Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solar Terminator #404

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Solar Terminator #404

wants to merge 28 commits into from

Conversation

belentorrente
Copy link
Collaborator

This MR introduces the CDataPostProcessor that calculates the Solar Terminator, which will assign one of five standard categories to a pixel (day, night, astronomical twilight, nautical twilight, and civil twilight) based on the solar zenith angle. Three test cases have been added.

The solar terminator algorithm itself is based on a book (Astronomical Algorithms, by Jean Meeus) that provides an approximation. An old scan of the book is available here, if you're interested.

More considerations:

  • The generic liveupdate layer has been left untouched, meaning that if a liveupdate with no post processors, it will go the pre-existing route, creating an image with the timestamp.
  • For this reason, at this point, the presence of a data post processor is the discriminator between a generic liveupdate, and a custom one (like the SolarTerminator).
  • I attempted to try and make something smart, like a virtual or temp file that is created when reading the config of the layer. Unfortunately, I haven't managed to make it work, as I was getting segmentation faults in numerous places in the code such as CDataWriter::addData, so I have discarded this idea (for now). So for now, and empty netCDF file is used. Another problem is that the units in the legend depend on this and I could not find the way of overwriting this in the data post processor.

@belentorrente belentorrente changed the base branch from master to store-layer-metadata September 23, 2024 10:57
@belentorrente belentorrente changed the base branch from store-layer-metadata to master September 24, 2024 13:32
printf("%s%c%c\n", "Content-Type:image/png", 13, 10);
image.printImagePng8(true);
CDBDebug("in special liveupdate case with timesteps %d", dataSources[j]->getNumTimeSteps());
if (dataSources[j]->cfgLayer->DataPostProc.empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you place this code inside layerTypeLiveUpdateRenderIntoDrawImage? We are trying to make CRequest.cpp a bit smaller

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added some aux functions within the LayerTypeLiveUpdate to deal with the case of the Solar Terminator

@@ -289,7 +289,9 @@ int storeLayerStyleListIntoMetadataDb(MetadataLayer *metadataLayer) {
}

int loadLayerStyleListFromMetadataDb(MetadataLayer *metadataLayer) {
if (metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeCascaded || metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeLiveUpdate) {
CDBWarning("loadLayerStyleListFromMetadataDb start");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed

@@ -215,7 +215,8 @@ int CXMLGen::getWMS_1_1_1_Capabilities(CT::string *XMLDoc, std::vector<MetadataL
addErrorInXMLForMisconfiguredLayer(XMLDoc, layer);
}
if (layer->hasError == 0) {
XMLDoc->printconcat("<Layer queryable=\"%d\" opaque=\"1\" cascaded=\"%d\">\n", layer->layerMetadata.isQueryable, layer->dataSource->dLayerType == CConfigReaderLayerTypeCascaded ? 1 : 0);
XMLDoc->printconcat("<Layer queryable=\"%d\" opaque=\"1\" cascaded=\"%d\">\n", layer->layerMetadata.isQueryable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to derive isQueryable in the layerMetadata section? Then other code can rely on the same checks too.

</Style>

<Configuration>
<Layer type="liveupdate">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A layer should have a Name element

</Style>

<Layer type="liveupdate">
<FilePath filter="" gfi_openall="true">{ADAGUC_PATH}data/datasets/solt.nc</FilePath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a Name element


</Style>

<Layer type="liveupdate">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a Name element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants