Skip to content

Commit

Permalink
Merge pull request #2398 from dtcenter/bugfix_2370_aeronetv3
Browse files Browse the repository at this point in the history
Bugfix 2370 aeronetv3
  • Loading branch information
hsoh-u authored Jan 10, 2023
2 parents 81739b0 + aad4de3 commit 1741cae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion scripts/utility/print_pointnc2ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def dump(self, out_handler, show_header=True, use_comma=False):
obs_val = [ f'{i:.0f}' for i in self.obs_val ]
else:
obs_precision = self.get_precision(self.obs_val)
obs_val = [ 'NA' if np.ma.is_masked(i) else
obs_val = [ 'NA' if np.ma.is_masked(i) or np.isnan(i) else
f'{i:.1f}' if abs((i*10)-int(i*10)) < 0.000001 else
f'{i:.1f}' if abs((i*10)-int(i*10)) > 0.999998 else
f'{i:.2f}' if abs((i*100)-int(i*100)) < 0.000001 else
Expand Down
30 changes: 18 additions & 12 deletions src/tools/other/ascii2nc/aeronet_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using namespace std;

#include "aeronet_handler.h"

static bool test_AOD_550 = false;
static const char *AERONET_NA_STR = "N/A";
static const char *AERONET_V3_STR = "AERONET Version 3";

Expand Down Expand Up @@ -436,15 +437,17 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
var_name = AOD_NAME;
double dheight = 550;
double aod_at_550 = angstrom_power_interplation(aod_at_675,aod_at_440,675.,440.,dheight);
_addObservations(Observation(header_type,
(sid_idx<0 ? _stationId : data_line[sid_idx]),
valid_time, _stationLat, _stationLon, _stationAlt,
na_str, var_id, bad_data_double, dheight,
aod_at_550,
var_name));
mlog << Debug(7) << method_name << " AOD at 550: "
<< aod_at_550 << "\t440: " << aod_at_440
<< "\t675: " << aod_at_675 << "\n";
if (!is_eq(aod_at_550, bad_data_double)) {
_addObservations(Observation(header_type,
(sid_idx<0 ? _stationId : data_line[sid_idx]),
valid_time, _stationLat, _stationLon, _stationAlt,
na_str, var_id, bad_data_double, dheight,
aod_at_550,
var_name));
mlog << Debug(7) << method_name << " AOD at 550: "
<< aod_at_550 << "\t440: " << aod_at_440
<< "\t675: " << aod_at_675 << "\n";
}
}
}
} // end while
Expand All @@ -455,7 +458,7 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
<< ascii_file.filename() << "\".\n\n";
}

if (format_version == 3) {
if (format_version == 3 && test_AOD_550) {
double aod_at_675, aod_at_440;
double aod_at_550_expected, aod_at_550;

Expand Down Expand Up @@ -785,8 +788,11 @@ string AeronetHandler::make_var_name_from_header(string hdr_field) {

double angstrom_power_interplation(double value_1, double value_2,
double level_1, double level_2, double target_level) {
double angstrom_log = -log10(value_1/value_2)/log10(level_1/level_2);
double angstrom_value = value_2 * pow((target_level/level_2),-angstrom_log);
double angstrom_value = bad_data_double;
if ((value_1*value_2) >=0 && (level_1*level_2) >=0) {
double angstrom_log = -log10(value_1/value_2)/log10(level_1/level_2);
angstrom_value = value_2 * pow((target_level/level_2),-angstrom_log);
}
return angstrom_value;
}

Expand Down

0 comments on commit 1741cae

Please sign in to comment.