netcdf

Working with Python, files

允我心安 提交于 2019-12-10 19:27:00
问题 I have some data files which I need to read. I know I should use Dataset, but is there a way how to download these files without downloading them manually but by its URL? How would it look like in my case. I am working with conda-python and netCDF4. Whatever I do I cannot read these files. Sorry for my English. The source is http://meop40.troja.mff.cuni.cz:11180/gw.projekt/data.stratopauza/netcdf.profily/ My first try: from netCDF4 import Dataset import numpy as np my_example_nc_file = '

Write a float array to file in Java

流过昼夜 提交于 2019-12-10 15:17:38
问题 I'm reading in a NetCDF file and I want to read in each array as a float array and then write the float array to a new file. I can make it work if I read in the float array and then iterate over each element in the array (using a DataOutputStream), but this is very, very slow, my NetCDF files are over 1GB. I tried using an ObjectOutputStream, but this writes extra bytes of information. So, to recap. 1. Open NetCDF file 2. Read float array x from NetCDF file 3. Write float array x to raw data

Changing or Turning off _FillValues

ぐ巨炮叔叔 提交于 2019-12-10 12:30:50
问题 I want to either turn off the filling or change the _FillValue to None/NaN in the NetCDF file. How do you do this? I have tried looking it up and nobody talks about it. When I output a variable such as longitude, this is what I get: float32 lons(lons) units: degree_east unlimited dimensions: current shape = (720,) filling on, default _FillValue of 9.969209968386869e+36 used I have also tried masking, but it still gives me the information above. Here is some code I have: lati = numpy.arange(

Read Netcdf sub categories and convert to grid

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:38:35
问题 I also posted this question on stack gis 1. From the netcdf4 data that have sub categories, I want to be able to read "Retrieval/fs" variable. I also want to read them and convert to raster girds, but it seems that raster doesn't support netcdf4. I appreciate any suggestions. library(ncdf4) library(raster) file <- "http://140906_B7101Ar_150909171225s.nc4" names(file$var) "latitude" ... "longitude"... "Retrieval/fs" lat <- raster(file, varname="latitude") lon <- raster(file, varname="longitude

Error on using xarray open_mfdataset function

爱⌒轻易说出口 提交于 2019-12-10 10:37:18
问题 I am trying to combine multiple netCDF files with the same dimensions, their dimensions are as follows: OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 ), (u'lon', <type 'netCDF4._netCDF4.Dimension'>: name = 'lon', size = 1440 ), (u'time', <type 'netCDF4._netCDF4.Dimension'>: name = 'time', size = 96 ), (u'nv', <type 'netCDF4._netCDF4.Dimension'>: name = 'nv', size = 2 )]) OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 )

java netcdf 4 tutorial

那年仲夏 提交于 2019-12-10 04:35:41
问题 I am using the latest netcdf jar library from unidata website here: http://www.unidata.ucar.edu/downloads/netcdf/index.jsp I am looking for a java netcdf 4 tutorial/example but I can't seem to find one on their website or anywhere else for that matter. Version 4 is significantly different than the previous versions in that the write function (to write data to a variable) is no longer used and is replaced by writeCDL...I think. Has anyone used the latest version of netcdf with java? I'd really

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

大憨熊 提交于 2019-12-09 18:40:18
问题 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. 回答1: 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

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

Batch read netcdf files and average one variable

懵懂的女人 提交于 2019-12-08 10:42:39
问题 I'm a new R user. I now have daily netcdf data for year 1979 such as these: sm19790101.1.nc sm19790102.1.nc . . . sm19791231.1.nc I need to average a variable called "sm" to monthly resolution. I can now do this: glob2rx("sm197901*.1.nc") jan<-list.files(pattern=glob2rx("sm197901*.1.nc"),full.names=TRUE) to port all January data to jan, but I don't know how to open each file and get specific variable (I've had Rnetcdf package installed) . If I were to do this manually, it should be: s19790101

Writing R raster stack to NetCDF

北城以北 提交于 2019-12-08 09:18:09
问题 I've got an R grid file containing monthly temperature data for the year 1981 which I read in and tried to write to NetCDF using the following code: library(raster) library(ncdf4) library(RNetCDF) test <- raster('.../TavgM_1981.gri', package = "raster") rstack = stack(test) writeRaster(rstack, "rstack.nc", overwrite=TRUE, format="CDF", varname="Temperature", varunit="degC", longname="Temperature -- raster stack to netCDF", xname="X", yname="Y",zname="nbands", zunit="numeric") This writes the