nasa-nccs-hpda / srlite

surface reflectance
0 stars 1 forks source link

Generalize CSV logic to handle non-standard ([B,G,R,N]) band ordering #23

Open gtamkin opened 4 months ago

gtamkin commented 4 months ago

The code below assumes a certain band order, which doesn't work if we only have 1, 2, or 3 bands (OR the bands are in a different order). It only works if 4 and 8 band processing is requested. Need to identify the indices for each band type instead of assuming index 0-4 for [B,G,R,N].

-------------------------------------------------------------------------

# calculateStatistics()
#
# Calculate statistics for each band, assuming a specific band ordering.
# First four bands are constant [B,G,R,N].  When 8Band processing in effect, four
# synthetic bands are appended to the list [C,Y,RE,N2]
# -------------------------------------------------------------------------
def calculateStatistics(self, context):

    # Get coefficients for standard 4-Bands
    sr_metrics_list = context[Context.METRICS_LIST]
    model = context[Context.REGRESSION_MODEL]

    # Correction coefficients for simulated bands
    yellowGreenCorr = 0.473
    yellowRedCorr = 0.527
    rededgeRedCorr = 0.621
    rededgeNIR1Corr = 0.379

    # Retrieve slope, intercept, and score coefficients for data-driven bands
    blueSlope = sr_metrics_list['slope']**[0]**
    blueIntercept = sr_metrics_list['intercept']**[0]**

    greenSlope = sr_metrics_list['slope'][1]
    greenIntercept = sr_metrics_list['intercept'][1]

    redSlope = sr_metrics_list['slope'][2]
    redIntercept = sr_metrics_list['intercept'][2]

    NIR1Slope = sr_metrics_list['slope'][3]
    NIR1Intercept = sr_metrics_list['intercept'][3]