Skip to content

Commit

Permalink
Proper fix for datetime in GEE notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubawy-ama committed Mar 23, 2021
1 parent 60576f6 commit 37ccb0e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Cloud_Statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
"from utils.data_cube_utilities.dc_load import get_product_extents\n",
"from utils.data_cube_utilities.dc_time import dt_to_str\n",
"\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()))\n",
"\n",
"# Print the extents of the data.\n",
"print(\"Latitude Extents:\", full_lat)\n",
Expand Down
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Custom_Mosaics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
}
],
"source": [
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()))\n",
"\n",
"# Print the extents of the combined data.\n",
"print(\"Latitude Extents:\", full_lat)\n",
Expand Down
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Land_Change.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"from utils.data_cube_utilities.dc_load import get_product_extents\n",
"from utils.data_cube_utilities.dc_time import dt_to_str\n",
"\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()))\n",
"\n",
"# Print the extents of the combined data.\n",
"print(\"Latitude Extents:\", full_lat)\n",
Expand Down
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Spectral_Products.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
"from utils.data_cube_utilities.dc_load import get_product_extents\n",
"from utils.data_cube_utilities.dc_time import dt_to_str\n",
"\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()))\n",
"\n",
"# Print the extents of the combined data.\n",
"print(\"Latitude Extents:\", full_lat)\n",
Expand Down
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Vegetation_Phenology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
"from utils.data_cube_utilities.dc_load import get_overlapping_area\n",
"from utils.data_cube_utilities.dc_time import dt_to_str\n",
"\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), np.array([[datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')]]))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), np.array([[datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()]]))\n",
"\n",
"# Print the extents of each product.\n",
"str_min_max_dates = np.vectorize(dt_to_str)(min_max_dates)\n",
Expand Down
2 changes: 1 addition & 1 deletion gee-notebooks/DCAL/DCAL_Water_WOFS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"from utils.data_cube_utilities.dc_load import get_product_extents\n",
"from utils.data_cube_utilities.dc_time import dt_to_str\n",
"\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.strptime('2020-12', '%Y-%m')))\n",
"from datetime import datetime; full_lat, full_lon, min_max_dates = ((-90, 90), (-180, 180), (datetime.strptime('2014-04', '%Y-%m'), datetime.utcnow()))\n",
"\n",
"# Print the extents of the combined data.\n",
"print(\"Latitude Extents:\", full_lat)\n",
Expand Down
4 changes: 2 additions & 2 deletions scripts/update_notebooks
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ for notebook in $(ls ./gee-notebooks/DCAL | grep .ipynb); do
sed -i "s/ls8_l2_c2[_a-z]*/ls8_google/g" ./gee-notebooks/DCAL/$notebook
sed -i "s/ls8_lasrc[_a-z]*/ls8_google/g" ./gee-notebooks/DCAL/$notebook
sed -i "s/dc.list_measurements().loc\[product, 'nodata'\]/{**dict(dc.list_measurements().loc[product, 'nodata']), **{alias: dc.list_measurements().loc[product, 'nodata'][key] for key, aliases in dc.list_measurements().loc[product, 'aliases'].items() for alias in aliases}}/g" ./gee-notebooks/DCAL/$notebook
perl -pi -e "s/full_lat, full_lon, min_max_dates(?!==| ==)[ =].*get_overlapping_area\(api, platforms, products\)/from datetime import datetime; full_lat, full_lon, min_max_dates = \(\(-90, 90\), \(-180, 180\), np.array\(\[\[datetime.strptime\('2014-04', '%Y-%m'\), datetime.strptime\('2020-12', '%Y-%m'\)\]\]\)\)/g" ./gee-notebooks/DCAL/$notebook
perl -pi -e "s/full_lat, full_lon, min_max_dates(?!==| ==)[ =].*get_product_extents\(api, platform, product\)/from datetime import datetime; full_lat, full_lon, min_max_dates = \(\(-90, 90\), \(-180, 180\), \(datetime.strptime\('2014-04', '%Y-%m'\), datetime.strptime\('2020-12', '%Y-%m'\)\)\)/g" ./gee-notebooks/DCAL/$notebook
perl -pi -e "s/full_lat, full_lon, min_max_dates(?!==| ==)[ =].*get_overlapping_area\(api, platforms, products\)/from datetime import datetime; full_lat, full_lon, min_max_dates = \(\(-90, 90\), \(-180, 180\), np.array\(\[\[datetime.strptime\('2014-04', '%Y-%m'\), datetime.utcnow\(\)\]\]\)\)/g" ./gee-notebooks/DCAL/$notebook
perl -pi -e "s/full_lat, full_lon, min_max_dates(?!==| ==)[ =].*get_product_extents\(api, platform, product\)/from datetime import datetime; full_lat, full_lon, min_max_dates = \(\(-90, 90\), \(-180, 180\), \(datetime.strptime\('2014-04', '%Y-%m'\), datetime.utcnow\(\)\)\)/g" ./gee-notebooks/DCAL/$notebook
perl -pi -e "s/dc(?!==| ==)[ =].*api\.dc/dc = earthengine.Datacube\(\)/g" ./gee-notebooks/DCAL/$notebook
# Patch until ODC-GEE update
perl -pi -e "s/build_cloud_coverage_table_landsat\(product(?!==| ==)[ =].*product/build_cloud_coverage_table_landsat\(dc=dc, product=product/g" ./gee-notebooks/DCAL/$notebook
Expand Down

0 comments on commit 37ccb0e

Please sign in to comment.