netcdf

How to avoid unsupported .nc file while reading from different directory

How to avoid unsupported .nc file while reading from different directory Question: I have several folders in a directory containing .nc files. While reading, I am getting an error: NETCDF can not read unsupported file Since there are more than 5 thousand files, I don’t know which file is corrupted or unsupported. Is there any …

Total answers: 1

plotting data from netcdf with cartopy isnt plotting data at 0 longitude

plotting data from netcdf with cartopy isnt plotting data at 0 longitude Question: im beggining my journey with gridded data, and ive been trying to plot some temperature data from a netcdf file with cartopy. I followed some examples and i cant understand why my plots have a white line in the middle. (i already …

Total answers: 1

Python extract multiple lat/lon from NETCDF files using xarray

Python extract multiple lat/lon from NETCDF files using xarray Question: I have a NC file (time, lat, lon) Download from here and I am trying to extracting time series of multiple stations (lat/lon points Download from here). So I tried it this way to read the coordinates and extract the nearest values from the NC …

Total answers: 1

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

Reading file opened with Python Paramiko SFTPClient.open method is slow Question: 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 …

Total answers: 1

how to read this netCDF file in python?

how to read this netCDF file in python? Question: I have this NetCDF file. it has 2 groups in it! I want to select one group and get the desired variable. I tried this in multiple ways but I failed. I could use simply print(ncfile.variables) but it’s not working! the file structure looks like this, …

Total answers: 1

Updating attritubtes in xarray inplace

Updating attritubtes in xarray inplace Question: I’m fairly new to using xarrays. I want to modify attributes of a NetCDF file inplace. But, the built-in function gives another new dataset instead. ds = xr.open_dataset(file_) # ds has “time” as one of the coordinates whose attributes I want to modify #here is ds for more clarity …

Total answers: 2

Creating a nested dictionary from a flattened dictionary

Creating a nested dictionary from a flattened dictionary Question: I have a flattened dictionary which I want to make into a nested one, of the form flat = {‘X_a_one’: 10, ‘X_a_two’: 20, ‘X_b_one’: 10, ‘X_b_two’: 20, ‘Y_a_one’: 10, ‘Y_a_two’: 20, ‘Y_b_one’: 10, ‘Y_b_two’: 20} I want to convert it to the form nested = {‘X’: …

Total answers: 8

Python : Replacing Values in netcdf file using netCDF4

Python : Replacing Values in netcdf file using netCDF4 Question: 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’] …

Total answers: 4

Combine multiple NetCDF files into timeseries multidimensional array python

Combine multiple NetCDF files into timeseries multidimensional array python Question: I am using data from multiple netcdf files (in a folder on my computer). Each file holds data for the entire USA, for a time period of 5 years. Locations are referenced based on the index of an x and y coordinate. I am trying …

Total answers: 5