Skip to content

Commit

Permalink
Merge pull request #58 from Terradue/feature/cbers-pan_ESACPE-1964
Browse files Browse the repository at this point in the history
Fix for CBERS PAN (with unspecified resolution)
  • Loading branch information
floeschau authored May 9, 2024
2 parents 59af998 + f2c472a commit 47a8f97
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/processing/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/raster/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"type": "Feature",
"id": "urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-51.624,
-30.02
],
[
-51.263,
-30.021
],
[
-51.261,
-28.964
],
[
-51.618,
-28.962
],
[
-51.624,
-30.02
]
]
]
},
"properties": {
"start_datetime": "2024-04-04T13:16:10Z",
"end_datetime": "2024-04-04T13:16:28Z",
"datetime": "2024-04-04T13:16:19Z",
"constellation": "cbers-4",
"platform": "cbers-4",
"mission": "cbers-4",
"instruments": [
"pan"
],
"sensor_type": "optical",
"gsd": 10.0,
"title": "CBERS-4 PAN10M L4 2024-04-04 13:16:19",
"eo:bands": [
{
"name": "band-2",
"common_name": "green",
"center_wavelength": 0.555,
"full_width_half_max": 0.07,
"solar_illumination": 1823.4
},
{
"name": "band-3",
"common_name": "red",
"center_wavelength": 0.66,
"full_width_half_max": 0.06,
"solar_illumination": 1536.38
},
{
"name": "band-4",
"common_name": "nir",
"center_wavelength": 0.83,
"full_width_half_max": 0.12,
"solar_illumination": 981.91
}
],
"cbers:path": 158,
"cbers:row": 133,
"sat:platform_international_designator": "2014-079A",
"proj:epsg": 32722,
"view:off_nadir": 0.0,
"view:sun_azimuth": 46.5463,
"view:sun_elevation": 43.1737,
"processing:level": "L4",
"providers": [
{
"name": "INPE/CAST",
"description": "The China-Brazil Earth Resources Satellite mission is to provide remote sensing images to observe and monitor vegetation - especially deforestation in the Amazon region - the monitoring of water resources, agriculture, urban growth, land use and education.",
"roles": [
"producer",
"processor",
"licensor"
],
"url": "http://www.cbers.inpe.br/sobre/cbers3-4.php"
}
],
"licence": "proprietary"
},
"bbox": [
-51.624,
-30.021,
-51.261,
-28.962
],
"assets": {
"compose": {
"type": "image/tiff",
"roles": [
"data",
"dn"
],
"title": "PAN10M L4 COMPOSE",
"href": "data/1003-INPE-CBERS-4-urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose/CBERS_4_PAN_20240404_158_133_L4__compose.tif",
"filename": "CBERS_4_PAN_20240404_158_133_L4__compose.tif",
"file:size": 0,
"eo:bands": [
{
"name": "band-2",
"common_name": "green",
"center_wavelength": 0.555,
"full_width_half_max": 0.07,
"solar_illumination": 1823.4
},
{
"name": "band-3",
"common_name": "red",
"center_wavelength": 0.66,
"full_width_half_max": 0.06,
"solar_illumination": 1536.38
},
{
"name": "band-4",
"common_name": "nir",
"center_wavelength": 0.83,
"full_width_half_max": 0.12,
"solar_illumination": 981.91
}
],
"raster:bands": [
{
"offset": 0.0
},
{
"offset": 0.0
},
{
"offset": 0.0
}
]
},
"metadata": {
"type": "text/csv",
"roles": [
"metadata"
],
"title": "Metadata file",
"href": "data/1003-INPE-CBERS-4-urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose/urn_ogc_def_eop_inpe_cbers_4_pan_20240404_158_133_l4__compose-metadata.csv",
"filename": "urn_ogc_def_eop_inpe_cbers_4_pan_20240404_158_133_l4__compose-metadata.csv",
"file:size": 534
},
"thumbnail": {
"type": "image/jpeg",
"roles": [
"thumbnail"
],
"href": "data/1003-INPE-CBERS-4-urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose/urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose-icon.jpg",
"filename": "urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose-icon.jpg",
"file:size": 6474
}
},
"links": []
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AGENCY,SATELLITE,INSTRUMENT,MODE,IDENTIFIER,START_DATE,COMPLETE_DATE,FOOTPRINT,PRODUCT_URL,AOI,FORMAT,PROCESSING_LEVEL,PROCESSING_LEVEL_DESCRIPTION,PROJECTION,EPSG,PATH,ROW,OFF_NADIR,SUN_AZIMUTH,SUN_ELEVATION,ABSOLUTE_CALIBRATION_COEFFICIENTS
INPE,CBERS4,PAN,,urn_ogc_def_EOP_INPE_CBERS_4_PAN_20240404_158_133_L4__compose,2024-04-04T13:16:10+0000,2024-04-04T13:16:28+0000," -28.962 -51.618 -28.964 -51.261 -30.021 -51.263 -30.02 -51.624 -28.962 -51.618 ",,,GeoTiff,L1B,,Geocoded,32722,158,133,0,46.5463,43.1737,band0:0 band1:0 band2:0
18 changes: 15 additions & 3 deletions src/Stars.Data/Model/Metadata/Inpe/InpeMetadataExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class InpeMetadataExtractor : MetadataExtraction
protected static string metadataAssetRegexPattern => @".*(CBERS_4|Call|CBERS_4A?|cbers_4|call|cbers_4A?|AMAZONIA_1|amazonia_1).*\.(xml|csv)$";
protected static string compositeAssetRegexPattern => @".*(CBERS_4|Call|CBERS_4A?|cbers_4|call|cbers_4A?|AMAZONIA_1|amazonia_1).*\.(tif|tiff)$";

