netcdf

Compiling Fortran netCDF programs on Ubuntu

房东的猫 提交于 2019-11-29 20:41:21
问题 Ok, newb question here. I'm trying to compile simple_xy_wr.f90 -- a netCDF example program -- using gfortran on Ubuntu, and I must be doing something pretty silly; I don't have much experince compiling Fortran. First, I've got the libnetcdf-dev package installed, which includes files like /usr/lib/libnetcdf.a /usr/lib/libnetcdff.a /usr/include/netcdf.mod So, I've tried to compile the code with (various command like) f95 -o xy -I/usr/include/ -L/usr/lib/ -lnetcdff -lnetcdf simple_xy_wr.f90 and

Merge netCDF files in R

时光毁灭记忆、已成空白 提交于 2019-11-29 15:42:25
问题 I have 2 netCDF files (each .nc file has 4 variables: Susceptible, Infected, Recovered and Inhabitable. The dimension of each variable is 64 x 88). I would like to merge these 2 files into a single netCDF file such that the merged file will stack separately Susceptible from the 2 files, Infected from the 2 files, Recovered from the 2 files and Inhabitable from the 2 files. Here are the 2 files(first and second) Could anyone help me with this please? Thanks in advance, Ashok 回答1: The ncdf4

python netcdf: making a copy of all variables and attributes but one

泄露秘密 提交于 2019-11-29 12:32:47
问题 I need to process a single variable in a netcdf file that actually contains many attributes and variable. I think it is not possible to update a netcdf file (see question How to delete a variable in a Scientific.IO.NetCDF.NetCDFFile?) My approach is the following: get the variable to process from the original file process the variable copy all data from the original netcdf BUT the processed variable to the final file copy the processed variable to the final file My problem is to code step 3.

Plotting netcdf file with levels in R

大城市里の小女人 提交于 2019-11-29 12:22:56
I have recently started to work with netcdf in R. Sample data is here: http://www.earthstat.org/data-download/ > Harvested area and yield for 175 crops > individual crops > soybean_HarvAreaYield2000_NetCDF In this folder, there is a netcdf file called soybean_AreaYieldProduction.nc This is how I open the netcdf library(ncdf4) dat <- nc_open("soybean_AreaYieldProduction.nc") print(soy) 1 variables (excluding dimension variables): float soybeanData[longitude,latitude,level,time] LayerDescriptions: struct(5).Data(:,:,1/2/3/4/5/6) to access data layer: 1=Harvested Area fraction, 2=Yield 3

Convert NetCDF file to CSV or text using Python

纵饮孤独 提交于 2019-11-29 08:58:37
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(time_var[:],time_var.units) precip = nc.variables['precip'][:] I am not sure how to proceed from here,

netCDF files in R

我与影子孤独终老i 提交于 2019-11-29 08:49:12
I have netCDF file obtained from here with name precip.mon.total.v6.nc . I am using ncdf package in R to open and analyse the file. new <- open.ncdf("precip.mon.total.v6.nc") > new [1] "file precip.mon.total.v6.nc has 4 dimensions:" [1] "lat Size: 360" [1] "lon Size: 720" [1] "nbnds Size: 2" [1] "time Size: 1320" [1] "------------------------" [1] "file precip.mon.total.v6.nc has 1 variables:" [1] "float precip[lon,lat,time] Longname:GPCC Monthly total of precipitation Missval:-9.96920996838687e+36" But when I extract the variable, I got the error > get.var.ncdf(new, "precip") Error: cannot

Speeding up reading of very large netcdf file in python

不问归期 提交于 2019-11-29 01:16:56
问题 I have a very large netCDF file that I am reading using netCDF4 in python I cannot read this file all at once since its dimensions (1200 x 720 x 1440) are too big for the entire file to be in memory at once. The 1st dimension represents time, and the next 2 represent latitude and longitude respectively. import netCDF4 nc_file = netCDF4.Dataset(path_file, 'r', format='NETCDF4') for yr in years: nc_file.variables[variable_name][int(yr), :, :] However, reading one year at a time is

plotting a smooth curve in matplotlib graphs

北战南征 提交于 2019-11-28 21:30:45
i am reading a netcdf file using python and need to plot a graphs using matplotlib library in python . the netcdf file is containing 3 variables u v and w components . i have to draw these 3 components on a vertical scale. since these data is going to be used in a weather forecasting radar's . i need to plot these graphs with smooth curves around the corner . now the plot looks and the code is... from netCDF4 import Dataset from pylab import * import numpy from scipy import interpolate from scipy.interpolate import spline #passing the filename root_grp=Dataset('C:\\Python27\\MyPrograms\

Import netCDF file to Pandas dataframe

浪子不回头ぞ 提交于 2019-11-28 20:46:29
Merry Christmas. Im still very new to Python and Pandas so help is appreciated. I am trying to read in a netCDF file, which I can do and then import that into a Pandas Dataframe. The netcDF file is 2D so I just want to 'dump it in'. I have tried the DataFrame method but it doesn't recognize the object. Presumably I need to convert the netCDF object to a 2D numpy array? Again thanks for any ideas on the best way to do this. Best wishes Jason The xarray library handles arbitrary-dimensional netCDF data, and retains metadata. Xarray provides a simple method of opening netCDF files, and converting

How to properly plot projected gridded data in ggplot2?

别说谁变了你拦得住时间么 提交于 2019-11-28 17:13:17
问题 I've been using using ggplot2 to plot climatic gridded data for years. These are usually projected NetCDF files. Cells are square in model coordinates, but depending on which projection the model uses, might not be so in the real world. My usual approach is to remap the data first on a suitable regular grid, and then plot. This introduces a small modification to the data, usually this is acceptable. However, I've decided this is not good enough anymore: I want to plot the projected data