Transforming NARR LCC coordinate system to Lat Lon #2648
-
I have tried to find a way to transform the Lambert Conic Conformal projection (meters) in NARR data to WGS 84, with no success whatsoever. These files have only 'x' and 'y' as coordinates, so I can't get lat_lon_grid_deltas and other lat lon dependent functions to work. If anyone could help me out, that would be wonderful. Here is some code to get the data I am working with. Also, how do I extract data for a certain location, such as 44.325, -96.785 from this grid the right way? I can get a lot of things to work, but in a hacky sort of way, and am finding documentation for what seems like basic operations to be quite lacking:) import numpy as np
import xarray as xr
import pandas as pd
from siphon.catalog import TDSCatalog
import fnmatch
import metpy.calc as calc
from metpy.units import units
yr = 1979
narr_data = TDSCatalog('https://rda.ucar.edu/thredds/catalog/files/g/ds608.0/3HRLY/' + str(yr) + '/catalog.xml')
ds = narr_data.datasets[np.min(np.where(fnmatch.filter(narr_data.datasets, '*3D*'))):np.max(np.where(fnmatch.filter(narr_data.datasets, '*3D*')))+1]
d = 0
lots_of_data = xr.open_dataset(ds[d].access_urls['OPENDAP']).metpy.parse_cf()
lots_of_data['u-component_of_wind_isobaric'].metpy.cartopy_crs
I am relatively new to Python, so I suppose that is adding to my struggles here. Otherwise, thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, Thanks for sharing your code, it was helpful. You are close. This line: actually adds a Coordinate Reference System (CRS) to your
From the documentation here: there is a part about your situation here: So, you can obtain the 2D latitude/longitude values for each grid cell in the NARR Lambert Conformal Conic grid like this:
I'm not familiar with WGS 84, but to properly locate the point Here is resource I've used for understanding this problem that details several approaches. The NARR grid is not terribly high resolution so you may be able to get away with looping instead of taking the Hope this is helpful! |
Beta Was this translation helpful? Give feedback.
Hi,
Thanks for sharing your code, it was helpful. You are close. This line:
lots_of_data = xr.open_dataset(ds[d].access_urls['OPENDAP']).metpy.parse_cf()
actually adds a Coordinate Reference System (CRS) to your
lots_of_data
variable, and this is the key to unlocking the rest of the puzzle. Here's what that looks like:From the documentation here:
https://unidata.github.io/MetPy/latest/tutorials/xarray_tutorial.html#coordinates-and-coordinate-reference-sys…