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

SEADAS: Reprojection Tool Modifications #442

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
12839d8
Reproject Tool: added new features of masking and use of the valid-pi…
knowles May 11, 2022
dd87ed8
Merge branch 'SEADAS-Reproject' into SEADAS-Reproject-9.0.0-master
knowles May 18, 2022
87af4e1
Merge branch 'SEADAS-Reproject-9.0.0-pre' into SEADAS-Reproject-9.0.0
knowles Aug 17, 2022
cc5b3a6
Reproject: fixed xml load/save for GraphBuilder tool
knowles Aug 18, 2022
9a227ac
Added NSIDC reader functionality ... commit to s3tbx, snap-desktop, a…
knowles Aug 22, 2022
5982a54
Added changes to support the new Angular View tool
knowles Feb 2, 2023
0761a0a
Removed formatting changes which caused merged conflicts
knowles Mar 1, 2023
3231de2
Removed formatting changes which caused merged conflicts
knowles Mar 1, 2023
cf424ca
Merge branch 'SEADAS-angular-view-9.0.0' into SEADAS-angular-view-10.…
knowles May 16, 2023
5c11319
Merge branch 'SEADAS-NSIDC-9.0.0' into SEADAS-NSIDC-10.0.0-pre
knowles May 17, 2023
b587fe4
Merge: resolving conflicts to merge SEADAS code into SNAP
knowles May 17, 2023
71411dd
Merge branch 'SEADAS-reproject-10.0.0-pre' into SEADAS-reproject-10.0.0
knowles May 30, 2023
2d077a4
Merge branch 'SEADAS-angular-view-10.0.0-pre' into SEADAS-angular-vie…
knowles May 30, 2023
a0a87c2
Merge branch 'SEADAS-NSIDC-10.0.0-pre' into SEADAS-NSIDC-10.0.0
knowles May 30, 2023
6cd727c
Merge branch 'SEADAS-angular-view-10.0.0' into SEADAS-angular-view-10…
knowles Aug 30, 2023
a66ad5f
Merge branch 'SEADAS-reproject-10.0.0' into SEADAS-reproject-10.0.0-0…
knowles Aug 30, 2023
cd9b3dc
Merge branch 'SEADAS-NSIDC-10.0.0' into SEADAS-NSIDC-10.0.0-08-30-23
knowles Aug 30, 2023
d556cfb
resolving conflicts
knowles Aug 30, 2023
673cc9b
Added angularValue and angularBandIndex property copy to various tools
knowles Sep 10, 2023
8e9218c
Update subset tool to include 'derived from' in some of the metadata …
knowles Oct 11, 2023
32ef95f
Merge branch 'SEADAS-angular-NSIDC-10.0.0-08-30-23' into SEADAS-angul…
knowles Nov 20, 2023
398b734
Merge branch 'SEADAS-reproject-10.0.0-08-30-23' into SEADAS-reproject…
knowles Nov 20, 2023
e19ab70
Merge branch 'SEADAS-angular-NSIDC-10.0.0-11-20-23' into SEADAS-repro…
knowles Nov 20, 2023
055f943
Updated ProductUtils.java and StringUtils.java to match other branches
knowles Nov 20, 2023
823bba6
Merge branch 'SEADAS-angular-NSIDC-10.0.0-11-20-23' into SEADAS-angul…
knowles Jan 6, 2024
45275a9
Merge branch 'SEADAS-reproject-10.0.0-11-20-23' into SEADAS-reproject…
knowles Jan 6, 2024
151861e
temp edits to fix conflicts
knowles Jan 26, 2024
9b3ed56
Updated to support bindingContext used in seadas_reader
knowles Jan 27, 2024
6b410dd
Add transfer of valid pixel expression and no-data value to ProductFl…
knowles Mar 15, 2024
6fd1668
Merge branch 'SEADAS-angular-NSIDC-10.0.0-01-05-24' into SEADAS-angul…
knowles Apr 18, 2024
9b9caca
Merge branch 'SEADAS-reproject-10.0.0-01-05-24' into SEADAS-reproject…
knowles Apr 18, 2024
d143a11
Merge branch 'SEADAS-angular-NSIDC-11.0.0-04-18-24' into SEADAS-angul…
knowles Apr 30, 2024
603d7c2
Merge branch 'SEADAS-reproject-11.0.0-04-18-24' into SEADAS-reproject…
knowles Apr 30, 2024
5320cfc
Merge branch 'SEADAS-angular-NSIDC-11.0.0-04-30-24' into SEADAS-repro…
knowles May 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
* @version $Revision$ $Date$
* @since Ceres 0.6
*/
// MAR2020 - Daniel Knowles - Added setEnabled so that some properties can be initially enabled/disabled

