Skip to content

Commit

Permalink
#2493 Update lat/lon/elv when station_id (site_name) is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Mar 29, 2023
1 parent c200ee2 commit ef8d12a
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/tools/other/ascii2nc/aeronet_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
int var_idx, sid_idx, elv_idx, lat_idx, lon_idx, date_idx, month_idx;
double height_from_header;
string aot = "AOT";
//string angstrom = "Angstrom";
string var_name;
string prev_sid, cur_sid;
StringArray hdr_names;
NumArray header_heights;
IntArray header_var_index;
Expand Down Expand Up @@ -286,6 +286,7 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
//
int bad_line_count = 0;
bool first_line = true;
bool update_lat_lon;
data_line.set_delimiter(",");
while (ascii_file >> data_line)
{
Expand Down Expand Up @@ -322,6 +323,8 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
}
}

cur_sid = (sid_idx < 0) ? _stationId : data_line[sid_idx];
update_lat_lon = (cur_sid.compare(prev_sid) != 0);
if (first_line) {
if (format_version == 3) {
// Get the stationId
Expand Down Expand Up @@ -352,22 +355,28 @@ bool AeronetHandler::_readObservations(LineDataFile &ascii_file)
break;
}
}

// Get the stationLat
_stationLat = atof(data_line[lat_idx]);
// Get the stationLon
_stationLon = atof(data_line[lon_idx]);
// Get the stationAlt
if (elv_idx >= 0) _stationAlt = atof(data_line[elv_idx]);
else _stationAlt = bad_data_float;

mlog << Debug(7) << "\n" << method_name << "stationID: "
<< ((sid_idx < 0) ? _stationId : data_line[sid_idx]) << " from index " << sid_idx
<< " lat: " << _stationLat
<< " lon: " << _stationLon
<< " elv: " << _stationAlt << " from index " << elv_idx << "\n";
mlog << Debug(7) << method_name << "station_idx=" << sid_idx
<< " elv_idx=" << elv_idx << "\n";
first_line = false;
}
first_line = false;
}

if (update_lat_lon) {
prev_sid = cur_sid;

// Get the stationLat
_stationLat = atof(data_line[lat_idx]);
// Get the stationLon
_stationLon = atof(data_line[lon_idx]);
// Get the stationAlt
if (elv_idx >= 0) _stationAlt = atof(data_line[elv_idx]);
else _stationAlt = bad_data_float;

mlog << Debug(7) << "\n" << method_name
<< "stationID: " << cur_sid << " lat: " << _stationLat
<< " lon: " << _stationLon << " elv: " << _stationAlt
<< "\n";
update_lat_lon = false;
}
//
// Pull the valid time from the data line
Expand Down

0 comments on commit ef8d12a

Please sign in to comment.