我在
AstroPy
使用海洋颜色-气候变化抑制(OC-CCI数据)时的包装。即,通过以下方式提取纬度和经度:
lats = nc.lat.data
lons = nc.lon.data
并将它们插入
loc = astropy.coordinates.EarthLocation(lons, lats)
退货:
Coordinates could not be parsed as either geocentric or geodetic, with respective exceptions "from_geocentric() missing 1 required positional argument: 'z'" and "Input parameters lon, lat, and height cannot be broadcast"
然而,将相同的过程应用于SeaHawk数据,我没有遇到这样的问题,尽管
lat
和
lon
SeaHawk的阵列是2D的,与OC-CCI的阵列相同。。。
有人知道变通办法吗?或者如何根据纬度和经度计算椭球高度?
我曾尝试创建meshgrid,将数据直接从netCDF文件馈送到函数中,但错误仍然存在。
编辑:这是代码:
import xarray as xr
import astropy.coordinates as coord
import numpy as np
nc1 = xr.open_dataset("SEAHAWK1_HAWKEYE.20210429T093401.L2.OC.nc", group = "navigation_data") #SEAHAWK DATA
lat1 = nc1.latitude.data
lon1 = nc1.longitude.data
loc1 = coord.EarthLocation(lon = lon1, lat = lat1)
nc2 = xr.open_dataset("WCS4395317542832488347.nc") #OC-CCI DATA
lat2 = nc2.lat.data
lon2 = nc2.lon.data
lat2 = np.float32(lat2)
lon2 = np.float32(lon2)
loc2 = coord.EarthLocation(lon = lon2, lat = lat2)
和
lon
从每个文件:
lat1
Out[13]:
array([[44.433517, 44.433372, 44.433224, ..., 44.057747, 44.0575 ,
44.057247],
[44.432293, 44.432137, 44.431976, ..., 44.0565 , 44.056244,
44.056004],
[44.43107 , 44.430916, 44.430763, ..., 44.05525 , 44.054993,
44.05475 ],
...,
[37.489437, 37.48917 , 37.4889 , ..., 37.01369 , 37.013416,
37.01314 ],
[37.488235, 37.48797 , 37.487694, ..., 37.01249 , 37.012215,
37.011948],
[37.487103, 37.486835, 37.486572, ..., 37.011353, 37.01109 ,
37.010815]], dtype=float32)
lat2
Out[14]:
array([43.609375, 43.598957, 43.588543, 43.578125, 43.567707, 43.557293,
43.546875, 43.536457, 43.526043, 43.515625, 43.505207, 43.494793,
43.484375, 43.473957, 43.463543, 43.453125, 43.442707, 43.432293,
43.421875, 43.411457, 43.401043, 43.390625, 43.380207, 43.369793,
43.359375, 43.348957, 43.338543, 43.328125, 43.317707, 43.307293,
43.296875, 43.286457, 43.276043, 43.265625, 43.255207, 43.244793,
43.234375, 43.223957, 43.213543, 43.203125, 43.192707, 43.182293,
43.171875, 43.161457, 43.151043, 43.140625, 43.130207, 43.119793,
43.109375, 43.098957, 43.088543, 43.078125, 43.067707, 43.057293,
43.046875, 43.036457, 43.026043, 43.015625, 43.005207, 42.994793,
42.984375, 42.973957, 42.963543, 42.953125, 42.942707, 42.932293,
42.921875, 42.911457, 42.901043, 42.890625, 42.880207, 42.869793,
42.859375, 42.848957, 42.838543, 42.828125, 42.817707, 42.807293,
42.796875, 42.786457, 42.776043, 42.765625, 42.755207, 42.744793,
42.734375, 42.723957, 42.713543, 42.703125, 42.692707, 42.682293,
42.671875, 42.661457, 42.651043, 42.640625, 42.630207, 42.619793,
42.609375, 42.598957, 42.588543, 42.578125, 42.567707, 42.557293,
42.546875, 42.536457, 42.526043, 42.515625], dtype=float32)
错误仍然保持不变。