Esempio n. 1
0
        ruptAspectRatio=valid.positivefloat,
        maxMag=valid.positivefloat,
        minMag=valid.positivefloat,
        binWidth=valid.positivefloat,
        probability=valid.probability,
        hypoDepth=valid.probability_depth,
        nodalPlane=valid.nodal_plane,
        occurRates=valid.positivefloats,
        probs_occur=valid.pmf,
        weight=valid.probability,
        alongStrike=valid.probability,
        downDip=valid.probability,
    )


nodefactory.add("siteModel")(LiteralNode)


# insuranceLimit and deductible can be either tags or attributes!
def float_or_flag(value, isAbsolute=None):
    """
    Validate the attributes/tags insuranceLimit and deductible
    """
    if isAbsolute is None:  # considering the insuranceLimit attribute
        return valid.positivefloat(value)
    else:
        return valid.boolean(isAbsolute)


@nodefactory.add("exposureModel")
class ExposureDataNode(LiteralNode):
Esempio n. 2
0
        maxMag=valid.positivefloat,
        minMag=valid.positivefloat,
        binWidth=valid.positivefloat,
        probability=valid.probability,
        hypoDepth=valid.probability_depth,
        nodalPlane=valid.nodal_plane,
        occurRates=valid.positivefloats,
        probs_occur=valid.pmf,
        weight=valid.probability,
        alongStrike=valid.probability,
        downDip=valid.probability,
        id=valid.simple_id,
        )


nodefactory.add('siteModel')(LiteralNode)


# insuranceLimit and deductible can be either tags or attributes!
def float_or_flag(value, isAbsolute=None):
    """
    Validate the attributes/tags insuranceLimit and deductible
    """
    if isAbsolute is None:  # considering the insuranceLimit attribute
        return valid.positivefloat(value)
    else:
        return valid.boolean(isAbsolute)


@nodefactory.add('exposureModel')
class ExposureDataNode(LiteralNode):
Esempio n. 3
0
        hypoDepth=valid.probability_depth,
        occurRates=valid.positivefloats,
        probs_occur=valid.pmf,
        weight=valid.probability,
        alongStrike=valid.probability,
        downDip=valid.probability,
        totalMomentRate=valid.positivefloat,
        characteristicRate=valid.positivefloat,
        characteristicMag=valid.positivefloat,
        magnitudes=valid.positivefloats,
        id=valid.simple_id,
        discretization=valid.compose(valid.positivefloat, valid.nonzero),
        )


nodefactory.add('siteModel')(LiteralNode)


# insuranceLimit and deductible can be either tags or attributes!
def float_or_flag(value, isAbsolute=None):
    """
    Validate the attributes/tags insuranceLimit and deductible
    """
    if isAbsolute is None:  # considering the insuranceLimit attribute
        return valid.positivefloat(value)
    else:
        return valid.boolean(isAbsolute)


@nodefactory.add('exposureModel')
class ExposureDataNode(LiteralNode):
Esempio n. 4
0
        # NB: I am hiding the archive by starting its name with a '.',
        # to avoid confusing the users, since the unzip files are
        # already in the target directory; the archive is used internally
        # by the WebUI, so it must be there; it would be nice not to
        # generate it when not using the Web UI, but I will leave that
        # feature for after the removal of the old calculators
        archname = "." + output.ds_key + "-" + fmt + ".zip"
        zipfiles(exported, os.path.join(target, archname))
        return os.path.join(target, archname)
    else:  # single file
        return exported[0]


# update export_output with ds_export
for ekey in ds_export:
    export_output.add(ekey)(export_from_datastore)


def export(output_id, target, export_type="xml,geojson,csv"):
    """
    Export the given calculation `output_id` from the database to the
    specified `target` directory in the specified `export_type`.
    """
    output = models.Output.objects.get(id=output_id)
    if isinstance(target, basestring):  # create target directory
        makedirs(target)
    for exptype in export_type.split(","):
        rtype = output.output_type
        if rtype == "datastore":
            rtype = output.ds_key
        key = (rtype, exptype)
Esempio n. 5
0
        # NB: I am hiding the archive by starting its name with a '.',
        # to avoid confusing the users, since the unzip files are
        # already in the target directory; the archive is used internally
        # by the WebUI, so it must be there; it would be nice not to
        # generate it when not using the Web UI, but I will leave that
        # feature for after the removal of the old calculators
        archname = '.' + output.ds_key + '-' + fmt + '.zip'
        zipfiles(exported, os.path.join(target, archname))
        return os.path.join(target, archname)
    else:  # single file
        return exported[0]


# update export_output with ds_export
for ekey in ds_export:
    export_output.add(ekey)(export_from_datastore)


def export(output_id, target, export_type='xml,geojson,csv'):
    """
    Export the given calculation `output_id` from the database to the
    specified `target` directory in the specified `export_type`.
    """
    output = models.Output.objects.get(id=output_id)
    if isinstance(target, basestring):  # create target directory
        makedirs(target)
    for exptype in export_type.split(','):
        rtype = output.ds_key
        key = (rtype, exptype)
        if key in export_output:
            return export_output(key, output, target)
Esempio n. 6
0
        hypoDepth=valid.probability_depth,
        occurRates=valid.positivefloats,
        probs_occur=valid.pmf,
        weight=valid.probability,
        alongStrike=valid.probability,
        downDip=valid.probability,
        totalMomentRate=valid.positivefloat,
        characteristicRate=valid.positivefloat,
        characteristicMag=valid.positivefloat,
        magnitudes=valid.positivefloats,
        id=valid.simple_id,
        discretization=valid.compose(valid.positivefloat, valid.nonzero),
    )


nodefactory.add('siteModel')(LiteralNode)


# insuranceLimit and deductible can be either tags or attributes!
def float_or_flag(value, isAbsolute=None):
    """
    Validate the attributes/tags insuranceLimit and deductible
    """
    if isAbsolute is None:  # considering the insuranceLimit attribute
        return valid.positivefloat(value)
    else:
        return valid.boolean(isAbsolute)


@nodefactory.add('exposureModel')
class ExposureDataNode(LiteralNode):