我在xarray数据集中有一些复杂的数据(numpy dtype complex128),我想用to_netcdf保存这些数据。我得到以下错误:
TypeError: illegal primitive data type, must be one of dict_keys(['S1', 'i1', 'u1', 'i2', 'u2', 'i4', 'u4', 'i8', 'u8', 'f4', 'f8']), got c
我正在尝试创建一个类,它作为属性xarray数据保存为netcdf
下面是我启动构造函数的方式
import xarray as xr
class volume:
''' volume class to contain everything about the seismic dataset
'''
def __init__(cls, name=None, netcdf=None, xarray=None):
''' Generic initializer
'''
cls.
我是netCDF data的新手,确实需要一些帮助。我有一个包含365次(天)和14052个时间序列的文件。这些数据跨越了水文年份(9月13日至8月14日)。我正在寻找每个时间序列的年度总数。我已经附加了我在python中的失败尝试。这为我提供了所有单元格的总和,但不会根据时间序列对它们进行划分。
# Imports
import xarray as xr
import numpy as np
# Read a netCDF file into an xarray Dataset object
ds = xr.open_dataset("Desktop/GOA_dischar
我正在使用xarray创建一个netcdf文件,该文件基于来自pandas Dataframe的数据。数据是一维的,只有时间是维的。然后,我使用这个文件的软件使用libray netcdf4中的MFdataset()打开并加载数据。每次我使用to_netcdf()函数可用的任何引擎或格式创建netcdf文件(例如,名为test3.nc)时,我都会在使用MFDataset('test3.nc')打开它时获得错误OSError: master dataset test3.nc does not have a aggregation dimension import pandas
我正在尝试使用Windows10上的xarray和python3.7从OpenDAP服务器下载一些数据,遍历了一系列的站点和年份,并编写了本地文件。下面的一个简单示例分别使用其中的两个,对我来说可能会失败: import xarray as xr
stations = ["pxsc1","obxc1"]
for station in stations:
for year in ["2019","2020"]:
print(f"Working on station: {station} year:
我正试图通过遍历子目录来创建一个大数据帧。我想:
i)从子目录中的所有文件(扩展名为.nc )中读取数据,ii)选择其中的特定块iii)将其保存在output.nc文件中。
import os
import xarray as xr
import numpy as np
rootdir ='/Users/sm/Desktop/along_track_J2'
data_new=[]
for subdir, dirs, files in os.walk(rootdir):
for file in files:
file_name= os.path.
我想将沿两个坐标之间的横断面线的横截面数据保存为netCDF文件。 我遵循的是Metpy's Cross Section Analysis中描述的示例代码 以下是添加了remove crs命令的修改后的代码: import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import metpy.calc as mpcalc
from metpy.interpolate import
我已经记录了每日温度数据,但我只对冬季的月份感兴趣。
from netCDF4 import Dataset as netcdf_dataset
import numpy as np
import xarray as xr
#open NASA GISS gridded temperature netcdf file
df = xr.open_dataset('BerkeleyEarth.nc')
#pull out temperature variable
air=df.temperature
#select only winter months
WinterAir =
在我共享的here链接的帮助下,我试着把我的文本文件转换成NetCDF (nc)文件。然而,问题是我不能在GrADS中打开这个nc文件。我猜原因是我不能用这些代码行将元数据或其他东西添加到nc文件中。 因此,如果您只是帮助我如何改进我手中的代码,以便我可以在其他平台上打开它。我需要在RCMES中打开这个NetCDF文件,以便执行quantile映射偏差校正操作。因此,如果您有任何其他方式/编程语言/平台来执行quantile映射偏差校正的建议,它也同样有效。下面是我使用的代码。 import netCDF4 as nc
import numpy as np
import panda
impo