Skip to content

Commit

Permalink
switched units from conc to chla, in report and dn to ci coversion
Browse files Browse the repository at this point in the history
  • Loading branch information
deronsmith committed Jun 6, 2024
1 parent 609f5d2 commit 5a0a7d2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion flaskr/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def calculate_extent(data: pd.DataFrame, detect_columns: list, all_columns: list


def calculate_chla(ci):
return 6620.0 * ci
return np.round(6620.0 * ci, 2)


def calculate_magnitude(data: pd.DataFrame, detect_columns: list, all_columns: list):
Expand Down
6 changes: 3 additions & 3 deletions flaskr/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
REFERENCES_PATH = os.path.join(Path(os.path.abspath(__file__)).parent.parent, "templates", "references.txt")
DEBUG = False

VERSION = "v0.1.1"
VERSION = "v0.1.3"
KEEP_PROPERTIES = {
"OBJECTID": ["Object ID", int],
"GNIS_ID": ["GNIS ID", str],
Expand Down Expand Up @@ -808,7 +808,7 @@ def get_waterbody_histogram(data, report_root, objectid: int, day: int, year: in
std_n += c
std_actual = int(np.sqrt((1 / std_n) * std_term)) if std_n > 0 else 0
std_con = convert_dn(std_actual)
day_metrics_names = ["Min (cells/mL)", "Max (cells/mL)", "Average (cells/mL)", "Standard Deviation (cells/mL)"]
day_metrics_names = ["Min (chla)", "Max (chla)", "Average (chla)", "Standard Deviation (chla)"]
day_metrics_values = [round(min_con, 2), round(max_con, 2), round(mean_con, 2), round(std_con, 2)]
range_blocks_x = {
"low": cell_ranges[ranges[0][0]:ranges[0][1]],
Expand Down Expand Up @@ -867,7 +867,7 @@ def get_waterbody_histogram(data, report_root, objectid: int, day: int, year: in
cells=dict(values=day_metrics_values, align='center', font=dict(size=18), height=30)), row=2, col=1
)
current_fig.update_layout(**layout, yaxis_title="Pixel Count",
title={"text": "Cell Concentration Histogram (cell/mL)",
title={"text": "Number of Chlorophyll a Histogram (chla)",
'y': 0.9, 'x': 0.5,
'xanchor': 'center', 'yanchor': 'top'}, )
current_fig.update_xaxes(tickvals=x_tick_value, ticktext=x_tick_text)
Expand Down
5 changes: 3 additions & 2 deletions flaskr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def p_get_geometry_bounds(objectid, day, year):
return values


def convert_dn(dn, round=2):
def convert_dn(dn, round=2, to_chla=True):
if type(dn) == int or type(dn) == np.int64:
np.int_(64)
if dn == 0:
Expand All @@ -136,9 +136,10 @@ def convert_dn(dn, round=2):
if np.max(dn) > 255:
print(f"DN value greater than acceptable max, dn: {np.max(dn)}")
cell_con = np.around(np.power(10, (3 / 250) * dn - 4.2) * 10 ** 8, round)
if to_chla:
return np.round(6620.0 * cell_con, 2)
return cell_con


def convert_cc(cell_concentration):
if cell_concentration < 6000:
return cell_concentration
Expand Down
Binary file added static/CyANColorbar2024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions templates/report_2_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ <h3 class="h3-title">Legends</h3>
<tr>
<td class="descript-left">
<div class="legend-title">OLCI Satellite Raster Legend</div>
<img src="{{STATIC_ROOT}}legend.png" class="waterbody-raster-legend" alt="Satellite data legend">
<!-- <img src="{{STATIC_ROOT}}legend.png" class="waterbody-raster-legend" alt="Satellite data legend">-->
<img src="{{STATIC_ROOT}}CyANColorbar2024.png" class="waterbody-raster-legend" alt="CyAN Colorbar">

</td>
<td class="descript-right">
<div class="legend-description">
Expand Down Expand Up @@ -73,9 +75,9 @@ <h3 class="h3-title">Legends</h3>
<tr class="dn-table-header dn-labels">
<td class="dn-border"></td>
<td><b>DN</b></td>
<td class="dn-border"><b>Cell Concentration (cell/mL)</b></td>
<td class="dn-border"><b>Number of Chlorophyll a (Chla)</b></td>
<td><b>DN</b></td>
<td><b>Cell Concentration (cell/mL)</b></td>
<td><b>Number of Chlorophyll a (Chla)</b></td>
</tr>
{% for level, values in CONVERSION_TABLE.items() %}
<tr class="dn-table-row">
Expand Down

0 comments on commit 5a0a7d2

Please sign in to comment.