Skip to content

Commit

Permalink
debug lat and lon
Browse files Browse the repository at this point in the history
  • Loading branch information
apchoiCMD committed Oct 16, 2024
1 parent ee45e80 commit ada23d5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 37 deletions.
40 changes: 28 additions & 12 deletions utils/obsproc/IcecAbi2Ioda.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <complex>
#include <ctime>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -56,10 +57,26 @@ namespace gdasapp {

// Read in GOES ABI fixed grid projection variables and constants
std::vector<double> y_coordinate_1d(dimySize);
ncFile.getVar("y").getVar(y_coordinate_1d.data()); // N-S elevation angle in radians
ncFile.getVar("y").getVar(y_coordinate_1d.data());
float yOffSet;
ncFile.getVar("y").getAtt("add_offset").getValues(&yOffSet);
float yScaleFactor;
ncFile.getVar("y").getAtt("scale_factor").getValues(&yScaleFactor);
// Apply the scale factor and add offset to the raw data
for (auto& yval : y_coordinate_1d) {
yval = yval * yScaleFactor + yOffSet; // N-S elevation angle in radians
}

std::vector<double> x_coordinate_1d(dimxSize);
ncFile.getVar("x").getVar(x_coordinate_1d.data()); // E-W scanning angle in radians
ncFile.getVar("x").getVar(x_coordinate_1d.data());
float xOffSet;
ncFile.getVar("x").getAtt("add_offset").getValues(&xOffSet);
float xScaleFactor;
ncFile.getVar("x").getAtt("scale_factor").getValues(&xScaleFactor);
// Apply the scale factor and add offset to the raw data
for (auto& xval : x_coordinate_1d) {
xval = xval * xScaleFactor + xOffSet; // E-W scanning angle in radians
}

