netcdf

Writing data to a netCDF file with R

梦想的初衷 提交于 2019-12-04 15:17:05
I am trying to use the data on my own .csv file to create a netCDF file using the R package "ncdf4". My dataset is composed by 3 columns: longitude, latitude and temperature and it has 2592 rows. I have been following the suggestions in the package to add the dimension and the variables to the netCDF file. Everything is fin until I want to write the temperature data on my file. I got this error: Error in ncvar_put(nc = ncnew, varid = var_temp, data, start = c(1, 1, : ncvar_put: error: you asked to write 65160 values, but the passed data array only has 2592 entries! What's wrong? library(ncdf)

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

Python Interpolation with matplotlib/basemap

岁酱吖の 提交于 2019-12-04 11:17:50
I am rather new to programming and am having a very hard time understanding interpolation. Every single source I can find that attempts to explain it is extremely cryptic (especially the package specific sites for basemap/matplotlib). I am mapping using matplotlib's basemap however the nature of my data is that it comes in 5 degree by 5 degree blocks (lat lon blocks). I want to smooth out the map by interpolation. So first here is my code. from netCDF4 import Dataset import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap, addcyclic #load the netcdf file

Efficient way to plot data on an irregular grid

巧了我就是萌 提交于 2019-12-04 11:11:33
问题 I work with satellite data organized on an irregular two-dimensional grid whose dimensions are scanline (along track dimension) and ground pixel (across track dimension). Latitude and longitude information for each centre pixel are stored in auxiliary coordinate variables, as well as the four corners coordinate pairs (latitude and longitude coordinates are given on the WGS84 reference ellipsoid). The data is stored in netCDF4 files. What I am trying to do is efficiently plotting these files

How to delete a variable in a Scientific.IO.NetCDF.NetCDFFile?

ぐ巨炮叔叔 提交于 2019-12-04 10:26:37
Is it possible to delete a variable from a Scientific.IO.NetCDF.NetCDFFile ? If a file is opened like so: nc = Scientific.IO.NetCDF.NetCDFFile("File.nc", "a") neither a del nc.variables["var"] nor a nc.variables["var"] = None will delete the variable var . Thx in advance for any insight. The simple answer is that you can not delete a variable. This is a "feature" of the NetCDF C-API and is not a shortcoming of Scientific.IO.NetCDF or any of the other python netcdf modules. From the official NetCDF user guide: Attributes are more dynamic than variables or dimensions; they can be deleted and

Plotting netcdf in R with correct grid

懵懂的女人 提交于 2019-12-04 06:26:19
问题 My goal is to plot nitrate (no3) data on a world map, using the correct longitude and latitude for these data. There are two netcdf files: 1. with the data 2. with the grid information Summary info on the data: no3 is an array of length x*y*sigma no3_df is 'x*y obs. of 3 variables' x = integer [180] y = integer [193] sigma = array[53] I want to look at sigma ('depth') 20. I therefore did the following: # Load the needed libraries to handle netcdf files library(ncdf) library(akima) # Open data

Converting NetCDF to GRIB2

◇◆丶佛笑我妖孽 提交于 2019-12-04 04:37:25
I know there is software like wgrib2 that will convert files in grib and grib2 format to NetCDF files, but I need to go the other way: from NetCDF to grib2 , because the local weather offices here can only consume gridded data in grib2 format. It appears that one solution could be in Python, using the NetCDF4-Python library (or other) to read the NetCDF files and using pygrib to write grib2 . Is there a better way? After some more research, I ended up using the British Met Office "Iris" package ( http://scitools.org.uk/iris/docs/latest/index.html ) which can read NetCDF as well as OPeNDAP,

How can I specify dimension order when using ncdf4::ncvar_get?

会有一股神秘感。 提交于 2019-12-04 04:10:15
问题 Following a previous question (Faster reading of time series from netCDF?) I have re-permuted my netCDF files to provide fast time-series reads (scripts on github to be cleaned up eventually ...). In short, to make reads faster, I have rearranged the dimensions from lat, lon, time to time, lat, lon . Now, my existing scripts break because they assume that the dimensions will always be lat, lon, time , following the ncdf4 documentation of ncvar_get , for the 'start' argument: Order is X-Y-Z-T

Creating multi-dimensional NetCDF in R

故事扮演 提交于 2019-12-04 03:56:26
I am trying to create a multi-dimensional NetCDF file using the R package ncdf . I am working with climatic daily observations for a set of 1500 points, the number of observations is ~ 18250 for each point. The problem is that the structure of the NetCDF file ( create.ncdf ) occupies 4Gb and each point makes the size of the file increase by more than 3 Gb ( put.var.ncdf ) This is the code I am using: # Make a few dimensions we can use dimX <- dim.def.ncdf( "Long", "degrees", Longvector ) dimY <- dim.def.ncdf( "LAT", "degrees", Latvector ) dimT <- dim.def.ncdf( "Time", "days", 1:18250, unlim

Extend dimensions in netCDF file using R

半世苍凉 提交于 2019-12-04 01:29:11
I would like to write a netCDF file using R with 'unlimited' dimensions that I can later extend. This is what I have tried: Create a netcdf file library(ncdf4) ## define lat, lon time dimensions lat <- ncdim_def("latitude", "degrees_east", vals = 44.0, unlim = TRUE) lon <- ncdim_def("longitude", "degrees_north", vals = -88.5, unlim = TRUE) time <- ncdim_def("time", "days since 0000-01-01", 1:1000) ## define data with these dimensions x <- ncvar_def("myvar", units = "m2", dim = list(lat, lon, time)) ## create, write to, close nc file nc <- nc_create(filename = "tmp.nc", vars = list(x)) ncvar