PlasmaFAIR / sdf-xarray

An xarray backend for reading SDF files from EPOCH
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Opening multifile data set seems to only provide data at the first time step #16

Closed d7919 closed 2 months ago

d7919 commented 2 months ago

I'm running Epoch1D for the simple two stream instability from the basic examples.

I can read each output time individually fine using sdf-xarray, but when I try to read as a multifile data set using

ds = xr.open_mfdataset(
    "*.sdf",
    combine="nested",
    data_vars='minimal', 
    coords='minimal', 
    compat='override', 
    preprocess=SDFPreprocess(), keep_particles = True
)

I don't hit any errors. Whilst plotting using plot(ds['X_Particles/Right'].isel(time=0), ds['Particles/Vx/Right'].isel(time=0),'bo', markersize = 1) works as expected, plot(ds['X_Particles/Right'].isel(time=1), ds['Particles/Vx/Right'].isel(time=1),'bo', markersize = 1) produces an empty plot with the default axis range. Printing the values, i.e. print(ds['X_Particles/Right'].isel(time=1).values) returns an array full of NaNs.

I'm new to epoch and sdf-xarray (and xarray) so I'm possibly just doing something stupid.

ZedThree commented 2 months ago

Oh I think that might just be combone="nested" -- try removing that? I think it's still in the readme but shouldn't be!

On Mon, 2 Sept 2024, 16:59 David Dickinson, @.***> wrote:

I'm running Epoch1D for the simple two stream instability from the basic examples https://epochpic.github.io/documentation/examples/basic_examples.html.

I can read each output time individually fine using sdf-xarray, but when I try to read as a multifile data set using

ds = xr.open_mfdataset( "*.sdf", combine="nested", data_vars='minimal', coords='minimal', compat='override', preprocess=SDFPreprocess(), keep_particles = True )

I don't hit any errors. Whilst plotting using plot(ds['X_Particles/Right'].isel(time=0), ds['Particles/Vx/Right'].isel(time=0),'bo', markersize = 1) works as expected, plot(ds['X_Particles/Right'].isel(time=1), ds['Particles/Vx/Right'].isel(time=1),'bo', markersize = 1) produces an empty plot with the default axis range. Printing the values, i.e. print(ds['X_Particles/Right'].isel(time=1).values) returns an array full of NaNs.

I'm new to epoch and sdf-xarray (and xarray) so I'm possibly just doing something stupid.

— Reply to this email directly, view it on GitHub https://github.com/PlasmaFAIR/sdf-xarray/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLAXWE4RPCMODZ2GV5X53ZUSDPRAVCNFSM6AAAAABNQSZNM6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGUYDCMRWHE3DKMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

d7919 commented 2 months ago

Ah thanks, that's sorted it. Yes I just copy-paste from the readme!

ZedThree commented 2 months ago

Fixed in 6ea7f96