private Regex identifierInfoRegex = new Regex(@".*(?'mode'awfi|mux|pan5m|pan10m|wfi|wpm)_\d{8}_\d{3}_\d{3}_l(?'level'[^_]+)_(?'rest'.*)$");
private Regex identifierInfoRegex = new Regex(@".*(?'mode'awfi|mux|pan|pan5m|pan10m|wfi|wpm)_\d{8}_\d{3}_\d{3}_l(?'level'[^_]+)_(?'rest'.*)$");

// Dictionary containing platform international designators
private Dictionary<string, string> platformInternationalDesignators = new Dictionary<string, string> {
Expand Down Expand Up @@ -87,6 +87,7 @@ public override bool CanProcess(IResource route, IDestination destination)
}
catch (Exception e)
{
Console.WriteLine("CAN NOT PROCESS: {0}\n{1}", e.Message, e.StackTrace);
return false;
}
}
Expand Down Expand Up @@ -256,8 +257,9 @@ protected virtual IAsset GetMetadataAsset(IItem item)

public virtual async Task<Schemas.Metadata> ReadMetadata(IAsset metadataAsset)
{
Match identifierMatch = identifierRegex.Match(Path.GetFileName(metadataAsset.Uri.OriginalString));
Match identifierMatch2 = identifierRegex2.Match(Path.GetFileName(metadataAsset.Uri.OriginalString).ToLower());
string originalAssetName = Path.GetFileName(metadataAsset.Uri.OriginalString);
Match identifierMatch = identifierRegex.Match(originalAssetName);
Match identifierMatch2 = identifierRegex2.Match(originalAssetName.ToLower());

string typeStr;
string level;
Expand All @@ -276,6 +278,11 @@ protected virtual IAsset GetMetadataAsset(IItem item)
throw new Exception("No metadata file found");
}

if (typeStr == "PAN")
{
if (originalAssetName.ToLower().Contains("_compose")) typeStr = "PAN10M";
else typeStr = "PAN5M";
}
switch (typeStr)
{
case "AWFI":
Expand Down Expand Up @@ -590,6 +597,11 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat
{
string mode = match.Groups["mode"].Value.ToUpper();
string rest = match.Groups["rest"].Value;
if (mode == "PAN")
{
if (rest.Contains("compose")) mode = "PAN10M";
else mode = "PAN5M";
}

if (metadata.satellite.name == "CBERS")
{
Expand Down

0 comments on commit 47a8f97

Please sign in to comment.