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

Bugfix 2383 aeronetv3 (main_v11.0) #2394

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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