netcdf

Plotting 2D data using Xarray takes a surprisingly long time?

半腔热情 提交于 2020-01-25 07:12:41
问题 I am reading NetCDF files using xarray. Each variable have 4 dimensions ( Times, lev, y, x ). After reading the variable, I calculate the mean of the variable QVAPOR along ( Times,lev ) dimensions. After calculation I get variable QVAPOR_mean which is a 2D variable with shape ( y: 699, x: 639 ). Xarray took only 10micro seconds to read the data with shape ( Times:2918, lev:36, y:699, x:639 ); but took more than 60 minutes to plot the filled contour of the data of shape ( y: 699, x: 639 ). I

How to plot latitude/longitude points over netcdf map

本小妞迷上赌 提交于 2020-01-25 05:05:57
问题 I have read in a netcdf file of observed climate data (global surface temperature) to R and would like to plot some species locality data (latitude/longitude coordinate points) over the top of this but am having difficulties doing so. I have generated my map of temperature using: obsula.pdclann <- open.ncdf("obsula.pdclann.nc") temp_var <- "temp_mm_1_5m" temp <- get.var.ncdf(obsula.pdclann, varid=temp_var) image.plot(temp) My species occurrence data are read in via the following: speciesall <

Determining signed state for HDF5 variables in NetCDF

点点圈 提交于 2020-01-24 12:55:19
问题 My team has been given HDF5 files to read. They contain structured data with unsigned variables. I and my team were overjoyed to find the NetCDF library, which allows pure-Java reading of HDF5 files, albeit using the NetCDF data model. No problem---we thought we'd just translate from the NetCDF data model to whatever model we wanted. As long as we get the data out. Then we tried to read an unsigned 32-bit integer from the HDF5 file. We can load up HDFView 2.9 and see that the variable is an

Using all elements of a list as argument to a system command (netCDF operator) in a python code

与世无争的帅哥 提交于 2020-01-17 04:31:14
问题 I've a python code performs some operator on some netCDF files. It has names of netCDF files as a list. I want to calculate ensemble average of these netCDF files using netCDF operator ncea (the netCDF ensemble average). However to call NCO, I need to pass all list elements as arguments as follows: filelist = [file1.ncf file2.ncf file3.ncf ........ file50.ncf] ncea file1.ncf file2.ncf ......file49.ncf file50.ncf output.cdf Any idea how this can be achieved. ANy help is greatly appreciated.

How to regrid a netCDF using bilinear interpolation?

此生再无相见时 提交于 2020-01-17 04:28:06
问题 I am looking for a procedure to apply bilinear interpolation to change the resolution of netCDF file (1.5°x1.5°) ---> (1.25°x0.9375°) Edit: I have been reading some pages and I found a function called remapbil . It comes from Climate Data Operator (CDO) . I tried to do the regrid but it did not work. This is my netCDF file info: File format: netCDF -1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter name 1 : unknown unknown instant 1 1 180 1 I16 : tp Grid coordinates : 1 :

error while writing to a Mysql wih python NetCDF

我怕爱的太早我们不能终老 提交于 2020-01-16 20:00:20
问题 #!/usr/bin/env python3 import datetime as dt # Python standard library datetime module import numpy as np from netCDF4 import Dataset # http://code.google.com/p/netcdf4-python/ import matplotlib.pyplot as plt #from mpl_toolkits.basemap import Basemap, addcyclic, shiftgrid import mysql.connector as sql from mysql.connector import errorcode import sys import getpass import hashlib import os import netCDF4 import sys, traceback def dbInsertGlobalAttributeCreateTable(cursor): ##Table name

error while writing to a Mysql wih python NetCDF

社会主义新天地 提交于 2020-01-16 20:00:15
问题 #!/usr/bin/env python3 import datetime as dt # Python standard library datetime module import numpy as np from netCDF4 import Dataset # http://code.google.com/p/netcdf4-python/ import matplotlib.pyplot as plt #from mpl_toolkits.basemap import Basemap, addcyclic, shiftgrid import mysql.connector as sql from mysql.connector import errorcode import sys import getpass import hashlib import os import netCDF4 import sys, traceback def dbInsertGlobalAttributeCreateTable(cursor): ##Table name

merging of Netcdf files

大兔子大兔子 提交于 2020-01-16 03:49:47
问题 I have around 500 netcdf(.nc) files.I need to combine all of them to a single file.I am new to programming and I don't have sufficient knowledge in merging these files.Can anybody please explain how we can merge these files and extract to a csv file or excel sheet.Which function we can use for merging of files.Any help will be really appreciated. 回答1: NCO's ncecat can combine any number of netCDF files together with ncecat in1.nc in2.nc ... inN.nc out.nc ncecat in*.nc out.nc Switches and

Reading file opened with Python Paramiko SFTPClient.open method is slow

↘锁芯ラ 提交于 2020-01-13 18:01:10
问题 I am trying to remote read a netcdf file. I used paramiko package to read my file, like this: import paramiko from netCDF4 import Dataset client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=’hostname’, username=’usrname’, password=’mypassword’) sftp_client = client.open_sftp() ncfile = sftp_client.open('mynetCDFfile') b_ncfile = ncfile.read() # **** nc = Dataset('test.nc', memory=b_ncfile) But the run speed of ncfile.read() is

Joblib userwarning while trying to cache results

拟墨画扇 提交于 2020-01-13 08:41:47
问题 I get the foll. userwarning when trying to cache results using joblib: from tempfile import mkdtemp cachedir = mkdtemp() from joblib import Memory memory = Memory(cachedir=cachedir, verbose=0) @memory.cache def get_nc_var3d(path_nc, var, year): """ Get value from netcdf for variable var for year :param path_nc: :param var: :param year: :return: """ try: hndl_nc = open_or_die(path_nc) val = hndl_nc.variables[var][int(year), :, :] except: val = numpy.nan logger.info('Error in getting var ' +