netcdf4

NCO cropping a netcdf file using dimension values rather than indices

a 夏天 提交于 2019-12-04 18:08:28
CDO can crop a netcdf file in terms of latitude and longitude as long as they are defined in a standard way, and I know that NCO can cut out a subset of a netcdf file along any dimension if you know the range of indices that you want, as stated in the answers to this related question: Is there a way to crop a NETCDF file? However, I was wondering if the ncks hyperslabber can work directly on the values of the dimension, rather than the index values? Yes, using a decimal indicates the range of actual values (eg, latitudes) to extract over, while using integers indicates the range of indices

Convert hdf5 to netcdf4 in bash, R, python or NCL?

眉间皱痕 提交于 2019-12-02 11:08:04
问题 Is there a quick and simple way to convert HDF5 files to netcdf(4) from the command line in bash? Alternatively a simple script that handle such a conversion automatically in R, NCL or python ? 回答1: with netcdf-c library you can: $ nccopy in.h5 out.nc 回答2: NCL's ncl_convert2nc function is my go-to for this type of problem: https://www.ncl.ucar.edu/Document/Tools/ncl_convert2nc.shtml 来源: https://stackoverflow.com/questions/48864357/convert-hdf5-to-netcdf4-in-bash-r-python-or-ncl

Plotting netcdf file with levels in R

大城市里の小女人 提交于 2019-11-29 12:22:56
I have recently started to work with netcdf in R. Sample data is here: http://www.earthstat.org/data-download/ > Harvested area and yield for 175 crops > individual crops > soybean_HarvAreaYield2000_NetCDF In this folder, there is a netcdf file called soybean_AreaYieldProduction.nc This is how I open the netcdf library(ncdf4) dat <- nc_open("soybean_AreaYieldProduction.nc") print(soy) 1 variables (excluding dimension variables): float soybeanData[longitude,latitude,level,time] LayerDescriptions: struct(5).Data(:,:,1/2/3/4/5/6) to access data layer: 1=Harvested Area fraction, 2=Yield 3

Convert NetCDF file to CSV or text using Python

纵饮孤独 提交于 2019-11-29 08:58:37
I'm trying to convert a netCDF file to either a CSV or text file using Python. I have read this post but I am still missing a step (I'm new to Python). It's a dataset including latitude, longitude, time and precipitation data. This is my code so far: import netCDF4 import pandas as pd precip_nc_file = 'file_path' nc = netCDF4.Dataset(precip_nc_file, mode='r') nc.variables.keys() lat = nc.variables['lat'][:] lon = nc.variables['lon'][:] time_var = nc.variables['time'] dtime = netCDF4.num2date(time_var[:],time_var.units) precip = nc.variables['precip'][:] I am not sure how to proceed from here,

Plotting netcdf file with levels in R

夙愿已清 提交于 2019-11-28 05:41:29
问题 I have recently started to work with netcdf in R. Sample data is here: http://www.earthstat.org/data-download/ > Harvested area and yield for 175 crops > individual crops > soybean_HarvAreaYield2000_NetCDF In this folder, there is a netcdf file called soybean_AreaYieldProduction.nc This is how I open the netcdf library(ncdf4) dat <- nc_open("soybean_AreaYieldProduction.nc") print(soy) 1 variables (excluding dimension variables): float soybeanData[longitude,latitude,level,time]

h5py not sticking to chunking specification?

末鹿安然 提交于 2019-11-26 18:36:32
问题 Problem: I have existing netCDF4 files (about 5000 of them), (typically in shape 96x3712x3712) datapoints (float32). These are files with the first dimension being time (1 file per day), the second and third spatial dimensions. Currently, making a slice over the first dimension (even a partial slice), would take a lot of time because of the following reasons: the netCDF files are chunked with a chunksize of 1x3712x3712. Slicing over the time dimension basically would read the entire file.