Package: cloudmetrics
cloudmetricsThecloudmetricspackage contains python routines to compute metrics
from 2D cloud fields to characterise cloud patterns in these fields. Most
methods operate on acloud-mask(i.e. a boolean true-false field)
indicating where clouds exist, some work on individually labelled (with a
unique integer ID) cloud objects (which can be produced from a cloud-mask) and
finally some work on 2D cloud scalar-fields (defining for example the
cloud-liquid water or cloud-top height).NOTE: thecloudmetricspackage contained in this repository is
refactored from work published inJanssens et al
2021,
this was done to make the routines implemented more accessible by external
tools and to ensure consistency. Not all functionality has been retained or
fully refactored, in particular functionality to allow for bulk-processing of
input files is in thecloudmetrics-piplinepackage. Progress on the refactoring can be followed in issuehttps://github.com/cloudsci/cloudmetrics/issues/20. The version published in
Janssens et al 2021 isavailable tagged as version
v0.1.0.Implemented metricsThe table below gives an overview over which metrics are avaiable in thecloudmetricspackage and what input each metric takes.function withincloudmetricsmaskobject_labelsscalar_fieldmask.cloud_fraction✔️mask.fractal_dimension✔️mask.open_sky✔️mask.orientation✔️mask.network_nn_distTODOmask.cop✔️†✔️mask.csdTODOTODOobjects.iorg✔️†✔️objects.max_length_scale✔️†✔️objects.mean_eccentricity✔️†✔️objects.mean_length_scale✔️†✔️objects.mean_perimeter_length✔️†✔️objects.rdfTODOTODOobjects.scai✔️†✔️scalar.spectral_anisotropy#1✔️scalar.spectral_length_median#1✔️scalar.spectral_length_moment,#1✔️scalar.spectral_slope#1✔️scalar.spectral_slope_binned#1✔️scalar.woi1✔️scalar.woi2✔️scalar.woi3✔️scalar.meanoptional✔️scalar.varoptional✔️scalar.stdoptional✔️scalar.skewoptional✔️scalar.kurtosisoptional✔️†: for convenience object-based scalars are also made avaiable to operate
directly on masks, for exampleobjects.max_length_scale(object_labels=...)can be called with a mask asmask.max_object_length_scale(mask=...)andobjects.iorg(object_labels=...)can be called withmask.iorg_objects(mask=...).#1: spectral metrics currently operate on the relevant power spectral densities,
which must first be computed:wavenumbers, psd_1d_radial, psd_1d_azimuthal = scalar.compute_spectra(...)
spectral_length_moment = scalar.spectral_length_moment(wavenumbers, psd_1d_radial)Alternatively, all spectral metrics can be computed simultaneously following the
standard convention withspectral_metrics = scalar.compute_all_spectral(scalar_field).
need refactoring to takescalar_fieldas inputInstallationTo install the most recent version ofcloudmetricsfrom pypi you can usepip:$>pipinstallcloudmetricsIf you plan to add/modifycloudmetrics(contribution via pull-requests are
very welcome!) you should check out thedevelopment
notesfor how to get set up with a local copy of the codebase.UsageTo use thecloudmetricspackage simply importcloudmetricsand use the
metric function you are interested in:importcloudmetricsiorg=cloudmetrics.mask.iorg_objects(mask=da_cloudmask,periodic_domain=False)As you can see in the table above the metrics are organised by the input they
take, either object masks, labelled-object arrays and/or 2D scalar fields you
want to perform reductions on.Note on periodic domains: internallycloudmetricsrepresents objects on
periodic domains by doubling the xy-size of any input mask provided, and moving
any objects that straddle the boundary to ensure they are spatially contiguous.
This means that all functions which take 2D arrays of object-labels as input
assume that all labelled objects are spatially contiguous and that the provided
input is actually2*nx x 2*ny(for an actual input domain spanningnxbynx). All metric functions that operate on masks handle the domain-doubling
internally and so do not require any modification to the masks before calling.