netcdf

Calculate variables mean in a selective area , in gridded netCDF file

核能气质少年 提交于 2019-12-23 04:04:13
问题 Let say we have TRMM precipitation data, each file represents data for each month. For example, the files in the folder are: 3B42.1998.01.01.7A.nc, 3B42.1998.02.01.7A.nc, 3B42.1998.03.01.7A.nc, 3B42.1998.04.01.7A.nc, 3B42.1998.05.01.7A.nc, ...... ...... 3B42.2010.11.01.7A.nc, 3B42.2010.12.01.7A.nc. These files having a dimension as follows : Xsize=1440, Ysize=400, Zsize=1,Tsize=1. Longitude set to 0 to 360 and Latitude set to -50 to 50. I want to calculate the amount of precipitation over a

Calculate variables mean in a selective area , in gridded netCDF file

柔情痞子 提交于 2019-12-23 04:04:03
问题 Let say we have TRMM precipitation data, each file represents data for each month. For example, the files in the folder are: 3B42.1998.01.01.7A.nc, 3B42.1998.02.01.7A.nc, 3B42.1998.03.01.7A.nc, 3B42.1998.04.01.7A.nc, 3B42.1998.05.01.7A.nc, ...... ...... 3B42.2010.11.01.7A.nc, 3B42.2010.12.01.7A.nc. These files having a dimension as follows : Xsize=1440, Ysize=400, Zsize=1,Tsize=1. Longitude set to 0 to 360 and Latitude set to -50 to 50. I want to calculate the amount of precipitation over a

How to change longitude range in a NetCDF

可紊 提交于 2019-12-22 17:48:34
问题 My NetCDF file has 4 dimensions (longitude, latitude, time, level pressure) and several variables. I want to replace the longitude data which is [340 342 344 ... 360 0 2 4 ... 18 20] by [-20 -18 -16 ... -2 0 2 4 ... 18 20]. In fact the longitude is counted from 0° to 360° but I need to have it from -180° to 180°. I have found some ideas on Internet but I don't know how to apply them. Here an explanation: "Some netcdf files contain strictly positive values [0,360] which are not compatible with

combining spatial netcdf files using xarray python

99封情书 提交于 2019-12-22 03:56:11
问题 Is there a way to merge 2 or more netCDF files with the same time dimension but different spatial domains into a single netCDF file? The spatial domains are specified by latitude and longitude coordinates? In the documentation for xarray concat, merge etc., they say that they work with a single dimension 回答1: My understanding of your question is that you want to want to open multiple netcdf files which contain different spatial sections of your data, where the overall dataset has been broken

Writing data to a netCDF file with R

吃可爱长大的小学妹 提交于 2019-12-22 00:09:18
问题 I am trying to use the data on my own .csv file to create a netCDF file using the R package "ncdf4". My dataset is composed by 3 columns: longitude, latitude and temperature and it has 2592 rows. I have been following the suggestions in the package to add the dimension and the variables to the netCDF file. Everything is fin until I want to write the temperature data on my file. I got this error: Error in ncvar_put(nc = ncnew, varid = var_temp, data, start = c(1, 1, : ncvar_put: error: you

Converting NetCDF to GRIB2

点点圈 提交于 2019-12-21 11:33:34
问题 I know there is software like wgrib2 that will convert files in grib and grib2 format to NetCDF files, but I need to go the other way: from NetCDF to grib2 , because the local weather offices here can only consume gridded data in grib2 format. It appears that one solution could be in Python, using the NetCDF4-Python library (or other) to read the NetCDF files and using pygrib to write grib2 . Is there a better way? 回答1: After some more research, I ended up using the British Met Office "Iris"

How to take a subset from a netCDF file using latitude/longitude boundaries in R

放肆的年华 提交于 2019-12-20 19:41:12
问题 I have a netCDF file that I wish to extract a subset from defined by latitude/longitude boundaries (i.e. a lat/long defined box), using the ‘ncdf’ package in R. A summary of my netCDF file is below. It has two dimensions (latitude and longitude) and 1 variable (10U_GDS4_SFC). It is essentially a lat/long grid containing wind values: [1] "file example.nc has 2 dimensions:" [1] "lat_0 Size: 1280" [1] "lon_1 Size: 2560" [1] "------------------------" [1] "file example.nc has 1 variables:" [1]

How to change a Lambert Conic Conformal raster projection to latlon degree R

白昼怎懂夜的黑 提交于 2019-12-20 02:38:38
问题 I have a raster, obtained from a netcdf which is in (Lambert Conic Conformal projection): library(meteoForecast) wrf_temporary <- getRaster("temp", day = Sys.Date(), frames = 'complete', resolution = 36, service = "meteogalicia") wrf_temporary extent : -18, 4230, -18, 3726 (xmin, xmax, ymin, ymax) coord. ref. : +proj=lcc +lat_1=43 +lat_2=43 +lat_0=34.82300186157227 +lon_0=-14.10000038146973 +x_0=536402.34 +y_0=-18558.61 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs Now I want to

Convert NetCDF (.nc) to GEOTIFF

霸气de小男生 提交于 2019-12-20 01:05:52
问题 I have .nc file sizing around 300MB with a couple of datasets ( TEMP , DEWPOINT ) forecast data. I need to convert ( TEMP ) dataset to multiple GEOTIFF (one .tif for each time slice). Here is how the .nc file looks like. Looked into this answer but it seems to be for the whole dataset. I tried GDAL but not sure how to make it work for each time slice. Any thoughts? netcdf4 -python? 回答1: gdal has a gdal_translate option that will allow you to do this to translate the file from .nc to .tiff .

Python : Replacing Values in netcdf file using netCDF4

孤街浪徒 提交于 2019-12-19 21:27:39
问题 I have a netcdf file with several values < 0. I would like to replace all of them with a single value (say -1). How do I do that using netCDF4? I am reading in the file like this: import netCDF4 dset = netCDF4.Dataset('test.nc') dset[dset.variables['var'] < 0] = -1 回答1: If you want to keep the data in the netCDF variable object, this should work: import netCDF4 dset = netCDF4.Dataset('test.nc') dset['var'][:][dset['var'][:] < 0] = -1 dset.close() # if you want to write the variable back to