issues: 419945711
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
419945711 | MDU6SXNzdWU0MTk5NDU3MTE= | 2806 | Dask arrays from `open_mfdataset` not loading when plotting inside a `multiprocessing` instance | 12760310 | closed | 0 | 1 | 2019-03-12T11:54:44Z | 2023-12-02T02:43:30Z | 2023-12-02T02:43:30Z | NONE | Code SampleUnfortunately I cannot include the original data, as it is quite large, but I can make an accessible dropbox folder if needed. ```python debug = False if not debug: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import xarray as xr import metpy.calc as mpcalc from metpy.units import units from glob import glob import numpy as np import pandas as pd from multiprocessing import Pool from functools import partial import os from utils import * import sys variable_name = 'cape_cin' projections = ['de','it','nord'] def main(): """In the main function we basically read the files and prepare the variables to be plotted. This is not included in utils.py as it can change from case to case.""" files = glob(input_file) dset = xr.open_mfdataset(files) # Only take hourly data dset = dset.sel(time=pd.date_range(dset.time[0].values, dset.time[-1].values, freq='H')) # Parse metadata for metpy dset = dset.metpy.parse_cf() # Select variable cape = dset['CAPE_ML'].squeeze().load()
def plot_files(dates, **args): first = True for date in dates: # Find index in the original array to subset when plotting i = np.argmin(np.abs(date - args['time'])) # Build the name of the output image filename = subfolder_images[args['projection']]+'/'+variable_name+'_%s.png' % args['cum_hour']
if name == "main": main() ``` Problem descriptionMy task is to routinely plot output from weather models in an automatized way. The main driver script is written in 'bash' and calls different 'python' scripts at the same time. Given that the input data is always dimensioned '(time, level, latitude, longitude)' and that I have to do one plot per timestep it seemed natural to me to use This works fine if I load the input More specifically. if I remove the In theory I would like to keep the It may well be that my code is somehow malformed but as far as I know this should not be the expected behaviour. Please apologize if I'm doing something wrong; every suggestion is highly appreciated! Thought that I report the error as I found it to be non-expected behaviour. Expected OutputArray should load into memory when plotting without the need to do it explicitly. Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2806/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
not_planned | 13221727 | issue |