def verify_convention_version(self, ds): """ Verify that the version in the Conventions field is correct """ try: for convention in ( getattr(ds, "Conventions", "").replace(" ", "").split(",") ): if convention == "ACDD-" + self._cc_spec_version: return ratable_result( (2, 2), None, [] ) # name=None so grouped with Globals # if no/wrong ACDD convention, return appropriate result # Result will have name "Global Attributes" to group with globals m = ["Conventions does not contain 'ACDD-{}'".format(self._cc_spec_version)] return ratable_result((1, 2), "Global Attributes", m) except AttributeError: # NetCDF attribute not found m = [ "No Conventions attribute present; must contain ACDD-{}".format( self._cc_spec_version ) ] # Result will have name "Global Attributes" to group with globals return ratable_result((0, 2), "Global Attributes", m)
def verify_geospatial_bounds(self, ds): """Checks that the geospatial bounds is well formed OGC WKT""" var = getattr(ds, "geospatial_bounds", None) check = var is not None if not check: return ratable_result( False, "Global Attributes", # grouped with Globals ["geospatial_bounds not present"], ) try: # TODO: verify that WKT is valid given CRS (defaults to EPSG:4326 # in ACDD. from_wkt(ds.geospatial_bounds) except AttributeError: return ratable_result( False, "Global Attributes", # grouped with Globals [ ( "Could not parse WKT from geospatial_bounds," ' possible bad value: "{}"'.format(ds.geospatial_bounds) ) ], variable_name="geospatial_bounds", ) # parsed OK else: return ratable_result(True, "Global Attributes", tuple())
def _check_attr_is_iso_date(attr, ds): result_name = "{}_is_iso".format(attr) if not hasattr(ds, attr): return ratable_result((0, 2), result_name, ["Attr {} is not present".format(attr)]) else: iso_check, msgs = datetime_is_iso(getattr(ds, attr)) return ratable_result((1 + iso_check, 2), result_name, msgs)
def _check_attr_is_iso_date(attr, ds): result_name = "{}_is_iso".format(attr) if not hasattr(ds, attr): return ratable_result((0,2), result_name, ["Attr {} is not present".format(attr)]) else: iso_check, msgs = datetime_is_iso(getattr(ds, attr)) return ratable_result((1 + iso_check, 2), result_name, msgs)
def verify_dummy(ds): """Sample function that will be called when passed into attr_check""" try: if ds.dummy + "y" == "dummyy": return base.ratable_result(True, "dummy", []) else: return base.ratable_result(False, "dummy", [ds.dummy + "y"]) except AttributeError: return base.ratable_result(False, "dummy", [])
def verify_convention_version(self, ds): """ Verify that the version in the Conventions field is correct """ for convention in ds.Conventions.replace(' ', '').split(','): if convention == 'ACDD-' + self._cc_spec_version: return ratable_result((2, 2), 'Conventions', []) # Conventions attribute is present, but does not include # proper ACDD version return ratable_result((1, 2), 'Conventions', [ "Attr Conventions does not contain 'ACDD-{}'".format( self._cc_spec_version) ])
def verify_convention_version(self, ds): """ Verify that the version in the Conventions field is correct """ for convention in ds.Conventions.replace(' ','').split(','): if convention == 'ACDD-' + self._cc_spec_version: return ratable_result( (2,2), 'Conventions', []) # Conventions attribute is present, but does not include # proper ACDD version return ratable_result( (1,2), 'Conventions', ["Attr Conventions does not contain 'ACDD-{}'".format( self._cc_spec_version)])
def verify_convention_version(self, ds): """ Verify that the version in the Conventions field is correct """ try: for convention in getattr(ds, "Conventions", '').replace(' ', '').split(','): if convention == 'ACDD-' + self._cc_spec_version: return ratable_result((2, 2), None, []) # name=None so grouped with Globals # if no/wrong ACDD convention, return appropriate result # Result will have name "Global Attributes" to group with globals m = ["Conventions does not contain 'ACDD-{}'".format(self._cc_spec_version)] return ratable_result((1, 2), "Global Attributes", m) except AttributeError: # NetCDF attribute not found m = ["No Conventions attribute present; must contain ACDD-{}".format(self._cc_spec_version)] # Result will have name "Global Attributes" to group with globals return ratable_result((0, 2), "Global Attributes", m)
def verify_geospatial_bounds(self, ds): """Checks that the geospatial bounds is well formed OGC WKT""" var = getattr(ds, 'geospatial_bounds', None) check = var is not None if not check: return ratable_result(False, 'geospatial_bounds', ["Attr geospatial_bounds not present"]) try: # TODO: verify that WKT is valid given CRS (defaults to EPSG:4326 # in ACDD. from_wkt(ds.geospatial_bounds) except AttributeError: return ratable_result( False, 'geospatial_bounds', ['Could not parse WKT, possible bad value for WKT']) # parsed OK else: return ratable_result(True, 'geospatial_bounds', tuple())
def verify_geospatial_bounds(self, ds): """Checks that the geospatial bounds is well formed OGC WKT""" var = getattr(ds, 'geospatial_bounds', None) check = var is not None if not check: return ratable_result(False, "Global Attributes", # grouped with Globals ["geospatial_bounds not present"]) try: # TODO: verify that WKT is valid given CRS (defaults to EPSG:4326 # in ACDD. from_wkt(ds.geospatial_bounds) except AttributeError: return ratable_result(False, "Global Attributes", # grouped with Globals ['Could not parse WKT, possible bad value for WKT']) # parsed OK else: return ratable_result(True, "Global Attributes", tuple())
def verify_dummy(ds): if ds.dummy + 'y' == 'dummyy': return base.ratable_result(True, 'dummy', []) else: return base.ratable_result(False, 'dummy', ['not "dummyy"'])