// Create 2D arrays (meshgrid equivalent)
std::vector<std::vector<double>> x_coordinate_2d(dimySize, std::vector<double>(dimxSize));
Expand All @@ -69,10 +86,10 @@ namespace gdasapp {

// Create 2D coordinate matrices from 1D coordinate vectors
for (int i = 0; i < dimySize; ++i) {
for (int j = 0; j < dimxSize; ++j) {
x_coordinate_2d[i][j] = x_coordinate_1d[j];
y_coordinate_2d[i][j] = y_coordinate_1d[i];
}
for (int j = 0; j < dimxSize; ++j) {
x_coordinate_2d[i][j] = x_coordinate_1d[j];
y_coordinate_2d[i][j] = y_coordinate_1d[i];
}
}

// Retrieve the attributes
Expand All @@ -87,12 +104,11 @@ namespace gdasapp {
double r_pol;
ncFile.getVar("goes_imager_projection").getAtt("semi_minor_axis").getValues(&r_pol);

// Calculate Latitude and Longitude from GOES Imager Projection
// for details of calculations in util.h

// Calculate H = Satellite height from center of earth(m)
double H = perspective_point_height + r_eq;

// Calculate Latitude and Longitude from GOES Imager Projection
// for details of calculations in util.h
gdasapp::obsproc::utils::calculate_degrees(
x_coordinate_2d,
y_coordinate_2d,
Expand All @@ -103,12 +119,12 @@ namespace gdasapp {
abi_lat,
abi_lon);

// Store lat and lon into eigen arrays
// Store real number of lat and lon into eigen arrays
int loc(0);
for (int i = 0; i < dimySize; i++) {
for (int j = 0; j < dimxSize; j++) {
iodaVars.longitude_(loc) = abi_lon[i][j];
iodaVars.latitude_(loc) = abi_lat[i][j];
iodaVars.longitude_(loc) = std::real(abi_lon[i][j]);
iodaVars.latitude_(loc) = std::real(abi_lat[i][j]);
loc += 1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions utils/obsproc/applications/gdas_obsprovider2ioda.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ namespace gdasapp {
} else if (provider == "SMOS") {
Smos2Ioda conv2ioda(fullConfig, this->getComm());
conv2ioda.writeToIoda();
} else if (provider == "AMSR2") {
IcecAmsr2Ioda conv2ioda(fullConfig, this->getComm());
conv2ioda.writeToIoda();
} else if (provider == "ABI") {
IcecAbi2Ioda conv2ioda(fullConfig, this->getComm());
conv2ioda.writeToIoda();
} else if (provider == "AMSR2") {
IcecAmsr2Ioda conv2ioda(fullConfig, this->getComm());
conv2ioda.writeToIoda();
} else if (provider == "MIRS") {
IcecMirs2Ioda conv2ioda(fullConfig, this->getComm());
conv2ioda.writeToIoda();
Expand Down
3 changes: 1 addition & 2 deletions utils/obsproc/util.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include <cmath>
#include <iostream>
#include <limits> // For quiet_NAN()
#include <limits>
#include <map>
#include <netcdf> // NOLINT (using C API)
#include <string>
Expand Down
17 changes: 10 additions & 7 deletions utils/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ list( APPEND utils_test_input
testinput/gdas_rtofssal.yaml
testinput/gdas_smap2ioda.yaml
testinput/gdas_smos2ioda.yaml
testinput/gdas_icecabi2ioda.yaml
testinput/gdas_icecamsr2ioda.yaml
testinput/gdas_icecmirs2ioda.yaml
testinput/gdas_icecjpssrr2ioda.yaml
Expand All @@ -20,6 +21,7 @@ set( gdas_utils_test_ref
testref/rads2ioda.test
testref/smap2ioda.test
testref/smos2ioda.test
testref/icecabi2ioda.test
testref/icecamsr2ioda.test
testref/icecmirs2ioda.test
testref/icecjpssrr2ioda.test
Expand Down Expand Up @@ -143,6 +145,13 @@ ecbuild_add_test( TARGET test_gdasapp_util_viirsaod2ioda
LIBS gdas-utils
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obsproc)

# Test the ABI to IODA converter
ecbuild_add_test( TARGET test_gdasapp_util_icecabi2ioda
COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_obsprovider2ioda.x
ARGS "../testinput/gdas_icecabi2ioda.yaml"
LIBS gdas-utils
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obsproc)

# Test the AMSR2 to IODA converter
ecbuild_add_test( TARGET test_gdasapp_util_icecamsr2ioda
COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_obsprovider2ioda.x
Expand All @@ -157,15 +166,9 @@ ecbuild_add_test( TARGET test_gdasapp_util_icecmirs2ioda
LIBS gdas-utils
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obsproc)

# Test the JPSSRR to IODA converter
# Test the JPSSRR to IODA converter
ecbuild_add_test( TARGET test_gdasapp_util_icecjpssrr2ioda
COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_obsprovider2ioda.x
ARGS "../testinput/gdas_icecjpssrr2ioda.yaml"
LIBS gdas-utils
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obsproc)
# Test the ABI to IODA converter
ecbuild_add_test( TARGET test_gdasapp_util_icecabi2ioda
COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_obsprovider2ioda.x
ARGS "../testinput/gdas_icecabi2ioda.yaml"
LIBS gdas-utils
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obsproc)
2 changes: 2 additions & 0 deletions utils/test/prepdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ project_source_dir=$1

cdl2nc4 rads_adt_3a_2021181.nc4 ${project_source_dir}/testdata/rads_adt_3a_2021181.cdl
cdl2nc4 rads_adt_3b_2021181.nc4 ${project_source_dir}/testdata/rads_adt_3b_2021181.cdl
cdl2nc4 icec_abi_g16_1.nc4 ${project_source_dir}/testdata/icec_abi_g16_1.cdl
cdl2nc4 icec_abi_g16_2.nc4 ${project_source_dir}/testdata/icec_abi_g16_2.cdl
cdl2nc4 icec_amsr2_north_1.nc4 ${project_source_dir}/testdata/icec_amsr2_north_1.cdl
cdl2nc4 icec_amsr2_north_2.nc4 ${project_source_dir}/testdata/icec_amsr2_north_2.cdl
cdl2nc4 icec_amsr2_south_1.nc4 ${project_source_dir}/testdata/icec_amsr2_south_1.cdl
Expand Down
26 changes: 13 additions & 13 deletions utils/test/testref/icecabi2ioda.test
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
Reading: [icec_abi_g16_1.nc4,icec_abi_g16_2.nc4]
seconds since 2000-01-01T12:00:00Z
obsVal:
Min: 0.805632
Max: 0.917733
Sum: 1.72336
Min: 0.568351
Max: 0.999635
Sum: 122.002
obsError:
Min: 0.1
Max: 0.1
Sum: 0.2
Sum: 13.5
preQc:
Min: 0
Max: 0
Sum: 0
Max: 1
Sum: 5
longitude:
Min: -140.249
Max: -108.83
Sum: -249.079
Min: -79.8731
Max: -59.9008
Sum: -9898.07
latitude:
Min: -55.3118
Max: -47.5932
Sum: -102.905
Min: 67.1378
Max: 70.7751
Sum: 9242.36
datetime:
Min: 771919506
Max: 771930306
Sum: 1543849812
Sum: 104209597710

0 comments on commit ada23d5

Please sign in to comment.