nco

Change time axis units from “years since” to “days since” in netcdf file

情到浓时终转凉″ 提交于 2020-12-10 08:42:54
问题 I have a netcdf file that someone passed me that uses "years since DATE" as the time units: double time(time) ; time:standard_name = "time" ; time:long_name = "time" ; time:calendar = "proleptic_gregorian" ; time:axis = "T" ; time:units = "years since 2000-1-1 00:00:00" ; I want to change the units to "Days since" the same base date - Obviously the timevariable needs to be changed to be consistent. I was hoping for a solution using nco or cdo, but I am a bit stumped. (A python solution would

Combine multiple NetCDF files into timeseries multidimensional array python

自作多情 提交于 2020-06-24 10:12:08
问题 I am using data from multiple netcdf files (in a folder on my computer). Each file holds data for the entire USA, for a time period of 5 years. Locations are referenced based on the index of an x and y coordinate. I am trying to create a time series for multiple locations(grid cells), compiling the 5 year periods into a 20 year period (this would be combining 4 files). Right now I am able to extract the data from all files for one location and compile this into an array using numpy append.

converting an accumulated variable to timestep values in a netcdf file with CDO

爷,独闯天下 提交于 2020-02-25 04:40:29
问题 I have a netcdf-file with about 100 timesteps on a grid with one variable, which is accumulated over the timesteps. I am now interested in calculating the contribution of each timestep to the variable's value (i.e. the difference of consecutive timesteps). Currently I use the following sequence: To extract every single timestep into a new file I use cdo seltimestep,$i ... , calculate each difference into a new file with cdo sub $i ${i-1} ... and merge those new files in the end with cdo

Using all elements of a list as argument to a system command (netCDF operator) in a python code

与世无争的帅哥 提交于 2020-01-17 04:31:14
问题 I've a python code performs some operator on some netCDF files. It has names of netCDF files as a list. I want to calculate ensemble average of these netCDF files using netCDF operator ncea (the netCDF ensemble average). However to call NCO, I need to pass all list elements as arguments as follows: filelist = [file1.ncf file2.ncf file3.ncf ........ file50.ncf] ncea file1.ncf file2.ncf ......file49.ncf file50.ncf output.cdf Any idea how this can be achieved. ANy help is greatly appreciated.

Is there a way to crop a NETCDF file?

本小妞迷上赌 提交于 2020-01-12 08:15:59
问题 Imagine that you have a file example.nc , that has wind data defined in 90N, 90S, 180E, 180W region. Is there anyway I could in linux, with a simple nc-type command (without extracting the data in matlab/python to rewrite), crop this file to include a smaller region, subset of the above. For example, 30N, 10S, 60E and 30W. 回答1: Yes, using ncks from the NCO package: http://nco.sourceforge.net/nco.html If you know the indices corresponding to the lat/lon range you want, let's say they are 30-40

Is there a way to crop a NETCDF file?

六月ゝ 毕业季﹏ 提交于 2020-01-12 08:14:07
问题 Imagine that you have a file example.nc , that has wind data defined in 90N, 90S, 180E, 180W region. Is there anyway I could in linux, with a simple nc-type command (without extracting the data in matlab/python to rewrite), crop this file to include a smaller region, subset of the above. For example, 30N, 10S, 60E and 30W. 回答1: Yes, using ncks from the NCO package: http://nco.sourceforge.net/nco.html If you know the indices corresponding to the lat/lon range you want, let's say they are 30-40

NCO cropping a netcdf file using dimension values rather than indices

自古美人都是妖i 提交于 2020-01-01 19:20:32
问题 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? 回答1: Yes, using a decimal indicates the

netcdf4 extract for subset of lat lon

↘锁芯ラ 提交于 2019-12-17 09:42:21
问题 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

NCO: Extract a variable from NetCDF file using NCO ncks

坚强是说给别人听的谎言 提交于 2019-12-12 14:06:36
问题 I am trying to extract a variable from a multi-variable netcdf file, by entering the command: ncks -v ta temp1.nc out.nc However then I look at the out.nc header, all the variables are still there. The headers of both temp1.nc and out.nc are below: --- temp1.nc header --- dimensions: time = UNLIMITED ; // (124 currently) lon = 256 ; bnds = 2 ; lat = 128 ; lev = 40 ; variables: double time(time) ; time:standard_name = "time" ; time:long_name = "time" ; time:units = "days since 1850-1-1" ; time

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