nco

How to convert daily to monthly netcdf files

狂风中的少年 提交于 2019-12-11 06:16:21
问题 I have downloaded climate model output in the form of netcdf files with one variable (pr) for the whole world with a daily time-step. My final goal is to have monthly data for Europe. I have never used netcdf files before and all the specific software for netcdf I could find doesn't seems to work in windows. Since I programme in R, I tried using the ncdf4 package but run into memory size problems (my files are around 2Gb)... I am now trying the netCDF4 module in python (first time I am using

setting values below a threshold to the threshold in a netcdf file

戏子无情 提交于 2019-12-10 23:05:43
问题 I want to set all values below a constant c to c itself in a netcdf file: file.nc A solution using climate data operators (CDO) would be cdo mul -gec,$c file.nc file.nc t1.nc cdo add -mulc,$c -ltc,$c file.nc t1.nc output.nc rm -f t1.nc But is there a neater/shorter way to do this? 回答1: You can use NCO's ncap2 to do this easily. For example, set all values of x below 100 to 100 in file.nc and output in file2.nc : >>> ncap2 -s 'where(x<100.) x=100;' file.nc -O file2.nc 回答2: ncap2's clipping

How to convert fixed size dimension to unlimited in a netcdf file

旧巷老猫 提交于 2019-12-09 10:57:03
问题 I'm downloading daily 600MB netcdf-4 files that have this structure: netcdf myfile { dimensions: time_counter = 18 ; depth = 50 ; latitude = 361 ; longitude = 601 ; variables: salinity temp, etc I'm looking for a better way to convert the time_counter dimension from a fixed size (18) to an unlimited dimension. I found a way of doing it with the netcdf commands and sed. Like this: ncdump myfile.nc | sed -e "s#^.time_counter = 18 ;#time_counter = UNLIMITED ; // (currently 18)#" | ncgen -o

NetCDF: How to mask/filter out non-land values in global dataset, preferably using Python and/or NCO?

*爱你&永不变心* 提交于 2019-12-07 22:56:41
问题 I have a global data at 0.25 degree resolution that I'd like to mask so that it only contains data values over land. The data covers full 360 degrees in the lon dimension and from -60 to 60 degrees in the lat dimension. The file header, as well as summary lat and lon coordinate values, are listed below: netcdf cmorph_global_daily { dimensions: lat = UNLIMITED ; // (480 currently) lon = 1440 ; time = 7305 ; variables: float lat(lat) ; lat:units = "degrees_north" ; lat:long_name = "Latitude" ;

How to concatenate monthly TRMM netCDF files into a single netCDF file using NCO or R on windows 7?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 08:59:30
问题 I have downloaded TRMM monthly precipitation rate in netCDF format from 1998 -2016, so approximately more than 200 files.The names of these files are 3B43.19980101.7.HDF.nc 3B43.19980201.7.HDF.nc 3B43.19980301.7.HDF.nc , and so on. I would like to concatenate all of these files into a single netCDF. I've tried using the NCO operator "ncrcat" which should be able to concatenate a very long series of files along the record dimension, in this case time, but so far no luck. I tried at first

NetCDF: How to mask/filter out non-land values in global dataset, preferably using Python and/or NCO?

陌路散爱 提交于 2019-12-06 08:02:33
I have a global data at 0.25 degree resolution that I'd like to mask so that it only contains data values over land. The data covers full 360 degrees in the lon dimension and from -60 to 60 degrees in the lat dimension. The file header, as well as summary lat and lon coordinate values, are listed below: netcdf cmorph_global_daily { dimensions: lat = UNLIMITED ; // (480 currently) lon = 1440 ; time = 7305 ; variables: float lat(lat) ; lat:units = "degrees_north" ; lat:long_name = "Latitude" ; float lon(lon) ; lon:units = "degrees_east" ; lon:long_name = "Longitude" ; float prcp(lat, lon, time)

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

How to concatenate monthly TRMM netCDF files into a single netCDF file using NCO or R on windows 7?

久未见 提交于 2019-12-04 13:12:26
I have downloaded TRMM monthly precipitation rate in netCDF format from 1998 -2016, so approximately more than 200 files.The names of these files are 3B43.19980101.7.HDF.nc 3B43.19980201.7.HDF.nc 3B43.19980301.7.HDF.nc , and so on. I would like to concatenate all of these files into a single netCDF. I've tried using the NCO operator "ncrcat" which should be able to concatenate a very long series of files along the record dimension, in this case time, but so far no luck. I tried at first simple with only 2 files ncrcat -O -h 3B43.19980101.7.HDF.nc 3B43.19980201.7.HDF.nc out.nc got ERROR: no

netcdf4 extract for subset of lat lon

南楼画角 提交于 2019-11-27 08:32:25
I would like to extract a spatial subset of a rather large netcdf file. From Loop through netcdf files and run calculations - Python or R from pylab import * import netCDF4 f = netCDF4.MFDataset('/usgs/data2/rsignell/models/ncep/narr/air.2m.1989.nc') # print variables f.variables.keys() atemp = f.variables['air'] # TODO: extract spatial subset How do I extract just the subset of netcdf file corresponding to a state (say Iowa). Iowa has following boundary lat lon: Longitude: 89° 5' W to 96° 31' W Latitude: 40° 36' N to 43° 30' N Well this is pretty easy, you have to find the index for the upper