-
Notifications
You must be signed in to change notification settings - Fork 283
/
fc_rules_cf.krb
2037 lines (1759 loc) · 79 KB
/
fc_rules_cf.krb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of Iris.
#
# Iris is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Iris is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Iris. If not, see <http://www.gnu.org/licenses/>.
#
# Pyke forward chaining rule interface to translate NetCDF Climate Forecast (CF)
# Metadata Conventions data into an Iris cube.
#
# References:
#
# [CF] NetCDF Climate and Forecast (CF) Metadata conventions, Version 1.5, October, 2010.
#
#
# Context:
# This rule will always trigger.
#
# Purpose:
# Add standard meta-data to the cube.
#
fc_default
assert
python build_cube_metadata(engine)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a rotated pole.
#
# Purpose:
# Creates the rotated pole lat/lon coordinate system.
#
fc_provides_grid_mapping_rotated_latitude_longitude
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_ROTATED_LAT_LON)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_rotated_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, rotated_latitude_longitude)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a regular lat/lon.
#
# Purpose:
# Creates the lat/lon coordinate system.
#
fc_provides_grid_mapping_latitude_longitude
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_LAT_LON)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_coordinate_system(cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, latitude_longitude)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a transverse Mercator.
#
# Purpose:
# Creates the transverse Mercator coordinate system.
#
fc_provides_grid_mapping_transverse_mercator
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_TRANSVERSE)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_transverse_mercator_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, transverse_mercator)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a Mercator.
#
# Purpose:
# Creates the Mercator coordinate system.
#
fc_provides_grid_mapping_mercator
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_MERCATOR)
check has_supported_mercator_parameters(engine, $grid_mapping)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_mercator_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, mercator)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a stereographic.
#
# Purpose:
# Creates the stereographic coordinate system.
#
fc_provides_grid_mapping_stereographic
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_STEREO)
check has_supported_stereographic_parameters(engine, $grid_mapping)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_stereographic_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, stereographic)
python engine.rule_triggered.add(rule.name)
#
# Context: This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a Lambert conformal.
#
# Purpose:
# Creates the Lambert conformal conic coordinate system.
#
fc_provides_grid_mapping_lambert_conformal
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_LAMBERT_CONFORMAL)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_lambert_conformal_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, lambert_conformal)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a grid_mapping() case specific fact
# has been asserted that refers to a lambert azimuthal equal area.
#
# Purpose:
# Creates the lambert azimuthal equal area coordinate system.
#
fc_provides_grid_mapping_lambert_azimuthal_equal_area
foreach
facts_cf.grid_mapping($grid_mapping)
check is_grid_mapping(engine, $grid_mapping, CF_GRID_MAPPING_LAMBERT_AZIMUTHAL)
assert
python cf_grid_var = engine.cf_var.cf_group.grid_mappings[$grid_mapping]
python coordinate_system = build_lambert_azimuthal_equal_area_coordinate_system(engine, cf_grid_var)
python engine.provides['coordinate_system'] = coordinate_system
facts_cf.provides(coordinate_system, lambert_azimuthal_equal_area)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# has been asserted that refers to a CF latitude coordinate.
#
# Purpose:
# Assert that the CF latitude coordinate exists.
#
fc_provides_coordinate_latitude
foreach
facts_cf.coordinate($coordinate)
check is_latitude(engine, $coordinate)
assert
facts_cf.provides(coordinate, latitude, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# has been asserted that refers to a CF longitude coordinate.
#
# Purpose:
# Assert that the CF longitude coordinate exists.
#
fc_provides_coordinate_longitude
foreach
facts_cf.coordinate($coordinate)
check is_longitude(engine, $coordinate)
assert
facts_cf.provides(coordinate, longitude, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# has been asserted that refers to a CF projection_x_coordinate.
#
# Purpose:
# Assert that the CF projection_x_coordinate exists.
#
fc_provides_projection_x_coordinate
foreach
facts_cf.coordinate($coordinate)
check is_projection_x_coordinate(engine, $coordinate)
assert
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# has been asserted that refers to a CF projection_y_coordinate.
#
# Purpose:
# Assert that the CF projection_y_coordinate exists.
#
fc_provides_projection_y_coordinate
foreach
facts_cf.coordinate($coordinate)
check is_projection_y_coordinate(engine, $coordinate)
assert
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# has been asserted that refers to a CF time coordinate.
#
# Purpose:
# Assert that the CF time coordinate exists.
#
fc_provides_coordinate_time
foreach
facts_cf.coordinate($coordinate)
check is_time(engine, $coordinate)
assert
facts_cf.provides(coordinate, time, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a coordinate() case specific fact
# had been asserted that contains units of time, but is not
# a time reference.
#
# Purpose:
# Assert that the forecast period coordinate exists.
#
fc_provides_coordinate_time_period
foreach
facts_cf.coordinate($coordinate)
check is_time_period(engine, $coordinate)
assert
facts_cf.provides(coordinate, time_period, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger for each label() case specific fact.
#
# Purpose:
# Add the label coordinate to the cube.
#
fc_build_label_coordinate
foreach
facts_cf.label($coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.labels[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordinate() case specific fact
# has been asserted that contains units that are a time reference or an
# axis of time.
#
# Purpose:
# Add the time reference auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_time
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_time(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordinate() case specific fact
# has been asserted that contains units of time, but is not a time reference.
#
# Purpose:
# Add the time period auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_time_period
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_time_period(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordinate() case specific fact
# has been asserted that refers to non-rotated pole latitude data.
#
# Purpose:
# Add the latitude auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_latitude
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_latitude(engine, $coordinate)
check not is_rotated_latitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LAT)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordiante() case specific fact
# has been asserted that refers to rotated pole latitude data.
#
# Purpose:
# Add the rotated pole latitude auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_latitude_rotated
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_latitude(engine, $coordinate)
check is_rotated_latitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_GRID_LAT)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordinate() case specific fact
# has been asserted that refers to non-rotated pole longitude data.
#
# Purpose:
# Add the longitude auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_longitude
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_longitude(engine, $coordinate)
check not is_rotated_longitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LON)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff an auxiliary_coordinate() case specific fact
# has been asserted that refers to rotated pole longitude data.
#
# Purpose:
# Add the rotated pole auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate_longitude_rotated
foreach
facts_cf.auxiliary_coordinate($coordinate)
check is_longitude(engine, $coordinate)
check is_rotated_longitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_GRID_LON)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger for each auxiliary_coordinate() case specific fact
# that is not a spatio-temporal related auxiliary coordinate.
#
# Purpose:
# Add the auxiliary coordinate to the cube.
#
fc_build_auxiliary_coordinate
foreach
facts_cf.auxiliary_coordinate($coordinate)
check not is_time(engine, $coordinate)
check not is_time_period(engine, $coordinate)
check not is_latitude(engine, $coordinate)
check not is_longitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.auxiliary_coordinates[$coordinate]
python build_auxiliary_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger for each cell_measure case specific fact.
#
# Purpose:
# Add the cell measures attribute to the cube.
#
fc_build_cell_measure
foreach
facts_cf.cell_measure($coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.cell_measures[$coordinate]
python build_cell_measures(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF latitude coordinate exists and
# a lat/lon coordinate system exists.
#
# Purpose:
# Add the latitude coordinate into the cube.
#
fc_build_coordinate_latitude
foreach
facts_cf.provides(coordinate, latitude, $coordinate)
facts_cf.provides(coordinate_system, latitude_longitude)
check not is_rotated_latitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LAT,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF rotated latitude coordinate exists and
# a rotated lat/lon coordinate system exists.
#
# Purpose:
# Add the rotated latitude coordinate into the cube.
#
fc_build_coordinate_latitude_rotated
foreach
facts_cf.provides(coordinate, latitude, $coordinate)
facts_cf.provides(coordinate_system, rotated_latitude_longitude)
check is_rotated_latitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_GRID_LAT,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF longitude coordinate exists and
# a lat/lon coordinate system exists.
#
# Purpose:
# Add the longitude coordinate into the cube.
#
fc_build_coordinate_longitude
foreach
facts_cf.provides(coordinate, longitude, $coordinate)
facts_cf.provides(coordinate_system, latitude_longitude)
check not is_rotated_longitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LON,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF rotated longitude coordinate exists and
# a rotated lat/lon coordinate system exists.
#
# Purpose:
# Add the rotated longitude coordinate into the cube.
#
fc_build_coordinate_longitude_rotated
foreach
facts_cf.provides(coordinate, longitude, $coordinate)
facts_cf.provides(coordinate_system, rotated_latitude_longitude)
check is_rotated_longitude(engine, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_GRID_LON,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF latitude coordinate exists and
# no coordinate system exists.
#
# Purpose:
# Add the latitude coordinate into the cube.
#
fc_build_coordinate_latitude_nocs
foreach
facts_cf.provides(coordinate, latitude, $coordinate)
notany
facts_cf.provides(coordinate_system, latitude_longitude)
notany
facts_cf.provides(coordinate_system, rotated_latitude_longitude)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LAT,
coord_system=None)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF longitude coordinate exists and
# no lat/lon coordinate system exists.
#
# Purpose:
# Add the longitude coordinate into the cube.
#
fc_build_coordinate_longitude_nocs
foreach
facts_cf.provides(coordinate, longitude, $coordinate)
notany
facts_cf.provides(coordinate_system, latitude_longitude)
notany
facts_cf.provides(coordinate_system, rotated_latitude_longitude)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_LON,
coord_system=None)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_x_coordinate coordinate exists and
# a transverse Mercator coordinate system exists.
#
# Purpose:
# Add the projection_x_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_x_transverse_mercator
foreach
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
facts_cf.provides(coordinate_system, transverse_mercator)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_X,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_y_coordinate coordinate exists and
# a transverse Mercator coordinate system exists.
#
# Purpose:
# Add the projection_y_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_y_transverse_mercator
foreach
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
facts_cf.provides(coordinate_system, transverse_mercator)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_Y,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_x_coordinate coordinate exists and
# a Lambert conformal coordinate system exists.
#
# Purpose:
# Add the projection_x_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_x_lambert_conformal
foreach
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
facts_cf.provides(coordinate_system, lambert_conformal)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_X,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_y_coordinate coordinate exists and
# a Lambert conformal coordinate system exists.
#
# Purpose:
# Add the projection_y_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_y_lambert_conformal
foreach
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
facts_cf.provides(coordinate_system, lambert_conformal)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_Y,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_x_coordinate coordinate exists and
# a Mercator coordinate system exists.
#
# Purpose:
# Add the projection_x_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_x_mercator
foreach
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
facts_cf.provides(coordinate_system, mercator)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_X,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_y_coordinate coordinate exists and
# a Mercator coordinate system exists.
#
# Purpose:
# Add the projection_y_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_y_mercator
foreach
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
facts_cf.provides(coordinate_system, mercator)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_Y,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_x_coordinate coordinate exists and
# a sterographic coordinate system exists.
#
# Purpose:
# Add the projection_x_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_x_stereographic
foreach
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
facts_cf.provides(coordinate_system, stereographic)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_X,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_y_coordinate coordinate exists and
# a stereographic coordinate system exists.
#
# Purpose:
# Add the projection_y_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_y_stereographic
foreach
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
facts_cf.provides(coordinate_system, stereographic)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_Y,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_x_coordinate coordinate exists and
# a lambert azimuthal equal area coordinate system exists.
#
# Purpose:
# Add the projection_x_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_x_lambert_azimuthal_equal_area
foreach
facts_cf.provides(coordinate, projection_x_coordinate, $coordinate)
facts_cf.provides(coordinate_system, lambert_azimuthal_equal_area)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_X,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a projection_y_coordinate coordinate exists and
# a lambert azimuthal equal area coordinate system exists.
#
# Purpose:
# Add the projection_y_coordinate coordinate into the cube.
#
fc_build_coordinate_projection_y_lambert_azimuthal_equal_area
foreach
facts_cf.provides(coordinate, projection_y_coordinate, $coordinate)
facts_cf.provides(coordinate_system, lambert_azimuthal_equal_area)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var,
coord_name=CF_VALUE_STD_NAME_PROJ_Y,
coord_system=engine.provides['coordinate_system'])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a CF time coordinate exists.
#
# Purpose:
# Add the time coordinate into the cube.
#
fc_build_coordinate_time
foreach
facts_cf.provides(coordinate, time, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a time period coordinate exists.
#
# Purpose:
# Add the time period coordinate to the cube.
#
fc_build_coordinate_time_period
foreach
facts_cf.provides(coordinate, time_period, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff there exists an "unclassifed" coordinate.
# i.e. a coordinate that is not a latitude, longitude, time or vertical coordinate.
#
# Purpose:
# Add the miscellaneous coordinate into the cube.
#
fc_default_coordinate
foreach
facts_cf.coordinate($coordinate)
notany
facts_cf.provides(coordinate, $_, $coordinate)
assert
python cf_coord_var = engine.cf_var.cf_group.coordinates[$coordinate]
python build_dimension_coordinate(engine, cf_coord_var)
facts_cf.provides(coordinate, miscellaneous, $coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff the "um_stash_source" or "ukmo__um_stash_source" attributes exist
# on the CF-netCDF data variable.
#
# Purpose:
# Add the CF-netCDF data variable "um_stash_source" attribute to the
# cube attributes dictionary as a "STASH" key.
#
fc_attribute_ukmo__um_stash_source
foreach
check hasattr(engine.cf_var, 'ukmo__um_stash_source') or hasattr(engine.cf_var, 'um_stash_source')
assert
python attr_value = getattr(engine.cf_var, 'um_stash_source', None) or getattr(engine.cf_var, 'ukmo__um_stash_source')
python engine.cube.attributes['STASH'] = pp.STASH.from_msi(attr_value)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff the "ukmo__process_flags" attribute exists
# on the CF-netCDF data variable.
#
# Purpose:
# Add the CF-netCDF data variable "ukmo__process_flags" attribute to the
# cube attributes dictionary as a "ukmo__process_flags" key.
#
fc_attribute_ukmo__process_flags
foreach
check hasattr(engine.cf_var, 'ukmo__process_flags')
assert
python attr_value = engine.cf_var.ukmo__process_flags
python engine.cube.attributes['ukmo__process_flags'] = tuple([x.replace("_", " ") for x in attr_value.split(" ")])
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a formula term that refers to a
# dimensionless vertical coordinate of hybrid height.
#
# Purpose:
# Assert that the formula term refers to hybrid height.
#
fc_formula_type_atmosphere_hybrid_height_coordinate
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'atmosphere_hybrid_height_coordinate'
assert
python engine.requires['formula_type'] = 'atmosphere_hybrid_height_coordinate'
facts_cf.formula_type(atmosphere_hybrid_height_coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a formula term that refers to a
# dimensionless vertical coordinate of hybrid pressure.
#
# Purpose:
# Assert that the formula term refers to hybrid pressure.
#
fc_formula_type_atmosphere_hybrid_sigma_pressure_coordinate
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'atmosphere_hybrid_sigma_pressure_coordinate'
assert
python engine.requires['formula_type'] = 'atmosphere_hybrid_sigma_pressure_coordinate'
facts_cf.formula_type(atmosphere_hybrid_height_coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger iff a formula term that refers to a
# dimensionless vertical coordinate of ocean sigma over z
#
# Purpose:
# Assert that the formula term refers to ocean sigma over z.
#
fc_formula_type_ocean_sigma_z_coordinate
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'ocean_sigma_z_coordinate'
assert
python engine.requires['formula_type'] = 'ocean_sigma_z_coordinate'
facts_cf.formula_type(ocean_sigma_z_coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger if a formula term that refers to a
# dimensionless vertical coordinate of ocean sigma
#
# Purpose:
# Assert that the formula term refers to ocean sigma
#
fc_formula_type_ocean_sigma_coordinate
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'ocean_sigma_coordinate'
assert
python engine.requires['formula_type'] = 'ocean_sigma_coordinate'
facts_cf.formula_type(ocean_sigma_coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger if a formula term that refers to a
# dimensionless vertical coordinate of ocean s coordinate
#
# Purpose:
# Assert that the formula term refers to ocean sigma
#
fc_formula_type_ocean_s_coordinate
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'ocean_s_coordinate'
assert
python engine.requires['formula_type'] = 'ocean_s_coordinate'
facts_cf.formula_type(ocean_s_coordinate)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger if a formula term that refers to a
# dimensionless vertical coordinate of Ocean s-coordinate g1
#
# Purpose:
# Assert that the formula term refers to Ocean s-coordinate g1
#
fc_formula_type_ocean_s_coordinate_g1
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'ocean_s_coordinate_g1'
assert
python engine.requires['formula_type'] = 'ocean_s_coordinate_g1'
facts_cf.formula_type(ocean_s_coordinate_g1)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger if a formula term that refers to a
# dimensionless vertical coordinate of Ocean s-coordinate g2
#
# Purpose:
# Assert that the formula term refers to Ocean s-coordinate g2
#
fc_formula_type_ocean_s_coordinate_g2
foreach
facts_cf.formula_root($coordinate)
check getattr(engine.cf_var.cf_group[$coordinate], 'standard_name') == 'ocean_s_coordinate_g2'
assert
python engine.requires['formula_type'] = 'ocean_s_coordinate_g2'
facts_cf.formula_type(ocean_s_coordinate_g2)
python engine.rule_triggered.add(rule.name)
#
# Context:
# This rule will trigger for variables referenced by a dimensionless
# vertical coordinate.
#
# Purpose:
# Build a mapping from term name to netCDF variable name.
#
fc_formula_terms
foreach
facts_cf.formula_root($coordinate)
facts_cf.formula_term($var_name, $coordinate, $term)
assert
python engine.requires.setdefault('formula_terms', {})[$term] = $var_name
python engine.rule_triggered.add(rule.name)
fc_extras