public class BindingContext {

private final PropertySet propertySet;
Expand Down Expand Up @@ -478,6 +480,22 @@ private static void configureComponent(JComponent component, String name, String
component.setEnabled(enabled);
}


/**
* Sets the <i>enabled</i> state of the components associated with {@code targetProperty}.
* Enablement of the target property matches that of the source property.
*
* @param targetPropertyName The name of the target property.
* @param sourcePropertyName The name of the source property.
*/
public Enablement bindEnabledState(final String targetPropertyName,
final String sourcePropertyName) {
return bindEnabledState(targetPropertyName, true,
new EqualValuesCondition(sourcePropertyName, true));
}



/**
* Sets the <i>enabled</i> state of the components associated with {@code targetProperty}.
* If the current value of {@code sourceProperty} equals {@code sourcePropertyValue} then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ private void addBandsToProduct(Product product) {
}
destBand.setSpectralBandIndex(sourceBand.getSpectralBandIndex());
destBand.setSpectralWavelength(sourceBand.getSpectralWavelength());
destBand.setAngularValue(sourceBand.getAngularValue());
destBand.setAngularBandIndex(sourceBand.getAngularBandIndex());
destBand.setSpectralBandwidth(sourceBand.getSpectralBandwidth());
destBand.setValidPixelExpression(sourceBand.getValidPixelExpression());
destBand.setNoDataValueUsed(sourceBand.isNoDataValueUsed());
destBand.setNoDataValue(sourceBand.getNoDataValue());
destBand.setSolarFlux(sourceBand.getSolarFlux());
FlagCoding sourceFlagCoding = sourceBand.getFlagCoding();
IndexCoding sourceIndexCoding = sourceBand.getIndexCoding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ private static void updateMetadata(
totalSize.getData().setElemUInt(targetProduct.getRawStorageSize());
}


// ProductUtils.markProductMetaDataFieldAsDerivedFrom(targetProduct);


if (nearRangeOnLeft) {
setLatLongMetadata(targetProduct, trgAbsRoot, "first_near_lat", "first_near_long", 0.5f, 0.5f);
setLatLongMetadata(targetProduct, trgAbsRoot, "first_far_lat", "first_far_long",
Expand Down Expand Up @@ -534,6 +538,9 @@ private Product createProduct() {
if (!isMetadataIgnored()) {
ProductUtils.copyMetadata(sourceProduct, product);
}

ProductUtils.markProductMetaDataFieldAsDerivedFrom(product);

addTiePointGridsToProduct(product);
addBandsToProduct(product);
ProductUtils.copyMasks(sourceProduct, product);
Expand Down Expand Up @@ -668,6 +675,8 @@ protected void addBandsToProduct(Product product) {
destBand.setSpectralBandIndex(sourceBand.getSpectralBandIndex());
destBand.setSpectralWavelength(sourceBand.getSpectralWavelength());
destBand.setSpectralBandwidth(sourceBand.getSpectralBandwidth());
destBand.setAngularValue(sourceBand.getAngularValue());
destBand.setAngularBandIndex(sourceBand.getAngularBandIndex());
destBand.setSolarFlux(sourceBand.getSolarFlux());
if (sourceBand.isNoDataValueSet()) {
destBand.setNoDataValue(sourceBand.getNoDataValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ protected void writeImageInterpretationElements(int indent) {
printLine(indent + 2, DimapProductConstants.TAG_SPECTRAL_BAND_INDEX,
band.getSpectralBandIndex());
}
if (band.getAngularBandIndex() > -1) {
printLine(indent + 2, DimapProductConstants.TAG_ANGULAR_BAND_INDEX,
band.getAngularBandIndex());
}
printLine(indent + 2, DimapProductConstants.TAG_BAND_WAVELEN, band.getSpectralWavelength());
printLine(indent + 2, DimapProductConstants.TAG_BAND_ANGULAR_VALUE, band.getAngularValue());
printLine(indent + 2, DimapProductConstants.TAG_BANDWIDTH, band.getSpectralBandwidth());
final FlagCoding flagCoding = band.getFlagCoding();
if (flagCoding != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ public final class DimapProductConstants {
public static final String TAG_DATA_TYPE = "DATA_TYPE";
public static final String TAG_SOLAR_FLUX = "SOLAR_FLUX";
public static final String TAG_SPECTRAL_BAND_INDEX = "SPECTRAL_BAND_INDEX";
public static final String TAG_ANGULAR_BAND_INDEX = "ANGULAR_BAND_INDEX";
public static final String TAG_SOLAR_FLUX_UNIT = "SOLAR_FLUX_UNIT";
public static final String TAG_BANDWIDTH = "BANDWIDTH";
public static final String TAG_BAND_WAVELEN = "BAND_WAVELEN";
public static final String TAG_BAND_ANGULAR_VALUE = "BAND_ANGULAR_VALUE";
public static final String TAG_WAVELEN_UNIT = "WAVELEN_UNIT";
public static final String TAG_FLAG_CODING_NAME = "FLAG_CODING_NAME";
public static final String TAG_INDEX_CODING_NAME = "INDEX_CODING_NAME";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1644,8 +1644,10 @@ private static void setGeneralBandProperties(Band band, Element element, Product
setUnit(element, band);
setSpectralWaveLength(element, band);
setSpectralBandWidth(element, band);
setAngularValue(element, band);
setSolarFlux(element, band);
setSpectralBandIndex(element, band);
setAngularBandIndex(element, band);
setScaling(element, band);
setFlagCoding(element, band, product);
setIndexCoding(element, band, product);
Expand Down Expand Up @@ -1696,6 +1698,15 @@ private static void setSpectralBandIndex(final Element element, final Band band)
}
}

private static void setAngularBandIndex(final Element element, final Band band) {
final String angularBandIndex = element.getChildTextTrim(DimapProductConstants.TAG_ANGULAR_BAND_INDEX);
if (angularBandIndex != null) {
band.setAngularBandIndex(Integer.parseInt(angularBandIndex));
} else {
band.setAngularBandIndex(-1);
}
}

private static void setScaling(final Element element, final Band band) {
final String scalingFactorString = element.getChildTextTrim(DimapProductConstants.TAG_SCALING_FACTOR);
if (scalingFactorString != null) {
Expand Down Expand Up @@ -1828,6 +1839,14 @@ private static void setSpectralBandWidth(final Element element, final Band band)
}
}

private static void setAngularValue(final Element element, final Band band) {
final String angularValue = element.getChildTextTrim(DimapProductConstants.TAG_BAND_ANGULAR_VALUE);
if (angularValue != null) {
band.setAngularValue(Float.parseFloat(angularValue));
}
}


private void addCollectedAncillaryVariables() {
Set<Map.Entry<RasterDataNode, List<String>>> entries = ancillaryVariables.entrySet();
for (Map.Entry<RasterDataNode, List<String>> entry : entries) {
Expand Down
83 changes: 83 additions & 0 deletions snap-core/src/main/java/org/esa/snap/core/datamodel/Band.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,24 @@ public class Band extends AbstractBand {
public static final String PROPERTY_NAME_SPECTRAL_BAND_INDEX = "spectralBandIndex";
public static final String PROPERTY_NAME_SPECTRAL_BANDWIDTH = "spectralBandwidth";
public static final String PROPERTY_NAME_SPECTRAL_WAVELENGTH = "spectralWavelength";
public static final String PROPERTY_NAME_DATE_BAND_INDEX = "dateBandIndex";
public static final String PROPERTY_NAME_DATE = "date";
public static final String PROPERTY_NAME_ANGULAR_BAND_INDEX = "angularBandIndex";
public static final String PROPERTY_NAME_ANGULAR_VALUE = "angularValue";

/**
* If this band contains flag data, this is the flag coding.
*/
private SampleCoding sampleCoding;

private int angularBandIndex;
private float angularValue;
private int spectralBandIndex;
private float spectralWavelength;
private float spectralBandwidth;
private int dateBandIndex;
private String date;
// private float spectralBandwidth;
private float solarFlux;

/**
Expand All @@ -88,7 +97,9 @@ public Band(String name, int dataType, int width, int height) {
super(name, dataType, width, height);
// By default a band is not a spectral band,
// so spectral band index must be -1
setAngularBandIndex(-1);
setSpectralBandIndex(-1);
setDateBandIndex(-1);
setModified(false);
}

Expand Down Expand Up @@ -156,6 +167,30 @@ public void setSampleCoding(SampleCoding sampleCoding) {
}
}

public float getAngularValue() {
return angularValue;
}

public void setAngularValue(float angularValue) {
if (this.angularValue != angularValue) {
this.angularValue = angularValue;
fireProductNodeChanged(PROPERTY_NAME_ANGULAR_VALUE);
setModified(true);
}
}

public int getAngularBandIndex() {
return angularBandIndex;
}

public void setAngularBandIndex(int angularBandIndex) {
if (this.angularBandIndex != angularBandIndex) {
this.angularBandIndex = angularBandIndex;
fireProductNodeChanged(PROPERTY_NAME_ANGULAR_BAND_INDEX);
setModified(true);
}
}

/**
* Gets the (zero-based) spectral band index.
*
Expand Down Expand Up @@ -202,6 +237,52 @@ public void setSpectralWavelength(float spectralWavelength) {
}
}

/**
* Gets the (zero-based) date band index.
*
* @return the (zero-based) date band index or <code>-1</code> if it is unknown
*/
public int getDateBandIndex() {
return dateBandIndex;
}

/**
* Sets the (zero-based) date band index.
*
* @param dateBandIndex the (zero-based) spectral band index or <code>-1</code> if it is unknown
*/
public void setDateBandIndex(int dateBandIndex) {
if (this.dateBandIndex != dateBandIndex) {
this.dateBandIndex = dateBandIndex;
fireProductNodeChanged(PROPERTY_NAME_DATE_BAND_INDEX);
setModified(true);
}
}

/**
* Gets the date.
*
* @return the date for this band, or zero if this is not a date band or the date is
* not known.
*/
public String getDate() {
return date;
}

/**
* Sets the date.
*
* @param date YYYY-MM-DD of this band, or 1601-01-01 if this is not a date band or
* the date is not known.
*/
public void setDate(String date) {
if (this.date != date) {
this.date = date;
fireProductNodeChanged(PROPERTY_NAME_DATE);
setModified(true);
}
}

/**
* Gets the spectral bandwidth in <code>nm</code> (nanomater) units.
*
Expand Down Expand Up @@ -454,6 +535,8 @@ public String toString() {
+ ProductData.getTypeString(getDataType()) + "," +
+getRasterWidth() + "," +
+getRasterHeight() + "," +
+getAngularBandIndex() + "," +
+getAngularValue() + "," +
+getSpectralBandIndex() + "," +
+getSpectralWavelength() + "," +
+getSpectralBandwidth() + "," +
Expand Down
Loading