netcdf

Half of the world masked when using maskoceans in Basemap

你。 提交于 2019-12-12 12:17:27
问题 I would like to mask oceans when plotting the data from a netCDF dataset. I followed the great instructions given in the answer to this question. It works great for half of the world, but somehow, everything west of Greenwich is masked as well, both ocean and land. Here is my code: import netCDF4 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.cm as cm import mpl_toolkits from mpl_toolkits import basemap from mpl_toolkits.basemap import Basemap,

Convert NetCDF file to CSV or text using Python

我怕爱的太早我们不能终老 提交于 2019-12-12 07:06:53
问题 I'm trying to convert a netCDF file to either a CSV or text file using Python. I have read this post but I am still missing a step (I'm new to Python). It's a dataset including latitude, longitude, time and precipitation data. This is my code so far: import netCDF4 import pandas as pd precip_nc_file = 'file_path' nc = netCDF4.Dataset(precip_nc_file, mode='r') nc.variables.keys() lat = nc.variables['lat'][:] lon = nc.variables['lon'][:] time_var = nc.variables['time'] dtime = netCDF4.num2date

VTK - How to use vtkNetCDFCFReader to read an array or variable array at specific time frame

半城伤御伤魂 提交于 2019-12-12 04:33:38
问题 Im trying to load an array at a specific time frame (for example if it has 50 frames or time units then get an array corresponding to the 2nd time frame) from netCDF files (.nc). Im currently using vtkNetCDFCFReader and getting the data array "vwnd" from the 1st time frame like this: vtkSmartPointer<vtkNetCDFCFReader> reader = vtkSmartPointer<vtkNetCDFCFReader>::New(); reader->SetFileName(path.c_str()); reader->UpdateMetaData(); vtkSmartPointer<vtkStructuredGridGeometryFilter> geometryFilter

Error 'nf90_def_var_deflate has no IMPLICIT type' only on one computer

左心房为你撑大大i 提交于 2019-12-12 03:52:40
问题 I have some code which compiles fine on one machine but on a different machine (using the same compilers, gcc and gfortran, and same flags) I get an error which I can't understand how it is compile related: deflate_status = nf90_def_var_deflate(NCF%ncid, i, 0, 1, 7) 1 Error: Function 'nf90_def_var_deflate' at (1) has no IMPLICIT type The variable is definitely declared (and it compiles and runs on the first machine). What sort of problems with compile setup could cause this error? 来源: https:/

Extracting site-specific information from NetCDF file in R

99封情书 提交于 2019-12-12 03:37:31
问题 I got a NetCDF file from the German Meteorological Service concerning mean temperatures in Europe (CDC FDP SERVER). The only thing I want to extract is the daily mean temperature for Bornholm, which is an island in the central Baltic. I know how to extract information for certain coordinates (see code sample below). The only problem is that the file specific coordinates are 'rotated' which is why the geographic coordinates for Bornholm (extracted from GoogleMaps) are kind of useless. packages

Pandas Panel resampling alternatives

折月煮酒 提交于 2019-12-12 03:17:47
问题 I often use pd.Series.resample(), and am wondering if there is a way to resample/ interpolate monthly gridded data in the form (time,lat, lon) to say 'MS' (monthly start). I understand the feature is not directly implemented in Panel. Is there a workaround? 回答1: You should check out the xray package. It is an N-dimensional labeled array package that extends much of the pandas resampling/group-by functionality. It is a pure python package so is easy to install and includes some really nice

Using Javascript to make parallel server requests THREDDS OPeNDAP

流过昼夜 提交于 2019-12-12 03:15:15
问题 For the following THREDDS OPeNDAP server: http://data.nodc.noaa.gov/thredds/catalog/ghrsst/L2P/MODIS_T/JPL/2015/294/catalog.html I would like to note four Attributes of every file in there. The attributes are: northernmost lattitude; easternmost lattitude; westernmost lattitude; southernmost lattitude. These can be found under the Global attributes under: http://data.nodc.noaa.gov/thredds/dodsC/ghrsst/L2P/MODIS_T/JPL/2015/294/20151021-MODIS_T-JPL-L2P-T2015294235500.L2_LAC_GHRSST_N-v01.nc.bz2

regrid netcdf data to finer resolution in python

点点圈 提交于 2019-12-12 01:47:53
问题 I would like to downscale netcdf data from 0.5 degree to 0.25 (or lower) resolution by simply creating new finer resolution grid cells that have the same value as the coarser resolution cell. I have the foll. code which works fine for creating a coarser resolution file: from mpl_toolkits.basemap import Basemap from netCDF4 import Dataset import numpy as np import pdb filename = '/Users/r/global_aug4.region.nc' pdb.set_trace() with Dataset(filename, mode='r') as fh: lons = fh.variables['lon'][

Convert netcdf “land” variable to latitude and longitude with Python

隐身守侯 提交于 2019-12-11 18:45:16
问题 I have a global meteorological dataset and I want to access the data for a certain grid (lat,lon). However, the data is compressed, i.e. the parameters of interest do not have the dimensions (lat, lon), but "land". "land" is a 1D array of integers. I imported the file in python using import scipy.io.netcdf as netcdf path = '/path/.../ncfile.nc' ncfile = netcdf.netcdf_file(path,'r') Then I checked what variables there were and found that, e.g. the "Rainf" variable has the dimensions (tstep,

How can I save a 3 column data frame into a NetCDF file in R?

一世执手 提交于 2019-12-11 16:15:54
问题 I have a Nx3 tibble I'd like to save to a NetCDF (.nc) file. The tibble has three columns: Longitude (lon) Latitude (lat) Data for each point (var) How can I save this to a NetCDF (.nc) file in R? So far I've been using the raster package with mixed results: # Be careful to call raster and dplyr in this specific order. require(raster) require(dplyr) set.seed(10) df <- expand.grid(lon = 1:10, lat=1:10) %>% as_tibble() %>% mutate(var1 = rnorm(100)) val <- df %>% select(var1) %>% pull()