netcdf

How to read NetCDF file and write to CSV using Python

蹲街弑〆低调 提交于 2019-11-28 11:48:00
My aim is to access data from a netcdf file and write to a CSV file in the following format. Latitude Longitude Date1 Date2 Date3 100 200 <-- MIN_SFC values --> So far I have accessed the variables, written the header to the file and populated the lat/lons. How can I access the MIN_SFC values for specified lon,lat coordinates and dates and then write to a CSV file. I'm a python newbie if there is a better way to go about this please let me know. NetCDF file info: Dimensions: time = 7 latitude = 292 longitude =341 Variables: float MIN_SFC (time=7, latitude = 292, longitude = 341) Here's what I

NetCDF and Python: Finding the closest lon/lat index given actual lon/lat values

。_饼干妹妹 提交于 2019-11-28 11:39:00
I'd like to be able to find the lon/lat coordinate indices of the closest location to a lon/lat tuple. This is already available in the Java API as GridCoordSystem.findXYindexFromLatLon(), but I haven't found anything comparable in the Python API. What I'm hoping to find in the API, or write myself and contribute to the API (if useful), is something like this: def get_indices(netcdf_dataset, lon_value, lat_value): ''' :param netcdf_dataset an open NetCDF data set object :param lon_value a longitude value, in degrees (-180...180) :param lat_value a latitude value, in degrees (-90...90) :return

The variable from a netcdf file comes out flipped

ⅰ亾dé卋堺 提交于 2019-11-28 10:24:25
I have downloaded a nc file from f=open.ncdf("file.nc") [1] "file Lfile.nc has 2 dimensions:" [1] "Longitude Size: 1440" [1] "Latitude Size: 720" [1] "------------------------" [1] "file filr.nc has 8 variables:" [1] "short ts[Latitude,Longitude] Longname:Skin Temperature (2mm) Missval:NA" I then wanted to work with the variable soil_moisture_c A = get.var.ncdf(nc=f,varid="soil_moisture_c",verbose=TRUE) I then plot A with image(A) . I got the map shown below,I even transposed it image(t(a)) but that was changed to other direction,and not how it should be. Anyway,in order to know what is wrong

R - Plotting netcdf climate data

最后都变了- 提交于 2019-11-28 09:31:01
I have been trying plot the following gridded netcdf file: "air.1999.nc" found at the following website: http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.html I have tried the code below based on answers I have found here and elsewhere, but no luck. library(ncdf); temp.nc <- open.ncdf("air.1999.nc"); temp <- get.var.ncdf(temp.nc,"air"); temp.nc$dim$lon$vals -> lon temp.nc$dim$lat$vals -> lat lat <- rev(lat) temp <- temp[nrow(temp):1,] temp[temp==-32767] <- NA temp <- t(temp) image(lon,lat,temp) library(maptools) data(wrld_simpl) plot(wrld_simpl, add = TRUE) This code was from modified from

Plotting netcdf file with levels in R

夙愿已清 提交于 2019-11-28 05:41:29
问题 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]

netCDF files in R

∥☆過路亽.° 提交于 2019-11-28 02:18:34
问题 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

plotting a smooth curve in matplotlib graphs

限于喜欢 提交于 2019-11-27 13:55:18
问题 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

netcdf4 extract for subset of lat lon

南楼画角 提交于 2019-11-27 08:32:25
I would like to extract a spatial subset of a rather large netcdf file. From Loop through netcdf files and run calculations - Python or R from pylab import * import netCDF4 f = netCDF4.MFDataset('/usgs/data2/rsignell/models/ncep/narr/air.2m.1989.nc') # print variables f.variables.keys() atemp = f.variables['air'] # TODO: extract spatial subset How do I extract just the subset of netcdf file corresponding to a state (say Iowa). Iowa has following boundary lat lon: Longitude: 89° 5' W to 96° 31' W Latitude: 40° 36' N to 43° 30' N Well this is pretty easy, you have to find the index for the upper

GDAL 编译C#环境下GDAL(支持HDF4、NetCDF)

巧了我就是萌 提交于 2019-11-27 08:19:08
题目: 编译C#环境下GDAL(支持HDF4、NetCDF) 需要文件: gdal-1.8.0 //gdal1.8版本 swigwin-1.3.4 //gdal1.8版本支持1.3.39系列,1.3.4亦可 HDF4.2.6_win_x86 //HDF4驱动,如要支持hdf4,必须编译 netcdf-4.1.1-win32-src.zip //netCDF驱动,需libsrc文件夹 netcdf-4.1.1-win32-bin.zip //netCDF驱动,需netcdf.lib文件 过程: 1、全部解压 2、用记事本打开gdal-1.8.0文件夹中,make.opt 3、分别修改 MSVC_VER=1400 //1400为visualstudio版本 GDAL_HOME = "C:\warmerda\bld6" //gdal编译生成目录 SWIG = C:\gdal\swigwin-1.3.40\swig.exe //swig目录(全路径,否则加环境变量(不建议)) *hdf4: # Uncomment the following and update to enable NCSA HDF Release 4 support. HDF4_PLUGIN = NO HDF4_DIR = E:\hdf4 HDF4_LIB = $(HDF4_DIR)\dll\hd426m.lib $

How to read NetCDF file and write to CSV using Python

旧街凉风 提交于 2019-11-27 06:25:46
问题 My aim is to access data from a netcdf file and write to a CSV file in the following format. Latitude Longitude Date1 Date2 Date3 100 200 <-- MIN_SFC values --> So far I have accessed the variables, written the header to the file and populated the lat/lons. How can I access the MIN_SFC values for specified lon,lat coordinates and dates and then write to a CSV file. I'm a python newbie if there is a better way to go about this please let me know. NetCDF file info: Dimensions: time = 7 latitude