The code is taking about 20 minutes to load a month for each variable with 168 time steps for the cycle of 00 and 12 UTC of each day. When it comes to saving to csv, the code takes even longer, it's been running for almost a day and it still hasn't saved to any station. How can I improve the code below?
Grib2 data extraction with xarray and cfgrib very slow, how to improve the code?
648 Views Asked by William Jacondino At
1
There are 1 best solutions below
Related Questions in PANDAS
- ModuleNotFoundError on .ipynb
- Str object is not callable in pandas
- Need help realigning python fill_between with data points
- AttributeError: module 'numba' has no attribute 'generated_jit'
- Fix error when assigning a list of values to dataframe row
- How to make pandas show large datasets in output?
- merge dataframe but do not sort by merge key
- vim python omnifunc not working some modules
- Preserving DataFrame Modifications Across Options in a Streamlit Application
- How to join 2 datasets by looking up based on a string (full match or part match)
- Python Pandas getting hierarchy path till top management
- How to convert pandas series to integer for use in datetime.fromisocalendar
- reformat numbers stored in array
- How can I resolve this error and work smoothly in deep learning?
- What is the best way to merge two dataframes that one of them has date ranges and the other one has date WITHOUT any shared columns?
Related Questions in DATAFRAME
- Preserving DataFrame Modifications Across Options in a Streamlit Application
- Python Pandas getting hierarchy path till top management
- What is the best way to merge two dataframes that one of them has date ranges and the other one has date WITHOUT any shared columns?
- python pandas plot.bar something wrong
- Subsetting rows with sequence of values and identifying columns where sequence begins
- How to group rows by values to create new columns in Pandas DataFrame?
- How to write an R function to pivot the last n minutes?
- How can I change the groupby scope to find the first value that meets the conditions of a mask?
- Eliminate sub elements in a huge list of strings as long as no duplicates appear
- How to transfer object dataframe in sklearn.ensemble methods
- How can i fix this error ? Attempt to get argmax of an empty sequence
- How can I change the groupby column to find the first row that meets the conditions of a mask if the initial groupby failed to find it?
- How to iteratively create matrices/vectors from columns/unique row values of dataframe, and pass them to subsequent code?
- How to convert scraped HTML document to a dataframe?
- Replacing values on a dataframe row using a specific value as reference
Related Questions in PYTHON-XARRAY
- How to add a new variable to xarray.Dataset in Python with same time,lat,lon dimensions with assign?
- get the band with the maximum value from a xarray stack
- Writing lat long co-ordinates for an 2-d array and making a .nc file out of it
- How to drop all coordinates and variables without dimensions in xarray
- Preserve coordinates in xarray.Dataset when subsetting a DataArray
- convert dataframe to netcdf multidimension using python
- Resampling chunked xarray creates many undesired time chunks
- How do I extract all the values from one variable in a NetCDF file with Python?
- Reproject large raster using Python
- Attribute Error while converting cdf file to xarray dataset
- Unexpected behavior when slicing xarray DataArray over the y dimension
- Use xr.apply_unfunc on a function that can only take scalars, with an input of multi-dimensional DataArrays
- python-xarray: How to create a Dataset and assign results of an iteration to the Dataset?
- Retrieve data from a .grib file for a specific latitude/longitude and convert it to a .csv file
- Assigning coordinates in existing xarray dataset and changing format for epoch
Related Questions in GFS
- What is the similar function to Distributed cache of Hadoop Distribution File system in Google File System
- Why Google File System divide files into Chunks with 64 MB?
- Is there any abstraction layer to work with GFS or HDFS?
- What is atomicity in the context of filesystems?
- The structure of the GFS checkpoint
- Why Google File System divide files into Chunks?
- Is the HDFS sink in Flume using a "anti-pattern" with it's default config
- how is a chunk server different from normal server?
- Processing big data on distributed system
- Xarray mfdataset combining files with different variables using cfgrib engine
- How to open multiple files in a path skiiping files with a determined name
- Does the Google File System allow listing directory contents?
- GFS/Hadoop master's storage capacity
- Persistent Logging in Gnome-Shell-Extension development?
- Why doesn't Hadoop file system support random I/O?
Related Questions in CFGRIB
- Retrieve data from a .grib file for a specific latitude/longitude and convert it to a .csv file
- No module named 'cfgrib' / 'ecmwflib'
- How do I properly install cfgrib and eccodes?
- Why is accessing values in xarray so slow?
- How to load and convert grib file from reduced gaussian grid to regular gaussian grid using cfgrib
- Error when converting grib file to netcdf
- Grib2 data extraction with xarray and cfgrib very slow, how to improve the code?
- xarray grib file - Error of shape extracting data
- Xarray mfdataset combining files with different variables using cfgrib engine
- 'cfgrib' is not showing in xarray engine list, when the python code is packaged with pyinstaller to get exe file
- Setting environment variable in python has no effect on cfgrib
- MetPy and grb2 file opening issue: xarray's Value Error
- Converting lat/lon coordinates into meters/kilometers for use in a metpy HRRR cross section
- Segmentation fault after updating eccodes for python
- Coordinate alignment off when using Metpy assign_y_x coordinates with manual CRS
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?

Reading .grib files using xr.open_mfdataset() and cfgrib:
I can speak to the slowness of reading grib files using
xr.open_mfdataset(). I had a similar task where I was reading in many grib using xarray and it was taking forever. Other people have experienced similar issues with this as well (see here).According to the issue raised here, "cfgrib is not optimized to handle files with a huge number of fields even if they are small."
One thing that worked for me was converting as many of the individual grib files as I could to one (or several) netcdf files and then read in the newly created netcdf file(s) to xarray instead. Here is a link to show you how you could do this with several different methods. I went with the
grib_to_netcdfcommand via ecCodes tool.In summary, I would start with converting your grib files to netcdf, as it should be able to read in the data to xarray in a more performant manner. Then you can focus on other optimizations further down in your code.
I hope this helps!