...
Fieldsets work much the same as they do in the Macro language, but watch out for these things:
- length of a fieldset can be found with the
lenfunction:num_fields = len(my_fieldset) - indexing starts at 0:
first_field = my_fieldset[0] - comparison operators work the same, i.e. they return a fieldset of 1s and 0s:
smaller = fs1 < fs2 - slicing works:
my_fields = fs[0:6:2] - you can pass a numpy array of indexes:
my_fields = fs[np.array([1.0, 2.0, 0.0, 5.0])] - comparison operators work the same as in Macro, i.e. they return a fieldset of 1s and 0s:
smaller = fs1 < fs2 - equality equality and non-equality operators are
==and!= - Fieldsets can be directly constructed either as empty, or with a path to a GRIB file:
f = mv.Fieldset()f = mv.Fieldset(path='test.grib')
- concatenation can be done like this:
my_fieldset.append(my_other_fieldset) - length of a fieldset can be found with the
lenfunction:num_fields = len(my_fieldset) - slicing works:
my_fields = fs[0:6:2] ='test.grib')
- concatenation can be done like this:
my_fieldset.append(my_other_fieldset)you can pass a numpy array of indexes:my_fields = fs[np.array([1.0, 2.0, 0.0, 5.0])] - iteration works:
for f in my_fieldset: #do something
...