Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh + Temporal not working if time values are negative or not chronological ordered #53467

Open
2 tasks done
rduivenvoorde opened this issue Jun 14, 2023 · 0 comments
Open
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats) Temporal Temporal filtering or animation

Comments

@rduivenvoorde
Copy link
Contributor

What is the bug or the crash?

Mesh layers (more specific ugrid and netcdf's) have their time dimension (often) defined as 'hours/days since ...

Eg:

dimensions:
	Two = 2 ;
	mesh2d_nEdges = 7 ;
	mesh2d_nNodes = 6 ;
	mesh2d_nFaces = 2 ;
	max_nMesh2D_face_nodes = 4 ;
	time = UNLIMITED ; // (3 currently)
variables:
	int mesh2d ;
		mesh2d:cf_role = "mesh_topology" ;
...
	double time(time) ;
		time:units = "hours since 2020-01-01 00:00:00.0" ;
		time:calendar = "gregorian" ;
		time:standard_name = "time" ;
		time:axis = "T" ;
...

Then the time data array for a dataset with 3 datasets/frames contains for example:
time = 0, 24, 48 ;
or
time = 24,48,72;

There is/was an issue with QGIS dropping the last timeframe, see #48942 (could be fixed by #53422).

But with (#53422) in place, both time frame examples above are working

But when the time array contain negative values AND zero
time =-48,-24,0 ;
OR when the time array is not ordered:
time = -72,-24,-48 ;

QGIS fails to show the right amount of frames. As in either it does not update the Temporal Controller the right way, OR it does not show data when looking on the right frame (after manually adjusting Temporal Controller)

To me it looks like this has something to do with how QGIS/MdalProvider determines the frame count and temporal extent...

I think first fix would be to handle negative values (in natural order), with a zero ending, or with zero in between

Then we could decide on how to handle ordered values in reverse order (72,48,24)

And last we could decide IF we want to handle nc's in which the time offsets are mixed/non-ordered. I'm not sure if ordering (and keeping indexes) would be easy to do, or if this would mean that non only the Time/offset array has to be re-arranged, but also the data arrays...

Steps to reproduce the issue

To reproduce, I created a python file to create a serie of 13 very small ugrid netcdf's:

# - 0,24,48  # 1 natural ordered start at 0
create_nc('01_t0_t24_t48.nc', times=[0, 24., 48.], values=values)
# - 48,24,0  # 2 reverse natural ordered start at 0
create_nc('02_t48_t24_t0.nc', times=[48., 24, 0], values=values)
# - 0,48,24  # 3 mixed order start at zero
create_nc('03_t0_t48_t24.nc', times=[0, 48., 24.], values=values)
# - 24,48,72 # 4 natural ordered start at 24
create_nc('04_t24_t48_t72.nc', times=[24., 48., 72.], values=values)
# - 72,48,24 # 5 reverse natural ordered start at 24
create_nc('05_t72_t48_t24.nc', times=[72., 48., 24.], values=values)
# - 24,72,48 # 6 mixed order start at 24
create_nc('06_t24_t72_t48.nc', times=[24., 72., 48.], values=values)
# - -48,-24,0 # 7 natural ordered negative times, start at 0
create_nc('07_t-48_t-24_t0.nc', times=[-48., -24., 0], values=values)
# - 0,-24,-48 # 8 reverse natural order negative times, start at 0
create_nc('08_t0_t-24_t-28.nc', times=[0, -24., -48.], values=values)
# - 0,-48,-24 # 9 mixed order negative times, start at 0
create_nc('09_t0_t-48_t-24.nc', times=[0, -48., -24.], values=values)
# - -72,-48,-24 # 10 natural ordered negative times, start at -72 end -24
create_nc('10_t-72_t-48_t-24.nc', times=[-72., -48., -24.], values=values)
# - -24,-48,-72 # 11 reverse natural ordered negative times, start at -72 end -24
create_nc('11_t-24_t-48_t-72.nc', times=[-24., -48., -72.], values=values)
# - -48,-24,-72 # 12 mixed order negative times, start at -72 end -24
create_nc('12_t-48_t-24_t-72.nc', times=[-48., -24., -72.], values=values)
# - -24., 0, 24. # natural order, but with negative offset and zero
create_nc('13_t-24_t0_t24.nc', times=[-24., 0, 24.], values=values)

I will attach both the script AND the created nc files here to try out or generate new ones:

testdata_and_scripts.zip

(There is also a 'temporal_test.py' to check framecount and temporal limit of a loaded layer)

Versions

Master and earliers

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@rduivenvoorde rduivenvoorde added Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats) Temporal Temporal filtering or animation labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats) Temporal Temporal filtering or animation
Projects
None yet
Development

No branches or pull requests

1 participant