miniufo / xgrads

Parse and read ctl and associated binary file commonly used by GrADS into xarray
https://xgrads.readthedocs.io/
MIT License
70 stars 27 forks source link

pdef and template option seems can't work togther. #30

Closed singledoggy closed 2 years ago

singledoggy commented 2 years ago

Here is the diff of my 2 ctl

index 42f7e4d..2209bfd 100644
--- a/emis.aa.2019090100.d2.template.ctl
+++ "b/emis.aa.2019090100.d2.singel.ctl"
@@ -1,12 +1,12 @@
-DSET ^emis.aa.2019%m2%d2%h2.d2
+DSET ^emis.aa.2019090100.d2
 TITLE ind + ene + dom + tra + agr + MEGAN-MACC + GFED4-BioBurn_emission
 UNDEF 99999.0
-OPTIONS byteswapped template
+OPTIONS byteswapped
 pdef 288 270 lcc 30.618 110.375 144.500 135.500 40.00000 25.00000 105.00000 5000.000 5000.000
 xdef 736 linear 102.42991 0.02252252
 ydef 588 linear 23.80582 0.02252252
 ZDEF  20 LINEAR  1.0 1.0
-TDEF  24 LINEAR 00Z01Sep2019 60mn
+TDEF  1 LINEAR 00Z01Sep2019 60mn

And b/emis.aa.2019090100.d2.singel.ctl works fine, while a/emis.aa.2019090100.d2.template.ctl returns

ValueError: conflicting sizes for dimension 'y': length 588 on the data but length 270 on coordinate 'y' It seems that template option can't work together with pdef. Or it maybe something wrong in my code?

My code is: open_CtlDataset( 'filenamel')

It seems that if ctl.template: and if ctl.pdef: need to in correctly order. or __read_template_as_dask need to set y, x to pdef. You can check it and I would also test my idea when I get around to do it. Here is the key I think. t, y, x = dd.tdef.length(), dd.ydef.length(), dd.xdef.length()

miniufo commented 2 years ago

Hi, thanks for your interests in xgrads. I'll look into this later. Probably you find the bug.

miniufo commented 2 years ago

The bug is fixed and now closing this. Thank you for your contribution!