From e0141eefe71c401a1e71a719a41a947aa0ed6471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=82=B3=E3=83=83=E3=83=88?= Date: Wed, 26 Jun 2024 23:40:10 -0400 Subject: [PATCH] Mineral (#41) * mineral updates --- README.md | 880 ++++++++++++++++++++--------------------- cdr_schemas/mineral.py | 240 ++++++----- pyproject.toml | 2 +- 3 files changed, 559 insertions(+), 563 deletions(-) diff --git a/README.md b/README.md index d45a1f6..d35bc8b 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,15 @@ classDiagram class Area_Extraction { type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list category: AreaType text: str = '' reference_id: str = '' validated: bool = False model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None } class AreaType { @@ -117,50 +117,23 @@ classDiagram ```mermaid classDiagram - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list - system: str - system_version: str - } - - class Geom_Point { - latitude: float | int | None - longitude: float | int | None - type: GeomType = GeomType.Point - } - - class GeoreferenceResult { - likely_CRSs: list[str] = list - map_area: Area_Extraction | None = None - projections: list[ProjectionResult] = list - } - - class Pixel_Point { - rows_from_top: float | int - columns_from_left: float | int - type: GeomType = GeomType.Point - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - class Area_Extraction { type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list category: AreaType text: str = '' reference_id: str = '' validated: bool = False model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class GeoreferenceResult { + likely_CRSs: list[str] = list + map_area: Optional[Area_Extraction] = None + projections: list[ProjectionResult] = list } class ProjectionResult { @@ -170,22 +143,49 @@ classDiagram validated: bool = False } + class Geom_Point { + latitude: Union[float, int, NoneType] + longitude: Union[float, int, NoneType] + type: GeomType = GeomType.Point + } + + class Pixel_Point { + rows_from_top: Union[float, int] + columns_from_left: Union[float, int] + type: GeomType = GeomType.Point + } + class GroundControlPoint { gcp_id: str map_geom: Geom_Point px_geom: Pixel_Point - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None model: str model_version: str crs: str } + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list + system: str + system_version: str + } + Area_Extraction ..> GeomType Area_Extraction ..> AreaType Geom_Point ..> GeomType Pixel_Point ..> GeomType - GroundControlPoint ..> Pixel_Point GroundControlPoint ..> Geom_Point + GroundControlPoint ..> Pixel_Point GeoreferenceResult ..> Area_Extraction GeoreferenceResult ..> ProjectionResult GeoreferenceResults ..> GeoreferenceResult @@ -204,45 +204,45 @@ classDiagram ```mermaid classDiagram - class MapShapeTypes { + class MapColorSchemeTypes { <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' } class MapMetaData { title: str = '' - year: int | None = None + year: Optional[int] = None crs: str = '' authors: list[str] = list organization: str = '' - scale: int | None = None + scale: Optional[int] = None quadrangle_name: str = '' - map_shape: MapShapeTypes | None = None - map_color_scheme: MapColorSchemeTypes | None = None + map_shape: Optional[MapShapeTypes] = None + map_color_scheme: Optional[MapColorSchemeTypes] = None publisher: str = '' state: str = '' model: str model_version: str } - class MapColorSchemeTypes { + class MapShapeTypes { <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes + MapMetaData ..> MapShapeTypes CogMetaData ..> MapMetaData @@ -258,101 +258,101 @@ classDiagram ```mermaid classDiagram + class FeatureResults { + system: str + system_version: str + cog_id: str + line_feature_results: list[LineLegendAndFeaturesResult] = list + point_feature_results: list[PointLegendAndFeaturesResult] = list + polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list + cog_area_extractions: list[Area_Extraction] = list + cog_metadata_extractions: list[CogMetaData] = list + } + + class Area_Extraction { + type: GeomType = GeomType.Polygon + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list + category: AreaType + text: str = '' + reference_id: str = '' + validated: bool = False + model: str + model_version: str + confidence: Union[float, int, NoneType] = None + } + class PolygonLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None label: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list color: str = '' pattern: str = '' category: str = '' - map_unit: MapUnit | None = None + map_unit: Optional[MapUnit] = None reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - polygon_features: PolygonFeatureCollection | None = None - } - - class Area_Extraction { - type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list - category: AreaType - text: str = '' - reference_id: str = '' - validated: bool = False - model: str - model_version: str - confidence: float | int | None = None + polygon_features: Optional[PolygonFeatureCollection] = None } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - class LineLegendAndFeaturesResult { + class PointLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None - name: str = '' + legend_provenance: Optional[ModelProvenance] = None + name: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: LineFeatureCollection | None = None + point_features: Optional[PointFeatureCollection] = None } - class FeatureResults { - system: str - system_version: str - cog_id: str - line_feature_results: list[LineLegendAndFeaturesResult] = list - point_feature_results: list[PointLegendAndFeaturesResult] = list - polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list - cog_area_extractions: list[Area_Extraction] = list - cog_metadata_extractions: list[CogMetaData] = list - } - - class PointLegendAndFeaturesResult { + class LineLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None - name: str + legend_provenance: Optional[ModelProvenance] = None + name: str = '' abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: PointFeatureCollection | None = None + line_features: Optional[LineFeatureCollection] = None } Area_Extraction ..> GeomType Area_Extraction ..> AreaType LineLegendAndFeaturesResult ..> LineFeatureCollection LineLegendAndFeaturesResult ..> ModelProvenance - PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance + PointLegendAndFeaturesResult ..> PointFeatureCollection PolygonLegendAndFeaturesResult ..> ModelProvenance PolygonLegendAndFeaturesResult ..> MapUnit PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection CogMetaData ..> MapMetaData FeatureResults ..> Area_Extraction - FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> CogMetaData FeatureResults ..> PointLegendAndFeaturesResult @@ -368,76 +368,76 @@ classDiagram ```mermaid classDiagram - class PointProperties { - model: str - model_version: str - confidence: float | int | None = None - bbox: list[float | int] | None = None - dip: int | None = None - dip_direction: int | None = None - reference_id: str = '' - validated: bool = False - } - class PointFeatureCollection { type: GeoJsonType = GeoJsonType.FeatureCollection features: list[PointFeature] = list } - class PointFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Point - properties: PointProperties - } - - class GeomType { + class GeoJsonType { <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } class Point { - coordinates: list[float | int] + coordinates: list[Union[float, int]] type: GeomType = GeomType.Point } - class GeoJsonType { + class GeomType { <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class PointFeature { + type: GeoJsonType = GeoJsonType.Feature + id: str + geometry: Point + properties: PointProperties } class PointLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None name: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: PointFeatureCollection | None = None + point_features: Optional[PointFeatureCollection] = None + } + + class PointProperties { + model: str + model_version: str + confidence: Union[float, int, NoneType] = None + bbox: list[Union[float, int]] = None + dip: Optional[int] = None + dip_direction: Optional[int] = None + reference_id: str = '' + validated: bool = False } Point ..> GeomType - PointFeature ..> PointProperties PointFeature ..> Point PointFeature ..> GeoJsonType + PointFeature ..> PointProperties PointFeatureCollection ..> PointFeature PointFeatureCollection ..> GeoJsonType - PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance + PointLegendAndFeaturesResult ..> PointFeatureCollection ``` @@ -459,62 +459,62 @@ classDiagram properties: LineProperty } - class Line { - coordinates: list[list[float | int]] - type: GeomType = GeomType.LineString - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - - class DashType { - <> - solid: str = 'solid' - dash: str = 'dash' - dotted: str = 'dotted' - } - class GeoJsonType { <> Feature: str = 'Feature' FeatureCollection: str = 'FeatureCollection' } - class LineFeatureCollection { - type: GeoJsonType = GeoJsonType.FeatureCollection - features: list[LineFeature] = list - } - class LineLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None name: str = '' abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: LineFeatureCollection | None = None + line_features: Optional[LineFeatureCollection] = None + } + + class LineFeatureCollection { + type: GeoJsonType = GeoJsonType.FeatureCollection + features: list[LineFeature] = list + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class DashType { + <> + solid: str = 'solid' + dash: str = 'dash' + dotted: str = 'dotted' + } + + class Line { + coordinates: list[list[Union[float, int]]] + type: GeomType = GeomType.LineString } class LineProperty { model: str model_version: str - confidence: float | int | None = None - dash_pattern: DashType | None = None + confidence: Union[float, int, NoneType] = None + dash_pattern: Optional[DashType] = None symbol: str = '' reference_id: str = '' validated: bool = False @@ -543,73 +543,65 @@ classDiagram ```mermaid classDiagram - class PolygonFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Polygon - properties: PolygonProperty - } - - class Polygon { - coordinates: list[list[list[float | int]]] - type: GeomType = GeomType.Polygon - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - - class PolygonProperty { - model: str - model_version: str - reference_id: str = '' - validated: bool = False - confidence: float | int | None = None - } - - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class MapUnit { + age_text: str = '' + b_age: Optional[float] = None + b_interval: str = '' + lithology: str = '' + name: str = '' + t_age: Optional[float] = None + t_interval: str = '' + comments: str = '' } class PolygonLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None label: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list color: str = '' pattern: str = '' category: str = '' - map_unit: MapUnit | None = None + map_unit: Optional[MapUnit] = None reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - polygon_features: PolygonFeatureCollection | None = None + polygon_features: Optional[PolygonFeatureCollection] = None + } + + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' + } + + class PolygonFeature { + type: GeoJsonType = GeoJsonType.Feature + id: str + geometry: Polygon + properties: PolygonProperty + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None } - class MapUnit { - age_text: str = '' - b_age: float | None = None - b_interval: str = '' - lithology: str = '' - name: str = '' - t_age: float | None = None - t_interval: str = '' - comments: str = '' + class Polygon { + coordinates: list[list[list[Union[float, int]]]] + type: GeomType = GeomType.Polygon } class PolygonFeatureCollection { @@ -617,12 +609,20 @@ classDiagram features: list[PolygonFeature] = list } + class PolygonProperty { + model: str + model_version: str + reference_id: str = '' + validated: bool = False + confidence: Union[float, int, NoneType] = None + } + Polygon ..> GeomType PolygonFeature ..> Polygon PolygonFeature ..> PolygonProperty PolygonFeature ..> GeoJsonType - PolygonFeatureCollection ..> PolygonFeature PolygonFeatureCollection ..> GeoJsonType + PolygonFeatureCollection ..> PolygonFeature PolygonLegendAndFeaturesResult ..> ModelProvenance PolygonLegendAndFeaturesResult ..> MapUnit PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection @@ -640,45 +640,45 @@ classDiagram ```mermaid classDiagram - class MapShapeTypes { + class MapColorSchemeTypes { <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' } class MapMetaData { title: str = '' - year: int | None = None + year: Optional[int] = None crs: str = '' authors: list[str] = list organization: str = '' - scale: int | None = None + scale: Optional[int] = None quadrangle_name: str = '' - map_shape: MapShapeTypes | None = None - map_color_scheme: MapColorSchemeTypes | None = None + map_shape: Optional[MapShapeTypes] = None + map_color_scheme: Optional[MapColorSchemeTypes] = None publisher: str = '' state: str = '' model: str model_version: str } - class MapColorSchemeTypes { + class MapShapeTypes { <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes + MapMetaData ..> MapShapeTypes CogMetaData ..> MapMetaData @@ -698,43 +698,43 @@ classDiagram doi: str = '' authors: list[str] = list journal: str = '' - year: int | None = None - month: int | None = None - volume: int | None = None + year: Optional[int] = None + month: Optional[int] = None + volume: Optional[int] = None issue: str = '' description: str = '' publisher: str = '' } - class DocumentProvenance { - external_system_name: str - external_system_id: str = '' - external_system_url: str = '' - } - class UploadDocument { title: str is_open: bool = True provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None + metadata: Optional[DocumentMetaData] = None system: str system_version: str } class DocumentExtraction { - id: str | None = None + id: UnionType[str, NoneType] = None document_id: str = None extraction_type: str extraction_label: str - score: float | None = None - bbox: tuple[float, float, float, float] | None = None - page_num: int | None = None - external_link: str | None = None - data: dict[] | None = None + score: UnionType[float, NoneType] = None + bbox: UnionType[tuple[float, float, float, float], NoneType] = None + page_num: UnionType[int, NoneType] = None + external_link: UnionType[str, NoneType] = None + data: Optional[dict[]] = None system: str system_version: str } + class DocumentProvenance { + external_system_name: str + external_system_id: str = '' + external_system_url: str = '' + } + class Document { id: str title: str @@ -742,7 +742,7 @@ classDiagram pages: int size: int provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None + metadata: Optional[DocumentMetaData] = None system: str system_version: str } @@ -765,99 +765,107 @@ classDiagram ```mermaid classDiagram - class PageInfo { - page: int - bounding_box: BoundingBox | None + class MineralInventory { + contained_metal: Optional[float] = None + commodity: str = '' + commodity_observed_name: str = '' + ore_unit: str = '' + ore_value: Optional[float] = None + grade_unit: str = '' + grade_value: Optional[float] = None + cutoff_grade_unit: str = '' + cutoff_grade_value: Optional[float] = None + material_form: Optional[float] = None + material_form_unit: str = '' + material_form_conversion: Optional[float] = None + confidence: Optional[Confidence] = None + categories: list[MineralInventoryCategory] = list + documents: list[DocumentReference] = list + records: list[RecordReference] = list + date: Optional[datetime] = None + zone: str = '' } - class Document { - id: str - title: str - is_open: bool - pages: int - size: int - provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None - system: str - system_version: str + class DepositTypeCandidate { + observed_name: str = '' + name: str + confidence: Union[float, int, NoneType] = None + source: str } - class LocationInfo { - location: Geometry - crs: str - country: str = '' - state_or_province: str | None + class RecordReference { + record_id: str = '' + source: str = '' + uri: str = '' } class EvidenceLayer { - name: str + name: str = '' relevance_score: float } - class Commodity { - name: str + class MappableCriteria { + criteria: str + theoretical: str = '' + potential_dataset: list[EvidenceLayer] = list + supporting_references: list[DocumentReference] } - class Geometry { - <> - Point: str = 'Point' - Polygon: str = 'Polygon' + class DocumentReference { + cdr_id: str + page: Optional[int] = None + x_min: Optional[float] = None + x_max: Optional[float] = None + y_min: Optional[float] = None + y_max: Optional[float] = None } - class Grade { - grade_unit: str - grade_value: float + class DepositType { + name: str + environment: str + group: str } - class DepositTypeCandidate { - observed_name: str - normalized_uri: DepositType - confidence: float | int | None + class MineralInventoryCategory { + category: str + confidence: Union[float, int, NoneType] = None source: str } - class Ore { - ore_unit: str - ore_value: float - } - - class BoundingBox { - x_min: float - x_max: float - y_min: float - y_max: float - } - - class MineralInventory { - commodity: Commodity - observed_commodity: str = '' - category: ResourceReserveCategory | None - ore: Ore | None - grade: Grade | None - cutoff_grade: Grade | None - contained_metal: float | None - reference: Reference - date: datetime | None - zone: str = '' - } - - class MappableCriteria { - criteria: str - theoretical: str = '' - potential_dataset: list[EvidenceLayer] = list - supporting_references: list[Reference] + class MineralSite { + id: str + source_id: str = '' + record_id: str = '' + name: str = '' + site_rank: str = '' + site_type: str = '' + country: list[str] = list + province: list[str] = list + location: Optional[GeoLocationInfo] = None + mineral_inventory: list[MineralInventory] = list + deposit_type_candidate: list[DepositTypeCandidate] = list } class MineralSystem { - deposit_type: list[DepositType] - source: list[MappableCriteria] - pathway: list[MappableCriteria] + deposit_type: list[str] = list + source: list[MappableCriteria] = list + pathway: list[MappableCriteria] = list trap: list[MappableCriteria] = list preservation: list[MappableCriteria] = list energy: list[MappableCriteria] = list outflow: list[MappableCriteria] = list } + class Confidence { + confidence: Union[float, int, NoneType] = None + source: str + } + + class GeoLocationInfo { + crs: str + geom: str + } + class GeologyInfo { age: str = '' unit_name: str = '' @@ -868,57 +876,17 @@ classDiagram comments: str = '' } - class DepositType { - name: str - environment: str - group: str - } - - class MineralSite { - source_id: str - record_id: str - name: str = '' - mineral_inventory: list[MineralInventory] - location_info: LocationInfo - geology_info: GeologyInfo | None - deposit_type_candidate: list[DepositTypeCandidate] - } - - class Reference { - document: Document - page_info: list[PageInfo] = list - } - - class ResourceReserveCategory { - <> - INFERRED: str = 'Inferred Mineral Resource' - INDICATED: str = 'Indicated Mineral Resource' - MEASURED: str = 'Measured Mineral Resource' - PROBABLE: str = 'Probable Mineral Reserve' - PROVEN: str = 'Proven Mineral Reserve' - } - - Document ..> DocumentMetaData - Document ..> DocumentProvenance - DepositTypeCandidate ..> DepositType - PageInfo ..> BoundingBox - Reference ..> PageInfo - Reference ..> Document + MappableCriteria ..> DocumentReference MappableCriteria ..> EvidenceLayer - MappableCriteria ..> Reference - MineralSystem ..> DepositType MineralSystem ..> MappableCriteria - MineralInventory ..> Reference - MineralInventory ..> Ore - MineralInventory ..> Grade - MineralInventory ..> Commodity - MineralInventory ..> ResourceReserveCategory + MineralInventory ..> MineralInventoryCategory + MineralInventory ..> Confidence MineralInventory ..> datetime - LocationInfo ..> Geometry - MineralSite ..> GeologyInfo - MineralSite ..> DepositTypeCandidate + MineralInventory ..> DocumentReference + MineralInventory ..> RecordReference MineralSite ..> MineralInventory - MineralSite ..> LocationInfo + MineralSite ..> GeoLocationInfo + MineralSite ..> DepositTypeCandidate ``` @@ -933,12 +901,15 @@ classDiagram ```mermaid classDiagram - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list + class FeatureResults { system: str system_version: str + cog_id: str + line_feature_results: list[LineLegendAndFeaturesResult] = list + point_feature_results: list[PointLegendAndFeaturesResult] = list + polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list + cog_area_extractions: list[Area_Extraction] = list + cog_metadata_extractions: list[CogMetaData] = list } class MapResults { @@ -947,26 +918,23 @@ classDiagram extraction_results: list[FeatureResults] = list } - class FeatureResults { + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list system: str system_version: str - cog_id: str - line_feature_results: list[LineLegendAndFeaturesResult] = list - point_feature_results: list[PointLegendAndFeaturesResult] = list - polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list - cog_area_extractions: list[Area_Extraction] = list - cog_metadata_extractions: list[CogMetaData] = list } FeatureResults ..> Area_Extraction - FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> CogMetaData FeatureResults ..> PointLegendAndFeaturesResult GeoreferenceResults ..> GeoreferenceResult GeoreferenceResults ..> GroundControlPoint - MapResults ..> GeoreferenceResults MapResults ..> FeatureResults + MapResults ..> GeoreferenceResults ``` @@ -1016,30 +984,6 @@ classDiagram SHP: str = 'shp' } - class InterpolationType { - <> - LINEAR: str = 'linear' - CUBIC: str = 'cubic' - NEAREST: str = 'nearest' - NONE: str = 'none' - } - - class StackMetaData { - title: str | None - year: int | None - crs: str | None - authors: list[str] | None - organization: str | None - scale: int | None - evidence_layers: list[ProcessedDataLayer] - } - - class LayerDataType { - <> - CONTINUOUS: str = 'continuous' - BINARY: str = 'binary' - } - class ScalingType { <> MINMAX: str = 'minmax' @@ -1048,7 +992,7 @@ classDiagram } class ProcessedDataLayer { - title: str | None + title: Optional[str] resampling_method: InterpolationType scaling_method: ScalingType normalization_method: str @@ -1062,25 +1006,49 @@ classDiagram } class DataSource { - DOI: str | None - authors: list[str] | None - publication_date: str | None - category: LayerCategory | str | None - subcategory: str | None - description: str | None - derivative_ops: str | None + DOI: Optional[str] + authors: Optional[list[str]] + publication_date: Optional[str] + category: Union[LayerCategory, str, NoneType] + subcategory: Optional[str] + description: Optional[str] + derivative_ops: Optional[str] type: LayerDataType - resolution: tuple | None + resolution: Optional[tuple] format: DataFormat - download_url: str | None + download_url: Optional[str] + } + + class LayerDataType { + <> + CONTINUOUS: str = 'continuous' + BINARY: str = 'binary' + } + + class InterpolationType { + <> + LINEAR: str = 'linear' + CUBIC: str = 'cubic' + NEAREST: str = 'nearest' + NONE: str = 'none' + } + + class StackMetaData { + title: Optional[str] + year: Optional[int] + crs: Optional[str] + authors: Optional[list[str]] + organization: Optional[str] + scale: Optional[int] + evidence_layers: list[ProcessedDataLayer] } - DataSource ..> LayerDataType - DataSource ..> DataFormat DataSource ..> tuple + DataSource ..> DataFormat DataSource ..> LayerCategory - ProcessedDataLayer ..> ScalingType + DataSource ..> LayerDataType ProcessedDataLayer ..> InterpolationType + ProcessedDataLayer ..> ScalingType StackMetaData ..> ProcessedDataLayer @@ -1096,43 +1064,46 @@ classDiagram ```mermaid classDiagram - class CMAModel { - title: str | None - date: int | None - authors: list[str] | None - organization: str | None - cma_model_type: NeuralNetModel | SOMModel - training_data: StackMetaData + class SOMTrainConfig { + dimensions_x: int + dimensions_y: int + num_epochs: int + num_initializations: int + neighborhood_function: NeighborhoodFunction + som_type: SOMType + neighborhood_decay: NeighborhoodDecay + learning_rate_decay: LearningRateDecay + initial_learning_rate: float + final_learning_rate: float + som_initialization: SOMInitialization + som_grid: SOMGrid } - class SOMGrid { + class LearningRateDecay { <> - HEXAGONAL: str = 'hexagonal' - RECTANGULAR: str = 'rectangular' - } - - class NeuralNetModel { - train_config: NeuralNetTrainConfig + LINEAR: str = 'linear' + EXPONENTIAL: str = 'exponential' } - class Accelerator { + class SOMType { <> - CPU: str = 'cpu' - GPU: str = 'gpu' + TOROID: str = 'toroid' + SHEET: str = 'sheet' } - class StackMetaData { - title: str | None - year: int | None - crs: str | None - authors: list[str] | None - organization: str | None - scale: int | None - evidence_layers: list[ProcessedDataLayer] + class SOMInitialization { + <> + RANDOM: str = 'random' + PCA: str = 'pca' } - class SOMModel { - train_config: SOMTrainConfig + class CMAModel { + title: Optional[str] + date: Optional[int] + authors: Optional[list[str]] + organization: Optional[str] + cma_model_type: Union[NeuralNetModel, SOMModel] + training_data: StackMetaData } class NeighborhoodDecay { @@ -1141,37 +1112,34 @@ classDiagram EXPONENTIAL: str = 'exponential' } - class LearningRateDecay { - <> - LINEAR: str = 'linear' - EXPONENTIAL: str = 'exponential' + class SOMModel { + train_config: SOMTrainConfig } - class SOMTrainConfig { - dimensions_x: int - dimensions_y: int - num_epochs: int - num_initializations: int - neighborhood_function: NeighborhoodFunction - som_type: SOMType - neighborhood_decay: NeighborhoodDecay - learning_rate_decay: LearningRateDecay - initial_learning_rate: float - final_learning_rate: float - som_initialization: SOMInitialization - som_grid: SOMGrid + class Accelerator { + <> + CPU: str = 'cpu' + GPU: str = 'gpu' } - class SOMInitialization { + class SOMGrid { <> - RANDOM: str = 'random' - PCA: str = 'pca' + HEXAGONAL: str = 'hexagonal' + RECTANGULAR: str = 'rectangular' } - class SOMType { - <> - TOROID: str = 'toroid' - SHEET: str = 'sheet' + class StackMetaData { + title: Optional[str] + year: Optional[int] + crs: Optional[str] + authors: Optional[list[str]] + organization: Optional[str] + scale: Optional[int] + evidence_layers: list[ProcessedDataLayer] + } + + class NeuralNetModel { + train_config: NeuralNetTrainConfig } class NeighborhoodFunction { @@ -1191,17 +1159,17 @@ classDiagram StackMetaData ..> ProcessedDataLayer NeuralNetTrainConfig ..> Accelerator - SOMTrainConfig ..> SOMInitialization SOMTrainConfig ..> SOMGrid + SOMTrainConfig ..> LearningRateDecay SOMTrainConfig ..> SOMType + SOMTrainConfig ..> SOMInitialization SOMTrainConfig ..> NeighborhoodFunction SOMTrainConfig ..> NeighborhoodDecay - SOMTrainConfig ..> LearningRateDecay NeuralNetModel ..> NeuralNetTrainConfig SOMModel ..> SOMTrainConfig - CMAModel ..> StackMetaData - CMAModel ..> NeuralNetModel CMAModel ..> SOMModel + CMAModel ..> NeuralNetModel + CMAModel ..> StackMetaData ``` diff --git a/cdr_schemas/mineral.py b/cdr_schemas/mineral.py index dbccc5d..4bdbd2d 100644 --- a/cdr_schemas/mineral.py +++ b/cdr_schemas/mineral.py @@ -1,40 +1,58 @@ from datetime import datetime -from enum import Enum from typing import List, Optional, Union from pydantic import BaseModel, Field -from cdr_schemas.document import Document +class DocumentReference(BaseModel): + cdr_id: str + page: Optional[int] = Field(default=None) + x_min: Optional[float] = Field(default=None) + x_max: Optional[float] = Field(default=None) + y_min: Optional[float] = Field(default=None) + y_max: Optional[float] = Field(default=None) -class Geometry(Enum): - Point = "Point" - Polygon = "Polygon" +class EvidenceLayer(BaseModel): + name: str = Field(default="") + relevance_score: float -class ResourceReserveCategory(Enum): - INFERRED = "Inferred Mineral Resource" - INDICATED = "Indicated Mineral Resource" - MEASURED = "Measured Mineral Resource" - PROBABLE = "Probable Mineral Reserve" - PROVEN = "Proven Mineral Reserve" + +class MappableCriteria(BaseModel): + criteria: str + theoretical: str = Field(default="") + potential_dataset: list[EvidenceLayer] = Field( + default_factory=list, description="List of evidence layers" + ) + supporting_references: list[DocumentReference] + + +class MineralSystem(BaseModel): + deposit_type: list[str] = Field(default_factory=list) + source: list[MappableCriteria] = Field(default_factory=list) + pathway: list[MappableCriteria] = Field(default_factory=list) + trap: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: trap" + ) + preservation: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: Preservation" + ) + energy: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: Energy" + ) + outflow: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: outflow" + ) class GeologyInfo(BaseModel): age: str = Field(default="", description="Age of the geologic unit or event") unit_name: str = Field(default="", description="Name of the geologic unit") - description: str = "" + description: str = Field(default="") lithology: List[str] = Field(default_factory=list, description="Lithology") process: List[str] = Field(default_factory=list, description="Process") environment: List[str] = Field(default_factory=list, description="environment") - comments: str = "" - - -class Ore(BaseModel): - ore_unit: str = Field( - description="The unit in which ore quantity is measured, eg, metric tonnes" - ) - ore_value: float = Field(description="The value of ore quantity") + comments: str = Field(default="") class DepositType(BaseModel): @@ -45,104 +63,111 @@ class DepositType(BaseModel): class DepositTypeCandidate(BaseModel): observed_name: str = Field( - description="Source dataset that the site info is retrieved from. e.g., MRDS" - ) - normalized_uri: DepositType = Field( - description="The deposit type of an inventory item" + default="", + description="Source dataset that the site info is retrieved from. e.g., MRDS", ) + + name: str = Field(description="Deposit type name") + confidence: Optional[Union[float, int]] = Field( - description="Score deposit type of an inventory item" + default=None, description="Score deposit type of an inventory item" ) source: str = Field( description="Source of the classification (automated model version / SME / etc...)" ) -class BoundingBox(BaseModel): - x_min: float - x_max: float - y_min: float - y_max: float +class RecordReference(BaseModel): + record_id: str = Field(default="", description="id in source") + source: str = Field(default="", description="Source information") + uri: str = Field(default="", description="uri of source") -class PageInfo(BaseModel): - page: int - bounding_box: Optional[BoundingBox] = Field( - description="Coordinates of the document where reference is found" +class MineralInventoryCategory(BaseModel): + category: str = Field(description="category name") + confidence: Optional[Union[float, int]] = Field( + default=None, + ) + source: str = Field( + description="Source of the classification (automated model version / SME / etc...)" ) -class Reference(BaseModel): - document: Document - page_info: List[PageInfo] = Field( - default_factory=list, - description="List of pages and their respective bounding boxes where the reference is found", +class GeoLocationInfo(BaseModel): + crs: str = Field( + description="The Coordinate Reference System (CRS) of the location" ) - -class EvidenceLayer(BaseModel): - name: str - relevance_score: float + geom: str = Field( + description="Type: Polygon or Point, value indicates the geolocation of the site" + ) -class MappableCriteria(BaseModel): - criteria: str - theoretical: str = "" - potential_dataset: list[EvidenceLayer] = Field( - default_factory=list, description="List of evidence layers" +class Confidence(BaseModel): + confidence: Optional[Union[float, int]] = Field(default=None) + source: str = Field( + description="Source of the classification (automated model version / SME / etc...)" ) - supporting_references: list[Reference] -class MineralSystem(BaseModel): - deposit_type: list[DepositType] - source: list[MappableCriteria] - pathway: list[MappableCriteria] - trap: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: trap" +class MineralInventory(BaseModel): + contained_metal: Optional[float] = Field( + default=None, + description="The quantity of a contained metal in an inventory item", ) - preservation: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: Preservation" + commodity: str = Field(default="", description="The commodity of an inventory item") + commodity_observed_name: str = Field( + default="", + description="The observed commodity in the source data (textual format)", ) - energy: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: Energy" + + ore_unit: str = Field( + default="", + description="The unit in which ore quantity is measured, eg, metric tonnes", ) - outflow: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: outflow" + ore_value: Optional[float] = Field( + default=None, description="The value of ore quantity" ) - -class Commodity(BaseModel): - name: str - - -class Grade(BaseModel): grade_unit: str = Field( - description="The unit in which grade is measured, eg, percent" + default="", description="The unit in which grade is measured, eg, percent" ) - grade_value: float = Field(description="The value of grade") + grade_value: Optional[float] = Field(default=None, description="The value of grade") - -class MineralInventory(BaseModel): - commodity: Commodity = Field(description="The commodity of an inventory item") - observed_commodity: str = Field( - default="", - description="The observed commodity in the source data (textual format)", + cutoff_grade_unit: str = Field( + default="", description="The unit in which grade is measured, eg, percent" ) - category: Optional[ResourceReserveCategory] = Field( - description="The category of an inventory item" + cutoff_grade_value: Optional[float] = Field(default=None) + + material_form: Optional[float] = Field(default=None) + material_form_unit: str = Field(default="") + material_form_conversion: Optional[float] = Field(default=None) + + confidence: Optional[Confidence] = Field(default=None) + + categories: List[MineralInventoryCategory] = Field( + default_factory=list, + description=""" + A list of categories + """, ) - ore: Optional[Ore] = Field(description="The ore of an inventory item") - grade: Optional[Grade] = Field(description="The grade of an inventory item") - cutoff_grade: Optional[Grade] = Field( - description="The cutoff grade of the observed inventory item" + + documents: List[DocumentReference] = Field( + default_factory=list, + description=""" + A list of document references + """, ) - contained_metal: Optional[float] = Field( - description="The quantity of a contained metal in an inventory item" + + records: List[RecordReference] = Field( + default_factory=list, + description=""" + A list of records references from databases or other sources + """, ) - reference: Reference = Field(description="The reference of an inventory item") + date: Optional[datetime] = Field( - description="When in the point of time mineral inventory valid" + default=None, description="When in the point of time mineral inventory valid" ) zone: str = Field( default="", @@ -150,30 +175,33 @@ class MineralInventory(BaseModel): ) -class LocationInfo(BaseModel): - location: Geometry = Field( - description="Type: Polygon or Point, value indicates the geolocation of the site" - ) - crs: str = Field( - description="The Coordinate Reference System (CRS) of the location" - ) - country: str = Field( - default="", description="Country that the mine site resides in" - ) - state_or_province: Optional[str] = Field( - description="State or province that the mine site resides in" - ) - - class MineralSite(BaseModel): + id: str = Field(description="Mineral Site Id") source_id: str = Field( - description="Source dataset that the site info is retrieved from. e.g., MRDS" + default="", + description="Source dataset that the site info is retrieved from. e.g., MRDS", ) record_id: str = Field( - description="Unique ID of the record that the info is retrieved from e.g., 10022920" + default="", + description="Unique ID of the record that the info is retrieved from e.g., 10022920", ) name: str = Field(default="", description="Name of the mine, e.g., Tungsten Jim") - mineral_inventory: list[MineralInventory] - location_info: LocationInfo - geology_info: Optional[GeologyInfo] - deposit_type_candidate: list[DepositTypeCandidate] + + site_rank: str = Field(default="") + site_type: str = Field(default="") + country: List[str] = Field(default_factory=list) + province: List[str] = Field(default_factory=list) + location: Optional[GeoLocationInfo] = Field(default=None) + mineral_inventory: List[MineralInventory] = Field( + default_factory=list, + description=""" + A list of mineral inventories + """, + ) + + deposit_type_candidate: List[DepositTypeCandidate] = Field( + default_factory=list, + description=""" + A list of deposit types candidates + """, + ) diff --git a/pyproject.toml b/pyproject.toml index 3518b0d..4cbc15a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdr_schemas" -version = "0.3.2" +version = "0.3.3" description = "CDR Schemas" authors = [] readme = "README.md"