netcdf

Joblib userwarning while trying to cache results

百般思念 提交于 2020-01-13 08:40:48
问题 I get the foll. userwarning when trying to cache results using joblib: from tempfile import mkdtemp cachedir = mkdtemp() from joblib import Memory memory = Memory(cachedir=cachedir, verbose=0) @memory.cache def get_nc_var3d(path_nc, var, year): """ Get value from netcdf for variable var for year :param path_nc: :param var: :param year: :return: """ try: hndl_nc = open_or_die(path_nc) val = hndl_nc.variables[var][int(year), :, :] except: val = numpy.nan logger.info('Error in getting var ' +

R Standardized Precipitation Index .nc file

蹲街弑〆低调 提交于 2020-01-13 05:59:10
问题 I'm trying to calculate the SPI from CHIRPS monthly mean precipitation data, because it's too large I cut it down to my area of interest and here it is: https://www.dropbox.com/s/jpwcg8j5bdc5gq6/chirps_mensual_v1.nc?dl=0 I did this to open it: require(utils) require(colorRamps) require(RNetCDF) require(rasterVis) require(rgdal) library(ncdf4) library(raster) datos2 <- nc_open("Datos/chirps_mensual_v1.nc") ppt_array <- ncvar_get(datos2, "precip") #I'm only taking complete years so I took out

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

Faster reading of time series from netCDF?

橙三吉。 提交于 2020-01-10 08:51:20
问题 I have some large netCDF files that contain 6 hourly data for the earth at 0.5 degree resolution. There are 360 latitude points, 720 longitude points, and 1420 time points per year. I have both yearly files (12 GB ea) and one file with 110 years of data (1.3 TB) stored as netCDF-4 (here is an example of the 1901 data, 1901.nc, its use policy, and the original, public files that I started with). From what I understood, it should be faster to read from one netCDF file rather than looping over

Error when creating variable to create a netCDF file

微笑、不失礼 提交于 2020-01-06 02:32:28
问题 I was able to figure out the lat, lon dimension declaration as indicated in the following code. I think I am close to obtain the netCDF file. But, I get an error. import numpy as np import netCDF4 import os # load the data path='C:\Users\.spyder2' os.chdir(path) # this load the file into a Nx3 array (three columns) data = np.loadtxt('TRMM_1998_01_0100_newntcl.csv', delimiter=',') # create a netcdf Data object with netCDF4.Dataset('TEST_file.nc', mode="w", format='NETCDF4') as ds: # some file

How to allocate size of Netcdf fortran array at run time?

时光怂恿深爱的人放手 提交于 2020-01-05 05:35:07
问题 I have a netCDF 4.4 file which has four dimensions- time, latitude,longitude, level. I want to be able to read the latitude and longitude values from this file and store them in a single dimensional array. However I do not know the size of the latitude array or longitude array and I so cannot allocate the size at the time of the declaration of the two arrays lat and lon. Each netCDF file that will be processed will have it's own lat and lon size and so it is not possible to declare this at

Python - Read data from netCDF file with time as “seconds since” beginning of measurement

荒凉一梦 提交于 2020-01-03 17:16:33
问题 I need to extract values from a netCDf file. I am pretty new to python and even newer this file format. I need to extract time series data at a specific location (lat, lon). I have found that there is a variable (called "base_time") in UNIX time and another variable (called "time") with "seconds since 2013-20-10 00:00:00" (which is the beginning of measurement time in UTC) for now. When i interrogate the dataset's variables, I get this: <type 'netCDF4.Variable'> int32 base_time() units:

Error when trying to import NetCDF to R

我的梦境 提交于 2020-01-03 17:12:26
问题 I' struggeling to open a NetCDF file in R. When I try to open it with library(ncdf) # read in NetCDF file maize.nc<-open.ncdf("C:/Users/Jo/Desktop/pft_harvest_maize.nc") I get the following error message: Error in R_nc_open: NetCDF: Unknown file format Error in open.ncdf("C:/Users/Jo/Desktop/pft_harvest_maize.nc") : Error in open.ncdf trying to open file C:/Users/Jo/Desktop/pft_harvest_maize.nc the weird thing is, that another NetCDF file with Runoff-Data from the exact same simulation with

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

妖精的绣舞 提交于 2020-01-02 04:57:07
问题 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] "