Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mnfienen authored Jul 30, 2024
2 parents fe4d12a + f1a2eaa commit 6a67e9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ Fienen MN, Hughes, JD, Langevin, CL, Larsen, JD, and Leaf, AT. 2024.
python-for-hydrology
U.S. Geological Survey software release. Reston, VA.
https://doi.org/10.5066/P1QTRYJY


_For USGS internal use, this is related to IP-162677._
14 changes: 9 additions & 5 deletions notebooks/part0_python_intro/11_xarray_mt_rainier_precip.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
"outputs": [],
"source": [
"# make an output folder first\n",
"output_folder = Path('11-0output')\n",
"output_folder = Path('11-output')\n",
"output_folder.mkdir(exist_ok=True)\n",
"\n",
"encoding={'prcp': {'zlib': True, # compression algorithm\n",
Expand Down Expand Up @@ -966,7 +966,9 @@
"source": [
"### Write an xarray dataset to a raster\n",
"\n",
"Write part of the dataset out to a GeoTIFF. Note that rioxarray requires us to remove the `'grid_mapping'` attribute first (at least in version 0.15, you will get an error otherwise). `grid_mapping` is a variable from the original NetCDF dataset that specifies that coordinate reference information is contained in a variable called `'lambert_conformal_conic'` (we used it above to specify the coordinate reference information for **rioxarray**).\n",
"Write part of the dataset out to a GeoTIFF. \n",
"\n",
"Earlier versions of rioxarray require us to remove the `'grid_mapping'` attribute first (at least in version 0.15, you will get an error otherwise). `grid_mapping` is a variable from the original NetCDF dataset that specifies that coordinate reference information is contained in a variable called `'lambert_conformal_conic'` (we used it above to specify the coordinate reference information for **rioxarray**).\n",
"\n",
"#### Write a single 2D timeslice to a raster"
]
Expand All @@ -978,7 +980,9 @@
"outputs": [],
"source": [
"precip_slice = ds.sel(time='2018-12-30')['prcp']\n",
"del precip_slice.attrs['grid_mapping']"
"\n",
"# remove grid_mapping if needed\n",
"#del precip_slice.attrs['grid_mapping']"
]
},
{
Expand All @@ -1005,7 +1009,7 @@
"outputs": [],
"source": [
"precip_slice = ds.sel(time=slice('2018-12-25', '2018-12-30'))['prcp']\n",
"del precip_slice.attrs['grid_mapping']\n",
"\n",
"precip_slice.rio.to_raster(output_folder / 'pcrp_20181225-30.tif')"
]
},
Expand Down Expand Up @@ -1097,7 +1101,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 6a67e9d

Please sign in to comment.