def _assert_doc_hierarchy_level(doc, is_update):
    """Assert hierarchy level information."""
    tu.assert_object(doc.hierarchy_level, cim.v1.DataHierarchyLevel)
    h = doc.hierarchy_level
    tu.assert_bool(h.is_open, True)
    tu.assert_str(h.name, "experiment")
    tu.assert_str(h.value, "HADGEM2_20C3M_1_D0_hus700")
示例#2
0
def _assert_doc_content(doc, is_update):
    """Assert content information."""
    tu.assert_iter(doc.content, 1, cim.v1.DataContent)
    c = doc.content[0]
    tu.assert_object(c.topic, cim.v1.DataTopic)
    tu.assert_str(c.topic.description, "missing CF name: tendency_of", True)
    tu.assert_str(c.topic.name, "fossil_fuel_organic_carbon")
示例#3
0
def _test(mod):
    """Performs standard document extensions tests,"""
    doc = tu.get_doc(mod)    # Note - returns an extended document
    tu.assert_object(doc.ext)
    tu.assert_str(doc.type_key, doc.meta.type)
    tu.assert_str(doc.type_key, doc.ext.type)
    if hasattr(mod, "assert_doc_extensions"):
        mod.assert_doc_extensions(doc)
def _assert_doc_core(doc, is_update):
    """Assert core information."""
    tu.assert_iter(doc.reports, 1)
    r = doc.reports[0]
    tu.assert_date(r.date, '2011-05-01 12:00:00')
    tu.assert_object(r.evaluator, cim.v1.ResponsibleParty)
    tu.assert_str(r.evaluator.individual_name, '*****@*****.**')
    tu.assert_str(r.evaluator.role, 'pointofContact')
def _assert_doc_tile_zcoords(doc, is_update):
    """Assert tile zcoords information."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.zcoords, cim.v1.VerticalCoordinateList)
    z = t.zcoords
    tu.assert_str(z.form, "hybrid height")
    tu.assert_str(z.type, "hybrid")
    tu.assert_iter(z.properties, 1, cim.v1.GridProperty)
def _do_test(encoding):
    """Executes a serialization test."""
    for desc in (_get_description(t) for t in (str, unicode)):
        _MODEL.description = desc
        representation = pyesdoc.encode(_MODEL, encoding)
        tu.assert_object(representation, str)
        as_doc = pyesdoc.decode(representation, encoding)
        tu.assert_object(as_doc, cim.v1.ModelComponent)
示例#7
0
def _test(mod):
    """Performs standard document extensions tests,"""
    doc = tu.get_doc(mod)  # Note - returns an extended document
    tu.assert_object(doc.ext)
    tu.assert_str(doc.type_key, doc.meta.type)
    tu.assert_str(doc.type_key, doc.ext.type)
    if hasattr(mod, "assert_doc_extensions"):
        mod.assert_doc_extensions(doc)
def _do_test(encoding):
    """Executes a serialization test."""
    for desc in (_get_description(t) for t in (str, unicode)):
        _MODEL.description = desc
        representation = pyesdoc.encode(_MODEL, encoding)
        tu.assert_object(representation, str)
        as_doc = pyesdoc.decode(representation, encoding)
        tu.assert_object(as_doc, cim.v1.ModelComponent)
def _assert_doc_report_measure(doc, is_update):
    """Assert report measure information."""
    r = doc.reports[0]
    tu.assert_object(r.measure, cim.v1.Measure)
    m = r.measure
    tu.assert_str(m.description, 'WDCC Conformance', True)
    tu.assert_str(m.identification, 'cmip5-qc-2d')
    tu.assert_str(m.name, 'CMIP5 Quality Control Data Level 2')
def _assert_doc_tile_zcoords(doc, is_update):
    """Assert tile zcoords information."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.zcoords, cim.v1.VerticalCoordinateList)
    z = t.zcoords
    tu.assert_str(z.form, "hybrid height")
    tu.assert_str(z.type, "hybrid")
    tu.assert_iter(z.properties, 1, cim.v1.GridProperty)
