netcdf

Python: How to use MFdataset in netCDF4

百般思念 提交于 2020-01-01 19:55:12
问题 I am trying to read multiple NetCDF files and my code returns the error: ValueError: MFNetCDF4 only works with NETCDF3_* and NETCDF4_CLASSIC formatted files, not NETCDF4. I looked up the documentation and MFdataset is not supported by NetCDF4, so I'm confused where to go from here. 回答1: I think the error is pretty clear, but there are ways to avoid it. 1/ You could convert the NetCDF files from NetCDF4 to the classic format using e.g. nccopy: nccopy -k classic nc4_file.nc ncclassic_file.nc 2/

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

Creating multi-dimensional NetCDF in R

自作多情 提交于 2020-01-01 09:12:20
问题 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

plot gebco data in python basemap

拈花ヽ惹草 提交于 2019-12-30 05:28:03
问题 I have downloaded some gebco bathymetry data as a netCDF file. I would like to plot it with python-basemap. I have tried, import netCDF4 from mpl_toolkits.basemap import Basemap # Load data dataset = netCDF4.Dataset('/home/david/Desktop/GEBCO/gebco_08_-30_45_5_65.nc') # Extract variables x = dataset.variables['x_range'] y = dataset.variables['y_range'] spacing = dataset.variables['spacing'] # Data limits nx = (x[-1]-x[0])/spacing[0] # num pts in x-dir ny = (y[-1]-y[0])/spacing[1] # num pts in

Fortran NetCDF - added new dimension need to fill it with zeroes

时间秒杀一切 提交于 2019-12-25 07:59:56
问题 I added a new dimension to an existing netCDF file in fortran using the following code - retval = nf_open(cfn,NF_WRITE,ncid) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_redef(ncid) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_def_dim(ncid,"xyz",len,dimid_xyz) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_enddef(ncid) Now I want to be able to fill this dimension with values of zero. The cardinality of this set is equal to the cardinality of

Hyperslab of a 4D netcdf variable using ncks

风流意气都作罢 提交于 2019-12-25 01:03:10
问题 I have a large large netcdf file, of which I only need certain data. Therefore, I want to create a subdivision of this netcdf file using ncks. The netcdf file is as following: Source: F:\LECOB\Model\20091208_195356.nc Format: 64bit Global Attributes: Model = 's26.bobshelf.20141113' Title = 'S-NWM_BiP' Dimensions: ni_t = 682 nj_t = 712 nk_t = 29 time = 1 (UNLIMITED) ni_w = 682 nj_w = 712 nk_w = 30 ni_u = 681 nj_u = 712 nk_u = 29 ni_v = 682 nj_v = 711 nk_v = 29 ni_f = 681 nj_f = 711 nk_f = 29

NetCDF Time series slice with Python 3

纵饮孤独 提交于 2019-12-24 19:48:56
问题 I'm trying to plot a week of time series data from NetCDF files and coming into some problems. I'm using the following packages: import netCDF4 from matplotlib import pyplot as plt import numpy as np import xarray as xr import dask First I import two .nc files: ds1 = xr.open_dataset('ERA5_forecast_100V_247_2008.nc') ds2 = xr.open_dataset('ERA5_analysis_100V_247_2008.nc') Then I select time and grid location using xarray: dsloc1 = ds1.sel(time='2008-02-10',longitude=2.2,latitude=48.7,method=

Why do I get different results in plotting a NetCDF layer with “image(x,y,z)” and “plot (raster)” using R-package Raster?

社会主义新天地 提交于 2019-12-24 15:46:36
问题 This might be something really simple to fix. I want to plot over a map a data layer from a NetCDF file using the function plot(raster). I don't know why I'm getting a raster skewed/offset (My guess is that the problem is in the transformation, resolution?) as shown in the following image. Incorrect map If I use the function image(x,y,z...) with the lat,lng, value matrices I get the correct display as is shown here: Correct map This is the code in R that I'm using: library(ncdf) library

leaflet-velocity - cannot read property 'data' of null

故事扮演 提交于 2019-12-24 08:38:51
问题 I am working on the wind animation by using leaflet-velocity.js, which can be found in either npm or github (https://github.com/danwild/leaflet-velocity) from my own atmospheric model output (WRF). To perform the wind animation, I wrote down my own python code to convert the model output from netCDF format to json format. The code is showing below import os, sys, json, numpy as np from glob import glob from netCDF4 import Dataset, num2date, date2num #- header templete header = {

Python Reading Multiple NetCDF Rainfall files of variable size

烈酒焚心 提交于 2019-12-23 06:03:56
问题 The issue I have is that the Australian Bureau of Meteorology has supplied me with Rainfall Data Files, that contains rainfall records recorded every 30 minutes for all active gauges. The problem is that for 1 day there are 48 30Minute files. I want to create time series of a particular Gauge. Which means reading all 48 files and searching for the Gauge ID, making sure it doesn't fail if for 1 30 minute period the gauge did not record anything?? here is link to file format: https://dl