Skip to content

Commit

Permalink
Update L1_working_with_age_ensembles.ipynb
Browse files Browse the repository at this point in the history
added verbose=False to series creation statements
  • Loading branch information
CommonClimate committed Aug 23, 2024
1 parent 960ee82 commit 15a3efb
Showing 1 changed file with 52 additions and 110 deletions.
162 changes: 52 additions & 110 deletions notebooks/L1_working_with_age_ensembles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1/1 [00:00<00:00, 2.21it/s]"
"100%|██████████| 1/1 [00:00<00:00, 2.01it/s]"
]
},
{
Expand Down Expand Up @@ -2160,27 +2160,9 @@
"execution_count": 19,
"id": "af7630ed",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time axis values sorted in ascending order\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/bf/_x19bm694857h_hrw44j0p7w0000gn/T/ipykernel_87583/3229721944.py:1: UserWarning: auto_time_params is not specified. Currently default behavior sets this to True, which might modify your supplied time metadata. Please set to False if you want a different behavior.\n",
" ts = pyleo.GeoSeries(time = age, value = paleoValues, value_name = value_name,\n",
"/Users/julieneg/Documents/GitHub/Pyleoclim_util/pyleoclim/core/geoseries.py:236: UserWarning: auto_time_params is not specified. Currently default behavior sets this to True, which might modify your supplied time metadata. Please set to False if you want a different behavior.\n",
" super().__init__(time, value, time_unit, time_name, value_name,\n"
]
}
],
"outputs": [],
"source": [
"ts = pyleo.GeoSeries(time = age, value = paleoValues, value_name = value_name,\n",
"ts = pyleo.GeoSeries(time = age, value = paleoValues, value_name = value_name, verbose=False,\n",
" time_name = time_name, value_unit = value_unit, time_unit = time_unit, depth = paleoDepth, lat = 6.45, lon = 125.83)\n",
"\n",
"ensemble = pyleo.EnsembleGeoSeries.from_AgeEnsembleArray(geo_series = ts, age_array = chronValues,\n",
Expand Down Expand Up @@ -2261,7 +2243,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1/1 [00:01<00:00, 1.69s/it]"
"100%|██████████| 1/1 [00:01<00:00, 1.77s/it]"
]
},
{
Expand Down Expand Up @@ -2329,34 +2311,6 @@
" <tr>\n",
" <th>0</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>http://linked.earth/lipd/paleo0model0ensemble0</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>None</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>cm</td>\n",
" <td>SST ensemble from the Bayesian calibration des...</td>\n",
" <td>None</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>http://linked.earth/lipd/paleo0model0ensemble0</td>\n",
" <td>realization 1</td>\n",
" <td>[[1.0, 28.2528873873423, 27.6829378220138, 28....</td>\n",
" <td>deg C</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>cm</td>\n",
" <td>SST ensemble from the Bayesian calibration des...</td>\n",
" <td>None</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>http://linked.earth/lipd/paleo0model1ensemble0</td>\n",
" <td>realization 1</td>\n",
" <td>[[2.5, -0.1929763844799, -0.266404906905685, 0...</td>\n",
Expand Down Expand Up @@ -2386,9 +2340,9 @@
" <th>2</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>http://linked.earth/lipd/paleo0model0ensemble0</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>None</td>\n",
" <td>realization 1</td>\n",
" <td>[[1.0, 28.2528873873423, 27.6829378220138, 28....</td>\n",
" <td>deg C</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>cm</td>\n",
Expand All @@ -2400,9 +2354,9 @@
" <th>3</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>http://linked.earth/lipd/paleo0model0ensemble0</td>\n",
" <td>realization 1</td>\n",
" <td>[[1.0, 28.2528873873423, 27.6829378220138, 28....</td>\n",
" <td>deg C</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>None</td>\n",
" <td>depth</td>\n",
" <td>[1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15....</td>\n",
" <td>cm</td>\n",
Expand All @@ -2422,16 +2376,16 @@
"3 MD982181.Khider.2014 http://linked.earth/lipd/paleo0model0ensemble0 \n",
"\n",
" ensembleVariableName ensembleVariableValues \\\n",
"0 depth [1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15.... \n",
"1 realization 1 [[1.0, 28.2528873873423, 27.6829378220138, 28.... \n",
"2 realization 1 [[2.5, -0.1929763844799, -0.266404906905685, 0... \n",
"3 depth [2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15.0, 16... \n",
"0 realization 1 [[2.5, -0.1929763844799, -0.266404906905685, 0... \n",
"1 depth [2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15.0, 16... \n",
"2 realization 1 [[1.0, 28.2528873873423, 27.6829378220138, 28.... \n",
"3 depth [1.0, 2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15.... \n",
"\n",
" ensembleVariableUnits ensembleDepthName \\\n",
"0 None depth \n",
"1 deg C depth \n",
"2 None depth \n",
"3 deg C depth \n",
"1 None depth \n",
"2 deg C depth \n",
"3 None depth \n",
"\n",
" ensembleDepthValues ensembleDepthUnits \\\n",
"0 [2.5, 5.0, 6.5, 7.0, 8.0, 11.5, 13.0, 15.0, 16... cm \n",
Expand Down Expand Up @@ -2560,7 +2514,7 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>8</th>\n",
" <th>3</th>\n",
" <td>MD982181.Khider.2014</td>\n",
" <td>Marine sediment</td>\n",
" <td>6.45</td>\n",
Expand All @@ -2584,25 +2538,25 @@
],
"text/plain": [
" dataSetName archiveType geo_meanLat geo_meanLon \\\n",
"8 MD982181.Khider.2014 Marine sediment 6.45 125.83 \n",
"3 MD982181.Khider.2014 Marine sediment 6.45 125.83 \n",
"\n",
" geo_meanElev paleoData_variableName \\\n",
"8 -2114.0 sst \n",
"3 -2114.0 sst \n",
"\n",
" paleoData_values paleoData_units \\\n",
"8 [27.8, 27.41, nan, nan, 27.55, 27.16, 27.35, 2... deg C \n",
"3 [27.8, 27.41, nan, nan, 27.55, 27.16, 27.35, 2... deg C \n",
"\n",
" paleoData_proxy paleoData_proxyGeneral time_variableName \\\n",
"8 None None age_calyrbp \n",
"3 None None age_calyrbp \n",
"\n",
" time_values time_units \\\n",
"8 [199.0, 205.0, 207.0, 211.0, 216.0, 222.0, 224... yr BP \n",
"3 [199.0, 205.0, 207.0, 211.0, 216.0, 222.0, 224... yr BP \n",
"\n",
" depth_variableName depth_values \\\n",
"8 depth_cm [1.0, 2.5, 3.0, 4.0, 5.0, 6.5, 7.0, 8.0, 9.0, ... \n",
"3 depth_cm [1.0, 2.5, 3.0, 4.0, 5.0, 6.5, 7.0, 8.0, 9.0, ... \n",
"\n",
" depth_units \n",
"8 cm "
"3 cm "
]
},
"execution_count": 24,
Expand All @@ -2621,19 +2575,7 @@
"execution_count": 25,
"id": "d5785af3",
"metadata": {},
"outputs": [
{
"ename": "IndexError",
"evalue": "too many indices for array: array is 1-dimensional, but 2 were indexed",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[25], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m paleoValues \u001b[38;5;241m=\u001b[39m \u001b[43mens_df\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mensembleVariableValues\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;66;03m#Drop the column that contains depth\u001b[39;00m\n\u001b[1;32m 2\u001b[0m paleoDepth \u001b[38;5;241m=\u001b[39m ens_df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mensembleDepthValues\u001b[39m\u001b[38;5;124m'\u001b[39m][\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 4\u001b[0m value_name \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSST\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
"\u001b[0;31mIndexError\u001b[0m: too many indices for array: array is 1-dimensional, but 2 were indexed"
]
}
],
"outputs": [],
"source": [
"paleoValues = ens_df['ensembleVariableValues'][1] #Drop the column that contains depth\n",
"paleoDepth = ens_df['ensembleDepthValues'][1]\n",
Expand All @@ -2658,13 +2600,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"id": "848cb8ac",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time axis values sorted in ascending order\n"
]
},
{
"ename": "IndexError",
"evalue": "tuple index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[26], line 8\u001b[0m\n\u001b[1;32m 1\u001b[0m ts \u001b[38;5;241m=\u001b[39m pyleo\u001b[38;5;241m.\u001b[39mGeoSeries(time \u001b[38;5;241m=\u001b[39m chronValues, value \u001b[38;5;241m=\u001b[39m paleo_row[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpaleoData_values\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39miloc[\u001b[38;5;241m0\u001b[39m], \n\u001b[1;32m 2\u001b[0m time_name \u001b[38;5;241m=\u001b[39m time_name, time_unit \u001b[38;5;241m=\u001b[39m time_unit,\n\u001b[1;32m 3\u001b[0m value_name \u001b[38;5;241m=\u001b[39m value_name, value_unit \u001b[38;5;241m=\u001b[39m value_unit,\n\u001b[1;32m 4\u001b[0m label \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mMD98-2181\u001b[39m\u001b[38;5;124m'\u001b[39m, archiveType \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mMarine sediment\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 5\u001b[0m depth \u001b[38;5;241m=\u001b[39m chronDepth, depth_name \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDepth\u001b[39m\u001b[38;5;124m'\u001b[39m, depth_unit \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcm\u001b[39m\u001b[38;5;124m'\u001b[39m, lat \u001b[38;5;241m=\u001b[39m paleo_df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgeo_meanLat\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39miloc[\u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m 6\u001b[0m lon \u001b[38;5;241m=\u001b[39m paleo_df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgeo_meanLon\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39miloc[\u001b[38;5;241m0\u001b[39m])\n\u001b[0;32m----> 8\u001b[0m ensemble \u001b[38;5;241m=\u001b[39m \u001b[43mpyleo\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mEnsembleGeoSeries\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_PaleoEnsembleArray\u001b[49m\u001b[43m(\u001b[49m\u001b[43mgeo_series\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mts\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpaleo_array\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mpaleoValues\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mage_depth\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mts\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdepth\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpaleo_depth\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mpaleoDepth\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/Documents/GitHub/Pyleoclim_util/pyleoclim/core/ensemblegeoseries.py:441\u001b[0m, in \u001b[0;36mEnsembleGeoSeries.from_PaleoEnsembleArray\u001b[0;34m(self, geo_series, paleo_array, paleo_depth, age_depth, extrapolate, verbose)\u001b[0m\n\u001b[1;32m 438\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAge depth and series time need to have the same length\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 440\u001b[0m \u001b[38;5;66;03m#Interpolate the age array to the value depth\u001b[39;00m\n\u001b[0;32m--> 441\u001b[0m mapped_paleo \u001b[38;5;241m=\u001b[39m \u001b[43mlipdutils\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmapAgeEnsembleToPaleoData\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 442\u001b[0m \u001b[43m \u001b[49m\u001b[43mensembleValues\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpaleo_array\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\n\u001b[1;32m 443\u001b[0m \u001b[43m \u001b[49m\u001b[43mdepthEnsemble\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpaleo_depth\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\n\u001b[1;32m 444\u001b[0m \u001b[43m \u001b[49m\u001b[43mdepthMapping\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mage_depth\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 445\u001b[0m \u001b[43m \u001b[49m\u001b[43mextrapolate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mextrapolate\u001b[49m\n\u001b[1;32m 446\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 448\u001b[0m series_list \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 450\u001b[0m \u001b[38;5;66;03m#check that mapped_age and the original time vector are similar, and that the object is not a geoseries object\u001b[39;00m\n",
"File \u001b[0;32m~/Documents/GitHub/Pyleoclim_util/pyleoclim/utils/lipdutils.py:1187\u001b[0m, in \u001b[0;36mmapAgeEnsembleToPaleoData\u001b[0;34m(ensembleValues, depthEnsemble, depthMapping, extrapolate)\u001b[0m\n\u001b[1;32m 1184\u001b[0m depthMapping \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(depthMapping)\n\u001b[1;32m 1186\u001b[0m \u001b[38;5;66;03m#Interpolate\u001b[39;00m\n\u001b[0;32m-> 1187\u001b[0m ensembleValuesMapped \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mzeros((\u001b[38;5;28mlen\u001b[39m(depthMapping),\u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshape\u001b[49m\u001b[43m(\u001b[49m\u001b[43mensembleValues\u001b[49m\u001b[43m)\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m)) \u001b[38;5;66;03m#placeholder\u001b[39;00m\n\u001b[1;32m 1189\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m extrapolate \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m 1190\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m np\u001b[38;5;241m.\u001b[39marange(\u001b[38;5;241m0\u001b[39m,np\u001b[38;5;241m.\u001b[39mshape(ensembleValues)[\u001b[38;5;241m1\u001b[39m]):\n",
"\u001b[0;31mIndexError\u001b[0m: tuple index out of range"
]
}
],
"source": [
"ts = pyleo.GeoSeries(time = chronValues, value = paleo_row['paleoData_values'].iloc[0], \n",
" time_name = time_name, time_unit = time_unit,\n",
" time_name = time_name, time_unit = time_unit, verbose=False,\n",
" value_name = value_name, value_unit = value_unit,\n",
" label = 'MD98-2181', archiveType = 'Marine sediment',\n",
" depth = chronDepth, depth_name = 'Depth', depth_unit = 'cm', lat = paleo_df['geo_meanLat'].iloc[0],\n",
Expand Down Expand Up @@ -2693,31 +2656,10 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "fafde780-42be-4403-bdfc-76326526c47d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Last updated: Fri Jun 28 2024\n",
"\n",
"Python implementation: CPython\n",
"Python version : 3.11.7\n",
"IPython version : 8.20.0\n",
"\n",
"y: not installed\n",
"\n",
"pyleoclim: 0.13.1b0\n",
"pandas : 2.1.4\n",
"numpy : 1.26.3\n",
"\n",
"Watermark: 2.4.3\n",
"\n"
]
}
],
"outputs": [],
"source": [
"%watermark -n -u -v -iv -wpy"
]
Expand Down

0 comments on commit 15a3efb

Please sign in to comment.