def _assert_doc_tile_extent(doc, is_update):
    """Assert tile extent information."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.extent, cim.v1.GridExtent)
    e = t.extent
    tu.assert_int(e.maximum_latitude, 90)
    tu.assert_int(e.minimum_latitude, -90)
    tu.assert_int(e.minimum_longitude, 0)
    tu.assert_int(e.maximum_longitude, 360, int)
def _assert_doc_tile_vertical_resolution(doc, is_update):
    """Assert tile vertical resolution."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.vertical_resolution, cim.v1.GridTileResolutionType)
    vr = t.vertical_resolution
    tu.assert_iter(vr.properties, 4, cim.v1.GridProperty)
    p = vr.properties[0]
    tu.assert_str(p.name, "TopModelLevel")
    tu.assert_str(p.value, "39254.8")
def _assert_doc_tile_extent(doc, is_update):
    """Assert tile extent information."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.extent, cim.v1.GridExtent)
    e = t.extent
    tu.assert_int(e.maximum_latitude, 90)
    tu.assert_int(e.minimum_latitude, -90)
    tu.assert_int(e.minimum_longitude, 0)
    tu.assert_int(e.maximum_longitude, 360, int)
示例#14
0
def _assert_doc(doc, typeof=None):
    """Perform standard test document assertions."""
    tu.assert_object(doc, typeof)
    if hasattr(doc, 'meta'):
        tu.assert_str(doc.meta.institute, _INSTITUTE.lower())
        tu.assert_str(doc.meta.project, _PROJECT.lower())
        tu.assert_str(doc.meta.source, pyesdoc.DEFAULT_SOURCE)
        if typeof is not None:
            tu.assert_str(doc.meta.type, typeof.type_key)
def _assert_doc_tile_vertical_resolution(doc, is_update):
    """Assert tile vertical resolution."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.vertical_resolution, cim.v1.GridTileResolutionType)
    vr = t.vertical_resolution
    tu.assert_iter(vr.properties, 4, cim.v1.GridProperty)
    p = vr.properties[0]
    tu.assert_str(p.name, "TopModelLevel")
    tu.assert_str(p.value, "39254.8")
def _assert_doc_core(doc, is_update):
    """Assert core information."""
    tu.assert_str(doc.acronym, "fossil_fuel_organic_carbon")
    tu.assert_str(doc.data_status, "complete")
    tu.assert_str(doc.description, "2D gridded monthly-mean", True)
    tu.assert_iter(doc.storage, 1)
    storage = doc.storage[0]
    tu.assert_object(storage, cim.v1.DataStorageIp)
    tu.assert_str(storage.format, "ASCII")
    tu.assert_str(storage.file_name, "emissions of organic", True)
示例#17
0
def _assert_doc(doc, typeof=None):
    """Perform standard test document assertions."""
    tu.assert_object(doc, typeof)
    if hasattr(doc, 'meta'):
        tu.assert_str(doc.meta.institute, _INSTITUTE.lower())
        tu.assert_str(doc.meta.language, pyesdoc.ESDOC_DEFAULT_LANGUAGE)
        tu.assert_str(doc.meta.project, _PROJECT.lower())
        tu.assert_str(doc.meta.source, _INSTITUTE.lower())
        if typeof is not None:
            tu.assert_str(doc.meta.type, typeof.type_key)
示例#18
0
def _assert_doc(doc, typeof=None):
    """Perform standard test document assertions."""
    tu.assert_object(doc, typeof)
    if hasattr(doc, "meta"):
        tu.assert_str(doc.meta.institute, _INSTITUTE.lower())
        tu.assert_str(doc.meta.language, pyesdoc.ESDOC_DEFAULT_LANGUAGE)
        tu.assert_str(doc.meta.project, _PROJECT.lower())
        tu.assert_str(doc.meta.source, _INSTITUTE.lower())
        if typeof is not None:
            tu.assert_str(doc.meta.type, typeof.type_key)
