From e6a6b4e6d75cb77bfae05a34996e501c17465344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Wed, 19 Oct 2022 09:20:57 +0300 Subject: [PATCH 1/3] Convert byte_no_cf and cf_nasa_4326 to Zarr --- fixtures/byte_no_cf.zarr.zip | Bin 0 -> 5696 bytes fixtures/cf_nasa_4326.zarr.zip | Bin 0 -> 12315 bytes src/programs/raster/mdimtranslate.rs | 7 ++- src/raster/mdarray.rs | 77 ++++++++++++++------------- 4 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 fixtures/byte_no_cf.zarr.zip create mode 100644 fixtures/cf_nasa_4326.zarr.zip diff --git a/fixtures/byte_no_cf.zarr.zip b/fixtures/byte_no_cf.zarr.zip new file mode 100644 index 0000000000000000000000000000000000000000..cd2904e6d2b1394dbdd1f8d2d5727a75f3d009e5 GIT binary patch literal 5696 zcmd6rc{tSV{>R6Rv5Xm^A!IKZ>&P=Hg|ao)Y*{1wzK@YD9&4t_9?8DTHi#@`FNCs$ z2q9|;SrW3I;W^iNIH%Lo^E?0izSnhsuY3NO*Y`c|&pr3&{k_$cK%@}B{#Bi&sdX^< z=Zy-$0x1W|uSaG`j!W@!rK$n=C?NyTEj}gN;!0Hj_d@EK3;IBT zn{wu$R!1GS+|uqiu-+%Amm=E2D0SR@WZL6iZUivo1O5Bt8)e0r&B=lZo4TwNw{BGF z-K6>*&B*|7ej;aM`udC*fVyRKWhP-KoWcjY3OiGGPueQ2+?{iY;UuCE zn(vhDcXlKxHj^9GVz&rIS+*k&L>br0)AO-+mMXKx1dvw!SWl|T(C?-|=Nl}oE8Pr> zi*wmN<(EJ7JUv${`cUh5fXl{wbp%J;91?a;Z#>TN^(-AJ+szl;cbwYV(}w4A6NWTV zgyGpf{%*LILq%TVFlx&-^g(YtrD;krkFx2!f!PEXGc7>Db)=^_EZc?5yk*~Bex3y!WnBdijhEB-SZCYog-Y33HrP3t20qV;BbbhmK z^Qx?8%x$h+!7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Ew(Ar!Cv9VeV9RuH>#(tXw4VUy|-0KXn#fB{6M_&#S-G zR$SKIG@QV^nA6cxY_qM#hZWs32H9?IA5+1qX~Gs?)e)Yc*@!lYC$m9?U2mkJG`gJfSL^^m}VVaeB0v7kE!?PE=R zU*(h*_s=k%I8;A4Qy|ZNs*ShL=zWSOeQ|cGs|YLqyFAW8S#6s+$99rnAKgc(dc%2l z;c3qj5(0dBh63jkD$T7}!nx~9IPdMfq@|Xa8{ZwLofq=L%(%lRZ~MV^lLGanco#1% z5~3by)uo`s409y2R!J@VjnQrKu+tot&35s(t>yZrlV&o9E*MO6cACFay3fnhSIXkl ztNffl?7T(#iKmLBK9KyL4DP_JII`!7syp4@Do3k85M7>Al|B=WR~w?W`t7+n{2;rO znT`q`Q>bE_w(Y>Zc6u7hlYn6@Blhl88Kx zTI?v8bNQU0I>L9ALu$dP2$mDgEgv{;O`qm`=3q`DE$hLD8bTdfYV*3mrv8$>!z2eu z+s0*GFQ@fWXJ3^}^@8_*v%Jix?-&7I)Sm87QUe~~F=g&sU>eLw*<61zm zXU>?Otssz*z>s1#tt3`W{jQ`WpsXOo)Srda<}AjZ@L~p41-MHRLX0=8fJj!tiapxJ zbaEM9%Ae&YF6%ZHnAmeoOw!j>c%Ayw zL;@p;Jp;mwWD)J=Nmr*(n{)2(DFuNE7{1)|WAL>)g!)s;s{~N4&Y=F3atHn9ty~>J z;iB9)?J;8QkEGT&55h6zo1OW>5z35aHb)8&#dGShk!3_%^U* zlcnZH_&c%iJJ;d=0rWO3Xa%6(_~X$x1-d38>;^2Rh*AL1O~r5RYKU3VQ(!$I1M4!_ oYL|6$^2TnaVm_JE3fNj}^>=t=K&=e|2?4+CKz17ASpM&S0EjY!!2kdN literal 0 HcmV?d00001 diff --git a/src/programs/raster/mdimtranslate.rs b/src/programs/raster/mdimtranslate.rs index f6b561f6..559745de 100644 --- a/src/programs/raster/mdimtranslate.rs +++ b/src/programs/raster/mdimtranslate.rs @@ -230,11 +230,11 @@ mod tests { use super::*; - use crate::{test_utils::TempFixture, DatasetOptions, Driver, GdalOpenFlags}; + use crate::{DatasetOptions, Driver, GdalOpenFlags}; #[test] fn test_build_tiff_from_path() { - let fixture = TempFixture::fixture("cf_nasa_4326.nc"); + let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -243,7 +243,6 @@ mod tests { sibling_files: None, }; let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); - let mem_file_path = "/vsimem/2d3e9124-a7a0-413e-97b5-e79d46e50ff8"; let dataset = multi_dim_translate( @@ -266,7 +265,7 @@ mod tests { #[test] fn test_build_tiff_from_dataset() { - let fixture = TempFixture::fixture("cf_nasa_4326.nc"); + let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, diff --git a/src/raster/mdarray.rs b/src/raster/mdarray.rs index b089bdbe..e60ea0c7 100644 --- a/src/raster/mdarray.rs +++ b/src/raster/mdarray.rs @@ -804,7 +804,7 @@ mod tests { #[test] fn test_root_group_name() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -820,7 +820,7 @@ mod tests { #[test] fn test_array_names() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -830,14 +830,17 @@ mod tests { }; let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); let root_group = dataset.root_group().unwrap(); - let options = CslStringList::new(); //Driver specific options determining how groups should be retrieved. Pass nullptr for default behavior. + let options = CslStringList::new(); let array_names = root_group.array_names(options); - assert_eq!(array_names, vec!["Band1".to_string()]) + assert_eq!( + array_names, + vec!["X".to_string(), "Y".to_string(), "byte_no_cf".to_string()] + ) } #[test] fn test_n_dimension() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -847,8 +850,8 @@ mod tests { }; let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); let root_group = dataset.root_group().unwrap(); - let array_name = "Band1".to_string(); - let options = CslStringList::new(); //Driver specific options determining how the array should be opened. Pass nullptr for default behavior. + let array_name = "byte_no_cf".to_string(); + let options = CslStringList::new(); let md_array = root_group.open_md_array(&array_name, options).unwrap(); let n_dimension = md_array.num_dimensions(); assert_eq!(2, n_dimension); @@ -856,7 +859,7 @@ mod tests { #[test] fn test_n_elements() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -866,8 +869,8 @@ mod tests { }; let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); let root_group = dataset.root_group().unwrap(); - let array_name = "Band1".to_string(); - let options = CslStringList::new(); //Driver specific options determining how the array should be opened. Pass nullptr for default behavior. + let array_name = "byte_no_cf".to_string(); + let options = CslStringList::new(); let md_array = root_group.open_md_array(&array_name, options).unwrap(); let n_elements = md_array.num_elements(); assert_eq!(400, n_elements); @@ -875,7 +878,7 @@ mod tests { #[test] fn test_dimension_name() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -892,24 +895,24 @@ mod tests { .into_iter() .map(|dimensions| dimensions.name()) .collect(); - assert_eq!(group_dimensions_names, vec!["x", "y"]); + assert_eq!(group_dimensions_names, vec!["X", "Y"]); // array dimensions - let array_name = "Band1".to_string(); - let options = CslStringList::new(); //Driver specific options determining how the array should be opened. Pass nullptr for default behavior. + let array_name = "byte_no_cf".to_string(); + let options = CslStringList::new(); let md_array = root_group.open_md_array(&array_name, options).unwrap(); let dimensions = md_array.dimensions().unwrap(); let mut dimension_names = Vec::new(); for dimension in dimensions { dimension_names.push(dimension.name()); } - assert_eq!(dimension_names, vec!["y".to_string(), "x".to_string()]) + assert_eq!(dimension_names, vec!["Y".to_string(), "X".to_string()]) } #[test] fn test_dimension_size() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -919,8 +922,8 @@ mod tests { }; let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); let root_group = dataset.root_group().unwrap(); - let array_name = "Band1".to_string(); - let options = CslStringList::new(); //Driver specific options determining how the array should be opened. Pass nullptr for default behavior. + let array_name = "byte_no_cf".to_string(); + let options = CslStringList::new(); let md_array = root_group.open_md_array(&array_name, options).unwrap(); let dimensions = md_array.dimensions().unwrap(); let mut dimensions_size = Vec::new(); @@ -932,7 +935,7 @@ mod tests { #[test] fn test_read_data() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -944,7 +947,7 @@ mod tests { let root_group = dataset.root_group().unwrap(); let md_array = root_group - .open_md_array("Band1", CslStringList::new()) + .open_md_array("byte_no_cf", CslStringList::new()) .unwrap(); let values = md_array.read_as::(vec![0, 0], vec![20, 20]).unwrap(); @@ -987,7 +990,7 @@ mod tests { #[test] fn test_datatype() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1000,7 +1003,7 @@ mod tests { let root_group = dataset.root_group().unwrap(); let md_array = root_group - .open_md_array("Band1", CslStringList::new()) + .open_md_array("byte_no_cf", CslStringList::new()) .unwrap(); let datatype = md_array.datatype(); @@ -1012,7 +1015,7 @@ mod tests { #[test] fn test_spatial_ref() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1024,7 +1027,7 @@ mod tests { let root_group = dataset.root_group().unwrap(); let md_array = root_group - .open_md_array("Band1", CslStringList::new()) + .open_md_array("byte_no_cf", CslStringList::new()) .unwrap(); let spatial_ref = md_array.spatial_reference().unwrap(); @@ -1036,7 +1039,7 @@ mod tests { #[test] fn test_no_data_value() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1048,7 +1051,7 @@ mod tests { let root_group = dataset.root_group().unwrap(); let md_array = root_group - .open_md_array("Band1", CslStringList::new()) + .open_md_array("byte_no_cf", CslStringList::new()) .unwrap(); assert_eq!(md_array.no_data_value_as_double(), Some(0.)); @@ -1056,7 +1059,7 @@ mod tests { #[test] fn test_attributes() { - let fixture = TempFixture::fixture("cf_nasa_4326.nc"); + let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1101,15 +1104,12 @@ mod tests { "air_temperature" ); - assert_eq!( - md_array.attribute("_FillValue").unwrap().read_as_f64(), - -9999. - ); + assert_eq!(md_array.no_data_value_as_double().unwrap(), -9999.); } #[test] fn test_unit() { - let fixture = TempFixture::fixture("cf_nasa_4326.nc"); + let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1148,7 +1148,8 @@ mod tests { #[test] fn test_stats() { - let fixture = TempFixture::fixture("byte_no_cf.nc"); + // make a copy to avoid writing the statistics into the original file + let fixture = TempFixture::fixture("byte_no_cf.zarr.zip"); let dataset_options = DatasetOptions { open_flags: GdalOpenFlags::GDAL_OF_MULTIDIM_RASTER, @@ -1156,10 +1157,14 @@ mod tests { open_options: None, sibling_files: None, }; - let dataset = Dataset::open_ex(&fixture, dataset_options).unwrap(); + let dataset = Dataset::open_ex( + format!("/vsizip/{}", fixture.path().display()), + dataset_options, + ) + .unwrap(); let root_group = dataset.root_group().unwrap(); - let array_name = "Band1".to_string(); - let options = CslStringList::new(); //Driver specific options determining how the array should be opened. Pass nullptr for default behavior. + let array_name = "byte_no_cf".to_string(); + let options = CslStringList::new(); let md_array = root_group.open_md_array(&array_name, options).unwrap(); assert!(md_array.get_statistics(false, true).unwrap().is_none()); From d9b6dea1cec5e9d2a4be0cc7cf0bb0c37980696f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 20 Oct 2022 09:36:52 +0300 Subject: [PATCH 2/3] Ignore Zarr tests on pre-GDAL 3.4 --- src/programs/raster/mdimtranslate.rs | 2 ++ src/raster/mdarray.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/programs/raster/mdimtranslate.rs b/src/programs/raster/mdimtranslate.rs index 559745de..21a308b3 100644 --- a/src/programs/raster/mdimtranslate.rs +++ b/src/programs/raster/mdimtranslate.rs @@ -233,6 +233,7 @@ mod tests { use crate::{DatasetOptions, Driver, GdalOpenFlags}; #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_build_tiff_from_path() { let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; @@ -264,6 +265,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_build_tiff_from_dataset() { let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; diff --git a/src/raster/mdarray.rs b/src/raster/mdarray.rs index e60ea0c7..0d0556c0 100644 --- a/src/raster/mdarray.rs +++ b/src/raster/mdarray.rs @@ -803,6 +803,7 @@ mod tests { use crate::{test_utils::TempFixture, Dataset, DatasetOptions, GdalOpenFlags}; #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_root_group_name() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -819,6 +820,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_array_names() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -839,6 +841,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_n_dimension() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -858,6 +861,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_n_elements() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -877,6 +881,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_dimension_name() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -911,6 +916,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_dimension_size() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -934,6 +940,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_read_data() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -959,7 +966,10 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_read_string_array() { + // Beware https://github.com/georust/gdal/issues/299 if you want to reuse this + // This can't be Zarr because it doesn't support string arrays let fixture = TempFixture::fixture("alldatatypes.nc"); let dataset_options = DatasetOptions { @@ -989,6 +999,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_datatype() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -1014,6 +1025,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_spatial_ref() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -1038,6 +1050,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_no_data_value() { let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip"; @@ -1058,6 +1071,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_attributes() { let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; @@ -1108,6 +1122,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_unit() { let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip"; @@ -1147,6 +1162,7 @@ mod tests { } #[test] + #[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)] fn test_stats() { // make a copy to avoid writing the statistics into the original file let fixture = TempFixture::fixture("byte_no_cf.zarr.zip"); From a61bf526b2fba729d81c8f987d1ceee721e3a7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 20 Oct 2022 09:57:08 +0300 Subject: [PATCH 3/3] Delete nc fixtures --- fixtures/byte_no_cf.nc | Bin 1420 -> 0 bytes fixtures/cf_nasa_4326.nc | Bin 18815 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 fixtures/byte_no_cf.nc delete mode 100644 fixtures/cf_nasa_4326.nc diff --git a/fixtures/byte_no_cf.nc b/fixtures/byte_no_cf.nc deleted file mode 100644 index b9bf53e922ce6fcae5a7848c09172916b43785b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1420 zcmZ`&J8#=a5SH^O68oCNRaX(L86Qc>q*yW*Bg=>+L#Be9gn;0!Rtm8c<#6e|w%u}z zE4E~-lBG(QY4dk-#R0ilGLB(DM}pkhnQvylnVmW9y*Ow!&r?_)z<2Pm+5e{GPj_-7 zwOWTDDBLgWPpdpxtmCVzBwO8DTdkuX_CtCV7fGB(IbJF&_&j)bF&UqqUe5KA-?Lrq z4{aI_wa=RjYnCs5lESQW3 zy}5px#yNp7UB}T4r|oua(>d-Kw%0lK+^*wwZL8gdzu`~Av+-mQ{yEo!i_5-l=&osY z^*3+!SRC7NmE~eG7zV(kpJSYTNYGo|F!#W_o@pugbTkO(`U0;24#;EEayut&+p|wB z&+D|?dt5!sw)b=B{Nyk`4^G3ucr@3;JkIEQoKqYPagO3*lk33JpZLQd3?_3ug~}J# z3mk2h(I!t;Nd`RbArQ`r94<#yb&T>t0LQd| z2GETYQ$2eSnYzFl0@kKDYh2_|8*5)F%%+O|>j5-Ma2q}FFGIMaT3L5Q9dIw(UzNh{i8pB?{rMpHZ{l8Os(ynSZ&yt+B4YKPO8TrwOSAVf%Wn8 zI9ph?x|xwitb6@2$WPKuwu-WNjqfnO_Iv(IO*v|#>-Aqa*O~xNqG?8xRfZRL*hfWv zty~Y^$7!;N;Cfeeq=%qWJif#CG8m)ckuaN}yPe%5HHp#PDE{Ak0{-A{$mw73 zZS8iYEX#7oCFMjt6p`xN_ph7?Ci!+N1!n}_awjUr5oPBTF;ViZ5a^~7VoUi9(HTMn zaYQ)Z%95!l0#VRWPG^h?B4&h=8Df-D#w3-9OU?;H0OCkc$q;8!R1z^b3Xz+NP)d*> zm0+NOAEh%=DS7~;oO9(sB+vm?q{avYM>4|UAj%YH0KxH$1Dq-52t-PxI-Uups6nm_ z?GX7=Ng=q3EVx>D#pq2{NrfcfUjlK?zY<<@0H_=!+cGE@FQG<2P8|g=p%M~@zyPbW hroclvC{B>Bq+6&3Q`{j1R02nEg^(O*t9sB<{s;QkxMTnT diff --git a/fixtures/cf_nasa_4326.nc b/fixtures/cf_nasa_4326.nc deleted file mode 100644 index f4c2bae7d01fe452893fb1cdd66ce1d94b720804..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18815 zcmeI3ZERcB8OM*~B&4lNLt7}YQZ9jxGD5HuCuzh0dx`U+wuzOb6zD43ZEll09NXAV z%9~Vg6QiI>%g{6??FD~8W9zgj+lLJ(5^34S`T;511X8zY%9o985}GB%K5S*|dG7f? zw&Nr;OA6^W3LYO+A8JZAoX@BJk>h*vxuc6I^BCB?CDZhsyg}?>F*4u zlPNQuwag6pZ=$Q+eolYLO`7S9l}z02dm>?G4~-m-TL;C<-_+LRdtz+laBG>TugT|a z@~hhGIkF4IQ0j`zA-5N_o_brmc}o zTNV3~`>Mvr=Wif?_Q{H>N?E09l`K|u3s<95)#{O0Hg*$aSZg;CSGCA(gEbx-wGyK} zW^&xjrXOwj3}j$lHd$Qf`~9CQswz#PvWjwFtm>!cSG6u4%Uaoq5i_@57r%C^4j|QC z6Hg{a?GR^fMF>bsq+6Xe$5U1_9$urPO9ONtN@upV>1V15JP({sKa(5i?A@h1-tih8 zb(f@2-tj1P7ya|t9j`N)m^2ev>Ra6HbjRbsQmxMJJA6&;9*V;~yVj0Ff{3#cxszU5 z7Iw%QPsL56v)edq#m$q0M<29>zh1dqx{tVYsv9T{JE40sXLr?2H`3_E&QM$G)Rv?4 ztEP^hR8>{k5$iVcQ@2ZW^;y0pclA~~qPtqjlS+EL98SvLxjQ&CME6{N9;fWYiCukr zLj6O11O1Vq&fxA42C?@c%LIjBrzM>7>$|r#l(K6mHY;xF^I>xJm)Kq)NkMR>q+JF@wg<&aQ4_#2PmfJd_#- zC$dH&nJqn_=c z;(rsHzgFsE{xv#oKgzF4Dw3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