Example #1
0
class BathymetryDepthExpression(Expression):
  def __init__(self, filename):
    self.nci = NetCDFInterpolator(filename, ('lat', 'lon'), ('lat', 'lon'))
    self.nci.set_field("z")

  def eval(self, values, x):
    latlon = utm.to_latlon(x[0], x[1], utm_zone, utm_band)
    values[0] = max(10, -self.nci.get_val(latlon))
Example #2
0
class BathymetryDepthExpression(Expression):
    def __init__(self, filename):
        self.nci = NetCDFInterpolator(filename, ('lat', 'lon'), ('lat', 'lon'))
        self.nci.set_field("z")

    def eval(self, values, x):
        latlon = utm.to_latlon(x[0], x[1], utm_zone, utm_band)
        values[0] = max(10, -self.nci.get_val(latlon))
    def _test_permutation(self, perm, coordinate_perm):
        # load the netcdf created in setup()
        if coordinate_perm == (0, 1):
            nci = NetCDFInterpolator(test_file_name1, ('lat', 'lon'),
                                     ('latitude', 'longitude'))
        else:
            nci = NetCDFInterpolator(test_file_name1, ('lon', 'lat'),
                                     ('longitude', 'latitude'))
        # call the methods in the order given by perm
        for x in perm:
            if x == 'field':
                nci.set_field('z')
            elif x == 'mask':
                nci.set_mask('mask')
            elif x == 'transposed_mask':
                nci.set_mask('transposed_mask')
            elif x == 'mask_from_fill_value':
                nci.set_mask_from_fill_value('mask', 0.0)
            elif x == 'ranges':
                if coordinate_perm == (0, 1):
                    nci.set_ranges(((0., 4.), (2., 8.)))
                else:
                    nci.set_ranges(((2., 8.), (0., 4.)))
            else:
                raise Exception("Unknown method")

        # now perform all tests
        if 'field' in perm:
            # if 'field' is not in perm we only test reading the field from nci2
            self._test_prepared_nci(nci, perm, coordinate_perm)

        # now try the same for the case where the field values are stored in a separate file
        nci2 = NetCDFInterpolator(test_file_name2, nci)
        nci2.set_field('z')
        self._test_prepared_nci(nci2, perm, coordinate_perm)
Example #4
0
 def __init__(self, filename):
   self.nci = NetCDFInterpolator(filename, ('lat', 'lon'), ('lat', 'lon'))
   self.nci.set_field("z")
    def _test_permutation(self, perm, coordinate_perm):
        # load the netcdf created in setup()
        if coordinate_perm == (0, 1):
            nci = NetCDFInterpolator(test_file_name1, ('lat', 'lon'), ('latitude', 'longitude'))
        else:
            nci = NetCDFInterpolator(test_file_name1, ('lon', 'lat'), ('longitude', 'latitude'))
        # call the methods in the order given by perm
        for x in perm:
            if x == 'field':
                nci.set_field('z')
            elif x == 'mask':
                nci.set_mask('mask')
            elif x == 'transposed_mask':
                nci.set_mask('transposed_mask')
            elif x == 'mask_from_fill_value':
                nci.set_mask_from_fill_value('mask', 0.0)
            elif x == 'ranges':
                if coordinate_perm == (0, 1):
                    nci.set_ranges(((0., 4.), (2., 8.)))
                else:
                    nci.set_ranges(((2., 8.), (0., 4.)))
            else:
                raise Exception("Unknown method")

        # now perform all tests
        if 'field' in perm:
            # if 'field' is not in perm we only test reading the field from nci2
            self._test_prepared_nci(nci, perm, coordinate_perm)

        # now try the same for the case where the field values are stored in a separate file
        nci2 = NetCDFInterpolator(test_file_name2, nci)
        nci2.set_field('z')
        self._test_prepared_nci(nci2, perm, coordinate_perm)
Example #6
0
 def __init__(self, filename):
     self.nci = NetCDFInterpolator(filename, ("lat", "lon"), ("lat", "lon"))
     self.nci.set_field("z")
Example #7
0
 def __init__(self, filename):
     self.nci = NetCDFInterpolator(filename, ('lat', 'lon'), ('lat', 'lon'))
     self.nci.set_field("z")