def _assert_doc_tile_horizontal_resolution(doc, is_update):
    """Assert tile horizontal resolution."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.horizontal_resolution, cim.v1.GridTileResolutionType)
    hr = t.horizontal_resolution
    tu.assert_str(hr.description, "1.875 degrees in longitude", True)
    tu.assert_iter(hr.properties, 2, cim.v1.GridProperty)
    p = hr.properties[0]
    tu.assert_str(p.name, "NumberOfLatitudinalGridCells")
    tu.assert_str(p.value, "145")
def _assert_doc_tile(doc, is_update):
    """Assert tile information."""
    g = doc.esm_model_grids[0]
    tu.assert_int(g.tile_count, 1)
    tu.assert_iter(g.tiles, 1, cim.v1.GridTile)
    tu.assert_object(g.tiles[0], cim.v1.GridTile)
    t = g.tiles[0]
    tu.assert_str(t.description, "Horizontal properties: The N96", True)
    tu.assert_str(t.discretization_type, "logically_rectangular")
    tu.assert_str(t.mnemonic, "N96")
def _assert_doc_tile(doc, is_update):
    """Assert tile information."""
    g = doc.esm_model_grids[0]
    tu.assert_int(g.tile_count, 1)
    tu.assert_iter(g.tiles, 1, cim.v1.GridTile)
    tu.assert_object(g.tiles[0], cim.v1.GridTile)
    t = g.tiles[0]
    tu.assert_str(t.description, "Horizontal properties: The N96", True)
    tu.assert_str(t.discretization_type, "logically_rectangular")
    tu.assert_str(t.mnemonic, "N96")
def _assert_doc_tile_horizontal_resolution(doc, is_update):
    """Assert tile horizontal resolution."""
    t = doc.esm_model_grids[0].tiles[0]
    tu.assert_object(t.horizontal_resolution, cim.v1.GridTileResolutionType)
    hr = t.horizontal_resolution
    tu.assert_str(hr.description, "1.875 degrees in longitude", True)
    tu.assert_iter(hr.properties, 2, cim.v1.GridProperty)
    p = hr.properties[0]
    tu.assert_str(p.name, "NumberOfLatitudinalGridCells")
    tu.assert_str(p.value, "145")
def _assert_doc_report_evaluation(doc, is_update):
    """Assert report evaluation information."""
    r = doc.reports[0]
    tu.assert_object(r.evaluation, cim.v1.Evaluation)
    e = r.evaluation
    tu.assert_date(e.date, '2012-11-05')
    tu.assert_str(e.description, 'evaluationMethodType=indirect', True)
    tu.assert_str(e.explanation, 'The quality results for this ESG', True)
    tu.assert_str(e.specification, 'The CMIP5/AR5 Model Data Quality Control')
    tu.assert_str(e.specification_hyperlink, 'http://cmip5qc.wdc-climate.de')
    tu.assert_str(e.type, 'QC Level 2 Results')
    tu.assert_str(e.type_hyperlink, 'http://cera-www.dkrz.de/WDCC/CMIP5/QCResult.jsp?experiment=cmip5/output1/NCC/NorESM1-ME/rcp45')
def _assert_doc_deployments(doc, is_update):
    """Assert simulation deployments."""
    tu.assert_iter(doc.deployments, 1, cim.v1.Deployment)

    dep = doc.deployments[0]
    tu.assert_str(dep.description, "The resources(deployment) on which", True)
    tu.assert_object(dep.platform_reference, cim.v1.DocReference)
    ref = dep.platform_reference
    tu.assert_str(ref.description, "Reference to a platform", True)
    tu.assert_uuid(ref.id, "b765775a-e2ac-11df-9efb-00163e9152a5")
    tu.assert_str(ref.name, "IBM Power 6")
    tu.assert_str(ref.type, "platform")
    tu.assert_int(ref.version, 1)
def _assert_doc_deployments(doc, is_update):
    """Assert simulation deployments."""
    tu.assert_iter(doc.deployments, 1, cim.v1.Deployment)

    dep = doc.deployments[0]
    tu.assert_str(dep.description, "The resources(deployment) on which", True)
    tu.assert_object(dep.platform_reference, cim.v1.DocReference)
    ref = dep.platform_reference
    tu.assert_str(ref.description, "Reference to a platform", True)
    tu.assert_uuid(ref.id, "b765775a-e2ac-11df-9efb-00163e9152a5")
    tu.assert_str(ref.name, "IBM Power 6")
    tu.assert_str(ref.type, "platform")
    tu.assert_int(ref.version, 1)
def _assert_doc_machine(doc, is_update):
    """Assert machine information."""
    tu.assert_object(doc.units[0].machine, cim.v1.Machine)
    m = doc.units[0].machine
    tu.assert_int(m.cores_per_processor, 32)
    tu.assert_str(m.interconnect, "Infiniband")
    tu.assert_str(m.name, "IBM Power 6")
    tu.assert_iter(m.libraries, 0)
    tu.assert_int(m.maximum_processors, 2)
    tu.assert_str(m.operating_system, "AIX")
    tu.assert_str(m.system, "Parallel")
    tu.assert_str(m.vendor, "IBM")
    tu.assert_str(m.processor_type, "Other")
def _assert_doc_machine(doc, is_update):
    """Assert machine information."""
    tu.assert_object(doc.units[0].machine, cim.v1.Machine)
    m = doc.units[0].machine
    tu.assert_int(m.cores_per_processor, 32)
    tu.assert_str(m.interconnect, "Infiniband")
    tu.assert_str(m.name, "IBM Power 6")
    tu.assert_iter(m.libraries, 0)
    tu.assert_int(m.maximum_processors, 2)
    tu.assert_str(m.operating_system, "AIX")
    tu.assert_str(m.system, "Parallel")
    tu.assert_str(m.vendor, "IBM")
    tu.assert_str(m.processor_type, "Other")
def _assert_doc_core(doc, is_update):
    """Assert core information."""
    tu.assert_str(doc.authors, "C. Jones, J. Hughes", True)
    tu.assert_object(doc.date_range, cim.v1.ClosedDateRange)
    tu.assert_str(doc.date_range.duration, "P30Y")
    tu.assert_date(doc.date_range.start, "1978-12-01 00:00:00+00:00")
    tu.assert_str(doc.description, "Main amip ensemble simulations", True)
    tu.assert_str(doc.long_name, "3.3 AMIP and AMIP Ensemble", True)
    tu.assert_iter(doc.projects, 1, str)
    tu.assert_iter(doc.projects[0], "CMIP5")
    tu.assert_iter(doc.responsible_parties, 4, cim.v1.ResponsibleParty)
    tu.assert_str(doc.short_name, "amip")
    tu.assert_object(doc.spinup_date_range, cim.v1.ClosedDateRange)
    tu.assert_str(doc.spinup_date_range.duration, "P30Y")
    tu.assert_date(doc.spinup_date_range.start, "1978-12-01 00:00:00+00:00")
def _assert_doc_core(doc, is_update):
    """Assert core information."""
    tu.assert_str(doc.authors, "C. Jones, J. Hughes", True)
    tu.assert_object(doc.date_range, cim.v1.ClosedDateRange)
    tu.assert_str(doc.date_range.duration, "P30Y")
    tu.assert_date(doc.date_range.start, "1978-12-01 00:00:00+00:00")
    tu.assert_str(doc.description, "Main amip ensemble simulations", True)
    tu.assert_str(doc.long_name, "3.3 AMIP and AMIP Ensemble", True)
    tu.assert_iter(doc.projects, 1, str)
    tu.assert_str(doc.projects[0], "CMIP5")
    tu.assert_iter(doc.responsible_parties, 4, cim.v1.ResponsibleParty)
    tu.assert_str(doc.short_name, "amip")
    tu.assert_object(doc.spinup_date_range, cim.v1.ClosedDateRange)
    tu.assert_str(doc.spinup_date_range.duration, "P30Y")
    tu.assert_date(doc.spinup_date_range.start, "1978-12-01 00:00:00+00:00")
def _assert_doc_member(doc, is_update):
    """Assert ensemble members information."""
    # ... ensemble member id.
    member = doc.members[0]
    tu.assert_iter(member.ensemble_ids, 1, cim.v1.StandardName)
    tu.assert_str(member.ensemble_ids[0].is_open, True)
    tu.assert_str(member.ensemble_ids[0].value, "r1i1p1")

    # ... ensemble member simulation reference.
    tu.assert_object(member.simulation_reference, cim.v1.DocReference)
    ref = member.simulation_reference
    tu.assert_str(ref.description, "Reference to a simulation called amip")
    tu.assert_uuid(ref.id, "e4155a28-268e-11e1-9a0e-00163e9152a5")
    tu.assert_str(ref.name, "amip")
    tu.assert_str(ref.type, "simulation")
    tu.assert_str(ref.version, 2)
def _assert_doc_references(doc, is_update):
    """Assert simulation references."""
    # Model reference.
    tu.assert_object(doc.model_reference, cim.v1.DocReference)
    ref = doc.model_reference
    tu.assert_str(ref.description, "Reference to a modelComponent", True)
    tu.assert_uuid(ref.id, "7a2b64cc-03ca-11e1-a36a-00163e9152a5")
    tu.assert_str(ref.name, "HadGEM2-A")
    tu.assert_str(ref.type, "modelComponent")
    tu.assert_int(ref.version, 1)

    # Experiment reference.
    tu.assert_iter(doc.supports_references, 1, cim.v1.DocReference)
    ref = doc.supports_references[0]
    tu.assert_str(ref.description, "Reference to an Experiment", True)
    tu.assert_uuid(ref.id, "9fa513fc-d3a5-11df-837f-00163e9152a5")
    tu.assert_str(ref.name, "amip")
    tu.assert_str(ref.type, "experiment")
    tu.assert_int(ref.version, 1)
def _assert_doc_requirements(doc, is_update):
    """Assert experiment requirements."""
    tu.assert_iter(doc.requirements, 13, cim.v1.NumericalRequirement)

    # Initial condition.
    req = doc.requirements[0]
    tu.assert_object(req, cim.v1.InitialCondition)
    tu.assert_str(req.description, "Initial conditions are from", True)
    tu.assert_str(req.id, "ic.003")
    tu.assert_str(req.name, "3.3.ic")
    tu.assert_str(req.requirement_type, "initialCondition")

    # Boundary condition.
    req = doc.requirements[1]
    tu.assert_object(req, cim.v1.BoundaryCondition)
    tu.assert_str(req.requirement_type, "boundaryCondition")
    tu.assert_str(req.description, "Imposed changing concentrations", True)
    tu.assert_none(req.id)
    tu.assert_str(req.name, "3.3.bc.sls")

    # Boundary condition - options.
    tu.assert_iter(req.options, 2, cim.v1.NumericalRequirementOption)
    opt = req.options[0]
    tu.assert_str(opt.relationship, "XOR")
    tu.assert_object(opt.requirement, cim.v1.BoundaryCondition)
    # ... sub-requirement
    req = opt.requirement
    tu.assert_str(req.requirement_type, "boundaryCondition")
    tu.assert_str(req.description, "Concentrations")
    tu.assert_str(req.id, "bc.013")
    tu.assert_str(req.name, "3.3.bc.sls_conc")

    # Spatio Temporal Constraint.
    req = doc.requirements[12]
    tu.assert_object(req, cim.v1.SpatioTemporalConstraint)
    tu.assert_object(req.date_range, cim.v1.ClosedDateRange)
    tu.assert_str(req.date_range.duration, "P30Y")
    tu.assert_date(req.date_range.end, "2008-12-30 00:00:00+00:00")
    tu.assert_date(req.date_range.start, "1979-01-01 00:00:00+00:00")
    tu.assert_str(req.description, "Begin in 1979 and", True)
    tu.assert_str(req.id, "stc.027")
    tu.assert_str(req.name, "3.3.stc.1979_30yr")
    tu.assert_str(req.requirement_type, "spatioTemporalConstraint")
def _assert_doc_references(doc, is_update):
    """Assert simulation references."""
    # Model reference.
    tu.assert_object(doc.model_reference, cim.v1.DocReference)
    ref = doc.model_reference
    tu.assert_str(ref.description, "Reference to a modelComponent", True)
    tu.assert_uuid(ref.id, "7a2b64cc-03ca-11e1-a36a-00163e9152a5")
    tu.assert_str(ref.name, "HadGEM2-A")
    tu.assert_str(ref.type, "modelComponent")
    tu.assert_int(ref.version, 1)

    # Experiment reference.
    tu.assert_iter(doc.supports_references, 1, cim.v1.DocReference)
    ref = doc.supports_references[0]
    tu.assert_str(ref.description, "Reference to an Experiment", True)
    tu.assert_uuid(ref.id, "9fa513fc-d3a5-11df-837f-00163e9152a5")
    tu.assert_str(ref.name, "amip")
    tu.assert_str(ref.type, "experiment")
    tu.assert_int(ref.version, 1)
def assert_doc(doc, is_update=False):
    """Asserts a document.

    :param object doc: Document being tested.
    :param bool is_update: Flag indicating whether document has been updated.

    """
    tu.assert_iter(doc.data, 18, cim.v1.DataObject)
    tu.assert_iter(doc.ensembles, 1, cim.v1.Ensemble)
    tu.assert_object(doc.experiment, cim.v1.NumericalExperiment)
    tu.assert_iter(doc.grids, 1, cim.v1.GridSpec)
    tu.assert_object(doc.model, cim.v1.ModelComponent)
    tu.assert_object(doc.platform, cim.v1.Platform)
    tu.assert_object(doc.simulation, cim.v1.SimulationRun)
def _assert_doc_extent(doc, is_update):
    """Assert extent information."""
    tu.assert_object(doc.extent, cim.v1.DataExtent)
    e = doc.extent
    tu.assert_object(e.geographical, cim.v1.DataExtentGeographical)
    tu.assert_float(e.geographical.east, 360.0)
    tu.assert_float(e.geographical.north, 90.0)
    tu.assert_float(e.geographical.south, -90.0)
    tu.assert_object(e.temporal, cim.v1.DataExtentTemporal)
    tu.assert_date(e.temporal.begin, "1859-12-01 00:00:00")
    tu.assert_date(e.temporal.end, "1999-12-30 00:00:00")
    tu.assert_object(e.temporal.time_interval, cim.v1.DataExtentTimeInterval)
    ti = e.temporal.time_interval
    tu.assert_int(ti.factor, -1)
    tu.assert_int(ti.radix, 50430)
    tu.assert_str(ti.unit, "day")
def _assert_doc_distribution(doc, is_update):
    """Assert distribution information."""
    tu.assert_object(doc.distribution, cim.v1.DataDistribution)
    tu.assert_str(doc.distribution.access, "OnlineFileHTTP")
    tu.assert_str(doc.distribution.format, "NetCDF")
    tu.assert_object(doc.distribution.responsible_party, cim.v1.ResponsibleParty)