cdo-climate

converting float to byte in netcdf file

狂风中的少年 提交于 2019-12-11 06:17:18
问题 I have a large netcdf file with a standard float field which consists of only 0.0 or 1.0. I would like to convert it to a byte type from the command line to save some space and also make it easier to read in the array to a byte type in fortran. I tried to use ncap ncap -s 'fire=byte(fire)' CAMS_2003-2017_frp_mask2_africa_zip.nc test.nc but it just seems to zero all the fields. I was using zip_6 netcdf4 compression on the source file, I'm not sure if that complicates matters? UPDATE: I found

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

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" ;

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)

How to convert a rotated NetCDF back to a normal lat/lon grid?

故事扮演 提交于 2019-12-05 09:43:10
I have a NetCDF file with rotated coordinates. I need to convert it to normal lat/lon coordinates (-180 to 180 for lon and -90 to 90 for lat). library(ncdf4) nc_open('dat.nf') For the dimensions, it shows: [1] " 5 variables (excluding dimension variables):" [1] " double time_bnds[bnds,time] " [1] " double lon[rlon,rlat] " [1] " long_name: longitude" [1] " units: degrees_east" [1] " double lat[rlon,rlat] " [1] " long_name: latitude" [1] " units: degrees_north" [1] " char rotated_pole[] " [1] " grid_mapping_name: rotated_latitude_longitude" [1] " grid_north_pole_longitude: 83" [1] " grid_north

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

netCDF files in R

我与影子孤独终老i 提交于 2019-11-29 08:49:12
I have netCDF file obtained from here with name precip.mon.total.v6.nc . I am using ncdf package in R to open and analyse the file. new <- open.ncdf("precip.mon.total.v6.nc") > new [1] "file precip.mon.total.v6.nc has 4 dimensions:" [1] "lat Size: 360" [1] "lon Size: 720" [1] "nbnds Size: 2" [1] "time Size: 1320" [1] "------------------------" [1] "file precip.mon.total.v6.nc has 1 variables:" [1] "float precip[lon,lat,time] Longname:GPCC Monthly total of precipitation Missval:-9.96920996838687e+36" But when I extract the variable, I got the error > get.var.ncdf(new, "precip") Error: cannot

netCDF files in R

∥☆過路亽.° 提交于 2019-11-28 02:18:34
问题 I have netCDF file obtained from here with name precip.mon.total.v6.nc . I am using ncdf package in R to open and analyse the file. new <- open.ncdf("precip.mon.total.v6.nc") > new [1] "file precip.mon.total.v6.nc has 4 dimensions:" [1] "lat Size: 360" [1] "lon Size: 720" [1] "nbnds Size: 2" [1] "time Size: 1320" [1] "------------------------" [1] "file precip.mon.total.v6.nc has 1 variables:" [1] "float precip[lon,lat,time] Longname:GPCC Monthly total of precipitation Missval:-9

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