From aa340bc685ced839b8b4b3c981310925f8ab60b0 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 8 Sep 2022 09:53:32 +0800 Subject: [PATCH 01/41] Do not fix the render axes to direction axes --- src/ImageData/FileLoader.cc | 10 ++++++---- src/ImageData/FileLoader.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 3d76b5862..210e6ecba 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -275,7 +275,7 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, int& spectral_ax return true; } -std::vector FileLoader::GetRenderAxes() { +std::vector FileLoader::GetRenderAxes(bool use_dir_axes) { // Determine which axes will be rendered std::vector axes; @@ -290,9 +290,11 @@ std::vector FileLoader::GetRenderAxes() { if (_image_shape.size() > 2) { // Normally, use direction axes if (_coord_sys->hasDirectionCoordinate()) { - casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); - axes[0] = dir_axes[0]; - axes[1] = dir_axes[1]; + if (use_dir_axes) { // Use direction axes as render axes if any + casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); + axes[0] = dir_axes[0]; + axes[1] = dir_axes[1]; + } } else if (_coord_sys->hasLinearCoordinate()) { // Check for PV image: [Linear, Spectral] axes // Returns -1 if no spectral axis diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index 6b62e7e03..a06c04329 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -79,7 +79,7 @@ class FileLoader { casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); bool FindCoordinateAxes(casacore::IPosition& shape, int& spectral_axis, int& z_axis, int& stokes_axis, std::string& message); - std::vector GetRenderAxes(); // Determine axes used for image raster data + std::vector GetRenderAxes(bool use_dir_axes = false); // Determine axes used for image raster data // Slice image data (with mask applied) bool GetSlice(casacore::Array& data, const StokesSlicer& stokes_slicer); From bcebbc3cc8397e6fa8283a0d6f3bd2c817f4ca30 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 8 Sep 2022 10:19:38 +0800 Subject: [PATCH 02/41] Modify the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8e1bca8..dbe951ae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Added a check of averaging width when calculating line/polyline spatial profiles or PV images ([#1174](https://github.com/CARTAvis/carta-backend/issues/1174)). +* Supported loading swapped-axes image cubes ([#1178](https://github.com/CARTAvis/carta-backend/issues/1178)). ### Fixed * Fixed issues with AIPS velocity axis by restoring previous casacore headers ([#1771](https://github.com/CARTAvis/carta-frontend/issues/1771)). From fcf9c3366ea3d594a7f96438f13295eaccbe9491 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Sun, 11 Sep 2022 01:23:03 +0800 Subject: [PATCH 03/41] Add axes numbers for Ra, Dec, Spectral and Stokes in the file info --- src/FileList/FileExtInfoLoader.cc | 47 +++++++++++++++++++-------- src/FileList/FileExtInfoLoader.h | 4 +-- src/Frame/Frame.cc | 2 +- src/Frame/Frame.h | 1 + src/ImageData/FileLoader.cc | 11 ++++++- src/ImageData/FileLoader.h | 5 ++- src/ImageData/StokesFilesConnector.cc | 6 ++-- 7 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 5cba40365..608151002 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -196,11 +196,12 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ AddDataTypeEntry(extended_info, data_type); + std::vector direction_axes; int spectral_axis, depth_axis, stokes_axis; - if (_loader->FindCoordinateAxes(image_shape, spectral_axis, depth_axis, stokes_axis, message)) { + if (_loader->FindCoordinateAxes(image_shape, direction_axes, spectral_axis, stokes_axis, depth_axis, message)) { // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis std::vector render_axes = _loader->GetRenderAxes(); - AddShapeEntries(extended_info, image_shape, spectral_axis, depth_axis, stokes_axis, render_axes); + AddShapeEntries(extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); info_ok = true; } @@ -593,7 +594,8 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: // Use header entries to determine computed entries casacore::IPosition shape; - int chan_axis(-1), depth_axis(-1), stokes_axis(-1); + std::vector direction_axes(2, -1); + int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); std::vector spectral_ctypes = {"ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA"}; casacore::DataType data_type(casacore::DataType::TpFloat); @@ -622,14 +624,19 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: auto entry_value = header_entry.value(); std::transform(entry_value.begin(), entry_value.end(), entry_value.begin(), [](unsigned char c) { return std::toupper(c); }); - if (entry_value == "STOKES") { + if (entry_value.find("RA") == 0) { + direction_axes[0] = axis_num; + } else if (entry_value.find("DEC") == 0) { + direction_axes[1] = axis_num; + } else if (entry_value == "STOKES") { stokes_axis = axis_num; } else if ((entry_value.find("FREQ") == 0) || (entry_value.find("WAV") != std::string::npos) || (std::find(spectral_ctypes.begin(), spectral_ctypes.end(), entry_value) != spectral_ctypes.end())) { - chan_axis = axis_num; - if (chan_axis > 1) { - depth_axis = chan_axis; - } + spectral_axis = axis_num; + } + + if (axis_num == 2) { // Default depth axis is the third axis from the file header + depth_axis = spectral_axis; } } else if (entry_name.find("BITPIX") == 0) { auto value = header_entry.value(); @@ -643,7 +650,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: } AddDataTypeEntry(extended_info, data_type); - AddShapeEntries(extended_info, shape, chan_axis, depth_axis, stokes_axis, render_axes); + AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); if (compressed_fits) { compressed_fits->SetShape(shape); @@ -665,8 +672,8 @@ void FileExtInfoLoader::AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, entry->set_entry_type(CARTA::EntryType::STRING); } -void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, int chan_axis, - int depth_axis, int stokes_axis, const std::vector& render_axes) { +void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, + const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis) { // Set fields/header entries for shape: dimensions, width, height, depth, stokes int num_dims(shape.size()); int width(shape(render_axes[0])); @@ -698,9 +705,23 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, shape_entry->set_value(shape_string); shape_entry->set_entry_type(CARTA::EntryType::STRING); - if (chan_axis >= 0) { + // Fill axes numbers info + std::string axes_numbers = + fmt::format("[{}, {}, {}, {}] (Ra, Dec, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); + size_t start_pos = 0; + std::string from("-1"), to("NA"); + while (((start_pos = axes_numbers.find(from, start_pos)) != std::string::npos) && (start_pos < axes_numbers.length())) { + axes_numbers.replace(start_pos, from.length(), to); + start_pos += to.length(); + } + auto* axes_numbers_entry = extended_info.add_computed_entries(); + axes_numbers_entry->set_name("Axes numbers"); + axes_numbers_entry->set_value(axes_numbers); + axes_numbers_entry->set_entry_type(CARTA::EntryType::STRING); + + if (depth_axis >= 0) { // header entry for number of channels - unsigned int nchan = shape(chan_axis); + unsigned int nchan = shape(depth_axis); auto entry = extended_info.add_computed_entries(); entry->set_name("Number of channels"); entry->set_value(std::to_string(nchan)); diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index a02892736..3b2c3ef01 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -50,8 +50,8 @@ class FileExtInfoLoader { // Computed entries void AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, casacore::DataType data_type); - void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, int chan_axis, int depth_axis, - int stokes_axis, const std::vector& render_axes); + void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& direction_axes, + int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis); void AddInitialComputedEntries(const std::string& hdu, CARTA::FileInfoExtended& extended_info, const std::string& filename, const std::vector& render_axes, CompressedFits* compressed_fits = nullptr); void AddComputedEntries(CARTA::FileInfoExtended& extended_info, casacore::ImageInterface* image, diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc index 22a261e1a..d2e9ff893 100644 --- a/src/Frame/Frame.cc +++ b/src/Frame/Frame.cc @@ -67,7 +67,7 @@ Frame::Frame(uint32_t session_id, std::shared_ptr loader, const std: // Get shape and axis values from the loader std::string log_message; - if (!_loader->FindCoordinateAxes(_image_shape, _spectral_axis, _z_axis, _stokes_axis, log_message)) { + if (!_loader->FindCoordinateAxes(_image_shape, _direction_axes, _spectral_axis, _stokes_axis, _z_axis, log_message)) { _open_image_error = fmt::format("Cannot determine file shape. {}", log_message); spdlog::error("Session {}: {}", session_id, _open_image_error); _valid = false; diff --git a/src/Frame/Frame.h b/src/Frame/Frame.h index 8ce3f1104..baf46ec02 100644 --- a/src/Frame/Frame.h +++ b/src/Frame/Frame.h @@ -281,6 +281,7 @@ class Frame { // Shape and axis info: X, Y, Z, Stokes casacore::IPosition _image_shape; int _x_axis, _y_axis, _z_axis, _spectral_axis, _stokes_axis; + std::vector _direction_axes; int _z_index, _stokes_index; // current index size_t _width, _height, _depth, _num_stokes; diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 210e6ecba..ebfdebddd 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -168,9 +168,11 @@ std::shared_ptr FileLoader::GetCoordinateSystem(cons return std::make_shared(); } -bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, int& spectral_axis, int& z_axis, int& stokes_axis, std::string& message) { +bool FileLoader::FindCoordinateAxes( + casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, int& z_axis, std::string& message) { // Return image shape and axes for image. Spectral axis may or may not be z axis. // All parameters are return values. + direction_axes.assign(2, -1); spectral_axis = -1; z_axis = -1; stokes_axis = -1; @@ -200,6 +202,13 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, int& spectral_ax _height = shape(render_axes[1]); _image_plane_size = _width * _height; + // Find direction axes + if (_coord_sys->hasDirectionCoordinate()) { + auto tmp_axes = _coord_sys->directionAxesNumbers(); + direction_axes[0] = tmp_axes[0]; + direction_axes[1] = tmp_axes[1]; + } + // Spectral and stokes axis spectral_axis = _coord_sys->spectralAxisNumber(); stokes_axis = _coord_sys->polarizationAxisNumber(); diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index a06c04329..69096eff5 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -23,8 +23,6 @@ namespace carta { -class Frame; - struct StokesSlicer { StokesSource stokes_source; casacore::Slicer slicer; @@ -78,7 +76,8 @@ class FileLoader { // Image shape and coordinate system axes casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); - bool FindCoordinateAxes(casacore::IPosition& shape, int& spectral_axis, int& z_axis, int& stokes_axis, std::string& message); + bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, int& z_axis, + std::string& message); std::vector GetRenderAxes(bool use_dir_axes = false); // Determine axes used for image raster data // Slice image data (with mask applied) diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc index 19431dff0..f5eb8f761 100644 --- a/src/ImageData/StokesFilesConnector.cc +++ b/src/ImageData/StokesFilesConnector.cc @@ -300,6 +300,7 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) } casacore::IPosition ref_shape(0); + std::vector ref_direction_axes; int ref_spectral_axis = -1; int ref_z_axis = -1; int ref_stokes_axis = -1; @@ -307,13 +308,14 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) for (auto& loader : _loaders) { casacore::IPosition shape; + std::vector direction_axes; int spectral_axis; int z_axis; if (ref_index == 0) { - loader.second->FindCoordinateAxes(ref_shape, ref_spectral_axis, ref_z_axis, ref_stokes_axis, err); + loader.second->FindCoordinateAxes(ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_z_axis, err); } else { - loader.second->FindCoordinateAxes(shape, spectral_axis, z_axis, stokes_axis, err); + loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, z_axis, err); if ((ref_shape.nelements() != shape.nelements()) || (ref_shape != shape) || (ref_spectral_axis != spectral_axis) || (ref_stokes_axis != stokes_axis)) { err = "Image shapes or axes are not consistent!"; From 70a10bfe2ca5109e9e8d16cca38ec65e35f9cf87 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Sun, 11 Sep 2022 01:57:34 +0800 Subject: [PATCH 04/41] Add axes numbers in the file info extended message --- carta-protobuf | 2 +- src/FileList/FileExtInfoLoader.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index 9395fe4ef..27b936c19 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit 9395fe4efdef6631174d878760d7d5eef17934a4 +Subproject commit 27b936c1953d931c60501c1da040d32763005011 diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 608151002..82c2b73fb 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -687,6 +687,14 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, extended_info.set_depth(depth); extended_info.set_stokes(stokes); + auto* axes_numbers_info = extended_info.mutable_axes_numbers(); + if (direction_axes.size() == 2) { + axes_numbers_info->add_directions(direction_axes[0]); + axes_numbers_info->add_directions(direction_axes[1]); + } + axes_numbers_info->set_spectral(spectral_axis); + axes_numbers_info->set_stokes(stokes_axis); + // shape computed_entry std::string shape_string; switch (num_dims) { From a6c5dc161c154a32a90316130a5bf34bce31ae3c Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 13 Sep 2022 00:38:19 +0800 Subject: [PATCH 05/41] A minor code change --- src/FileList/FileExtInfoLoader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 82c2b73fb..300e26f96 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -715,7 +715,7 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, // Fill axes numbers info std::string axes_numbers = - fmt::format("[{}, {}, {}, {}] (Ra, Dec, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); + fmt::format("[{}, {}, {}, {}] (Dir1, Dir2, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); size_t start_pos = 0; std::string from("-1"), to("NA"); while (((start_pos = axes_numbers.find(from, start_pos)) != std::string::npos) && (start_pos < axes_numbers.length())) { From d212cbb8eb44c30740f57219cc38de34ce7271a9 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 13 Sep 2022 01:38:05 +0800 Subject: [PATCH 06/41] Fix the problem of showing PV image coordinates for swapped axes cubes --- src/ImageGenerators/PvGenerator.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ImageGenerators/PvGenerator.cc b/src/ImageGenerators/PvGenerator.cc index 294732535..4f2100452 100644 --- a/src/ImageGenerators/PvGenerator.cc +++ b/src/ImageGenerators/PvGenerator.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -104,8 +105,23 @@ casacore::CoordinateSystem PvGenerator::GetPvCoordinateSystem( casacore::LinearCoordinate linear_coord(name, unit, crval, inc, pc, crpix); csys.addCoordinate(linear_coord); - // Add spectral coordinate - csys.addCoordinate(input_csys.spectralCoordinate()); + // Add spectral or direction axis if its axis number is 2 (i.e., depth axis) + if (input_csys.hasSpectralAxis() && input_csys.spectralAxisNumber() == 2) { + csys.addCoordinate(input_csys.spectralCoordinate()); + } else if (input_csys.hasDirectionCoordinate()) { + auto dir_axes = input_csys.directionAxesNumbers(); + if (dir_axes(0) == 2) { + csys.addCoordinate(input_csys.directionCoordinate()); + csys.removeWorldAxis(3, 0.0); // Remove the second axis from direction axes + } else if (dir_axes(1) == 2) { + csys.addCoordinate(input_csys.directionCoordinate()); + csys.removeWorldAxis(2, 0.0); // Remove the first axis from direction axes + } else { + spdlog::error("Can not find depth axis from direction coordinate."); + } + } else { + spdlog::error("Can not find depth axis from spectral or direction coordinates."); + } // Add stokes coordinate if input image has one if (input_csys.hasPolarizationCoordinate()) { From c6d382dec0c7904896e7c4bacd2f4e76d9fd19b1 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 13 Sep 2022 23:54:06 +0800 Subject: [PATCH 07/41] Identify key words GLON or GLAT as direction axes --- src/FileList/FileExtInfoLoader.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 300e26f96..f71f70721 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -624,9 +624,9 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: auto entry_value = header_entry.value(); std::transform(entry_value.begin(), entry_value.end(), entry_value.begin(), [](unsigned char c) { return std::toupper(c); }); - if (entry_value.find("RA") == 0) { + if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0) { direction_axes[0] = axis_num; - } else if (entry_value.find("DEC") == 0) { + } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0) { direction_axes[1] = axis_num; } else if (entry_value == "STOKES") { stokes_axis = axis_num; @@ -715,7 +715,7 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, // Fill axes numbers info std::string axes_numbers = - fmt::format("[{}, {}, {}, {}] (Dir1, Dir2, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); + fmt::format("[{}, {}, {}, {}] (DirX, DirY, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); size_t start_pos = 0; std::string from("-1"), to("NA"); while (((start_pos = axes_numbers.find(from, start_pos)) != std::string::npos) && (start_pos < axes_numbers.length())) { From 97798efc637af53c637e99d9b21aa7f9ed1b4ef8 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 13 Sep 2022 23:57:29 +0800 Subject: [PATCH 08/41] Remove unused codes --- src/ImageData/FileLoader.cc | 45 +++++++++++++++---------------------- src/ImageData/FileLoader.h | 2 +- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index ebfdebddd..e5ade7b48 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -284,7 +284,7 @@ bool FileLoader::FindCoordinateAxes( return true; } -std::vector FileLoader::GetRenderAxes(bool use_dir_axes) { +std::vector FileLoader::GetRenderAxes() { // Determine which axes will be rendered std::vector axes; @@ -296,34 +296,25 @@ std::vector FileLoader::GetRenderAxes(bool use_dir_axes) { // Default unless PV image axes.assign({0, 1}); - if (_image_shape.size() > 2) { - // Normally, use direction axes - if (_coord_sys->hasDirectionCoordinate()) { - if (use_dir_axes) { // Use direction axes as render axes if any - casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); - axes[0] = dir_axes[0]; - axes[1] = dir_axes[1]; - } - } else if (_coord_sys->hasLinearCoordinate()) { - // Check for PV image: [Linear, Spectral] axes - // Returns -1 if no spectral axis - int spectral_axis = _coord_sys->spectralAxisNumber(); - - if (spectral_axis >= 0) { - // Find valid (not -1) linear axes - std::vector valid_axes; - casacore::Vector lin_axes = _coord_sys->linearAxesNumbers(); - for (auto axis : lin_axes) { - if (axis >= 0) { - valid_axes.push_back(axis); - } + if (_image_shape.size() > 2 && _coord_sys->hasLinearCoordinate()) { + // Check for PV image: [Linear, Spectral] axes + // Returns -1 if no spectral axis + int spectral_axis = _coord_sys->spectralAxisNumber(); + + if (spectral_axis >= 0) { + // Find valid (not -1) linear axes + std::vector valid_axes; + casacore::Vector lin_axes = _coord_sys->linearAxesNumbers(); + for (auto axis : lin_axes) { + if (axis >= 0) { + valid_axes.push_back(axis); } + } - // One linear + spectral axis = pV image - if (valid_axes.size() == 1) { - valid_axes.push_back(spectral_axis); - axes = valid_axes; - } + // One linear + spectral axis = pV image + if (valid_axes.size() == 1) { + valid_axes.push_back(spectral_axis); + axes = valid_axes; } } } diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index 69096eff5..cf171490a 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -78,7 +78,7 @@ class FileLoader { std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, int& z_axis, std::string& message); - std::vector GetRenderAxes(bool use_dir_axes = false); // Determine axes used for image raster data + std::vector GetRenderAxes(); // Determine axes used for image raster data // Slice image data (with mask applied) bool GetSlice(casacore::Array& data, const StokesSlicer& stokes_slicer); From fa79f05a71537b527624ad1cdea89f13b8a6a09c Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 14 Sep 2022 01:31:37 +0800 Subject: [PATCH 09/41] Modify the protobuf message AxesNumbers --- carta-protobuf | 2 +- src/FileList/FileExtInfoLoader.cc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/carta-protobuf b/carta-protobuf index 27b936c19..ece47327c 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit 27b936c1953d931c60501c1da040d32763005011 +Subproject commit ece47327cbadc27e849bc68a1cd740ef3358f289 diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index f71f70721..827d2eea5 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -688,12 +688,11 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, extended_info.set_stokes(stokes); auto* axes_numbers_info = extended_info.mutable_axes_numbers(); - if (direction_axes.size() == 2) { - axes_numbers_info->add_directions(direction_axes[0]); - axes_numbers_info->add_directions(direction_axes[1]); - } + axes_numbers_info->set_dir_x(direction_axes[0]); + axes_numbers_info->set_dir_y(direction_axes[1]); axes_numbers_info->set_spectral(spectral_axis); axes_numbers_info->set_stokes(stokes_axis); + axes_numbers_info->set_depth(depth_axis); // shape computed_entry std::string shape_string; From c4319524ffe43979aff5887b7b48f44287b0101e Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Mon, 3 Oct 2022 10:39:21 +0800 Subject: [PATCH 10/41] Change axis indices from 0-based to 1-based in the axes_numbers message --- src/FileList/FileExtInfoLoader.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 827d2eea5..070b30431 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -688,11 +688,12 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, extended_info.set_stokes(stokes); auto* axes_numbers_info = extended_info.mutable_axes_numbers(); - axes_numbers_info->set_dir_x(direction_axes[0]); - axes_numbers_info->set_dir_y(direction_axes[1]); - axes_numbers_info->set_spectral(spectral_axis); - axes_numbers_info->set_stokes(stokes_axis); - axes_numbers_info->set_depth(depth_axis); + // Change to 1-based axis indices + axes_numbers_info->set_dir_x(direction_axes[0] + 1); + axes_numbers_info->set_dir_y(direction_axes[1] + 1); + axes_numbers_info->set_spectral(spectral_axis + 1); + axes_numbers_info->set_stokes(stokes_axis + 1); + axes_numbers_info->set_depth(depth_axis + 1); // shape computed_entry std::string shape_string; From c14c257e95ac151ee967720146fde18b8dadcf90 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 4 Oct 2022 01:30:40 +0800 Subject: [PATCH 11/41] Minor code changes and refactoring --- src/FileList/FileExtInfoLoader.cc | 50 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 070b30431..b329faaaf 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -596,7 +596,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: casacore::IPosition shape; std::vector direction_axes(2, -1); int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); - std::vector spectral_ctypes = {"ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA"}; + std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; casacore::DataType data_type(casacore::DataType::TpFloat); for (int i = 0; i < extended_info.header_entries_size(); ++i) { @@ -628,15 +628,16 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: direction_axes[0] = axis_num; } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0) { direction_axes[1] = axis_num; - } else if (entry_value == "STOKES") { + } else if (entry_value.find("STOKES") == 0) { stokes_axis = axis_num; - } else if ((entry_value.find("FREQ") == 0) || (entry_value.find("WAV") != std::string::npos) || - (std::find(spectral_ctypes.begin(), spectral_ctypes.end(), entry_value) != spectral_ctypes.end())) { + } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), + [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { spectral_axis = axis_num; } - if (axis_num == 2) { // Default depth axis is the third axis from the file header - depth_axis = spectral_axis; + // Depth axis is non-render axis that is not stokes (if any) + if (axis_num > 1 && axis_num != stokes_axis) { + depth_axis = axis_num; } } else if (entry_name.find("BITPIX") == 0) { auto value = header_entry.value(); @@ -695,17 +696,34 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axes_numbers_info->set_stokes(stokes_axis + 1); axes_numbers_info->set_depth(depth_axis + 1); + // Set axis types with respect to axis numbers 0~3 + std::vector axis_types(4, "NA"); + if (direction_axes[0] > -1) { + axis_types[direction_axes[0]] = "X"; + } + if (direction_axes[1] > -1) { + axis_types[direction_axes[1]] = "Y"; + } + if (spectral_axis > -1) { + axis_types[spectral_axis] = "Spectral"; + } + if (stokes_axis > -1) { + axis_types[stokes_axis] = "Stokes"; + } + // shape computed_entry std::string shape_string; switch (num_dims) { case 2: - shape_string = fmt::format("[{}, {}]", shape(0), shape(1)); + shape_string = fmt::format("[{}, {}] ({}, {})", shape(0), shape(1), axis_types[0], axis_types[1]); break; case 3: - shape_string = fmt::format("[{}, {}, {}]", shape(0), shape(1), shape(2)); + shape_string = + fmt::format("[{}, {}, {}] ({}, {}, {})", shape(0), shape(1), shape(2), axis_types[0], axis_types[1], axis_types[2]); break; case 4: - shape_string = fmt::format("[{}, {}, {}, {}]", shape(0), shape(1), shape(2), shape(3)); + shape_string = fmt::format("[{}, {}, {}, {}] ({}, {}, {}, {})", shape(0), shape(1), shape(2), shape(3), axis_types[0], + axis_types[1], axis_types[2], axis_types[3]); break; } auto shape_entry = extended_info.add_computed_entries(); @@ -713,20 +731,6 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, shape_entry->set_value(shape_string); shape_entry->set_entry_type(CARTA::EntryType::STRING); - // Fill axes numbers info - std::string axes_numbers = - fmt::format("[{}, {}, {}, {}] (DirX, DirY, Spectral, Stokes)", direction_axes[0], direction_axes[1], spectral_axis, stokes_axis); - size_t start_pos = 0; - std::string from("-1"), to("NA"); - while (((start_pos = axes_numbers.find(from, start_pos)) != std::string::npos) && (start_pos < axes_numbers.length())) { - axes_numbers.replace(start_pos, from.length(), to); - start_pos += to.length(); - } - auto* axes_numbers_entry = extended_info.add_computed_entries(); - axes_numbers_entry->set_name("Axes numbers"); - axes_numbers_entry->set_value(axes_numbers); - axes_numbers_entry->set_entry_type(CARTA::EntryType::STRING); - if (depth_axis >= 0) { // header entry for number of channels unsigned int nchan = shape(depth_axis); From 09f229e46e89bba9d570a1cfff917dcc054ba569 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 4 Oct 2022 01:45:34 +0800 Subject: [PATCH 12/41] Fix an unit test error for the file info --- test/TestFileInfo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestFileInfo.cc b/test/TestFileInfo.cc index c9d2a4870..d94b53344 100644 --- a/test/TestFileInfo.cc +++ b/test/TestFileInfo.cc @@ -115,7 +115,7 @@ class FileExtInfoLoaderTest : public ::testing::Test { } else if (computed_entries.name() == "HDU") { CheckHeaderEntry(computed_entries, "0", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Shape") { - CheckHeaderEntry(computed_entries, "[6, 6, 5, 1]", CARTA::EntryType::STRING); + CheckHeaderEntry(computed_entries, "[6, 6, 5, 1] (X, Y, Spectral, Stokes)", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Number of channels") { CheckHeaderEntry(computed_entries, "5", CARTA::EntryType::INT, 5); } else if (computed_entries.name() == "Number of polarizations") { From 88d203723ea67dea00b2a44c839b50b28aca14a1 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 4 Oct 2022 09:59:29 +0800 Subject: [PATCH 13/41] Revert coordinate settings in PV generator --- src/ImageGenerators/PvGenerator.cc | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/ImageGenerators/PvGenerator.cc b/src/ImageGenerators/PvGenerator.cc index 4f2100452..294732535 100644 --- a/src/ImageGenerators/PvGenerator.cc +++ b/src/ImageGenerators/PvGenerator.cc @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -105,23 +104,8 @@ casacore::CoordinateSystem PvGenerator::GetPvCoordinateSystem( casacore::LinearCoordinate linear_coord(name, unit, crval, inc, pc, crpix); csys.addCoordinate(linear_coord); - // Add spectral or direction axis if its axis number is 2 (i.e., depth axis) - if (input_csys.hasSpectralAxis() && input_csys.spectralAxisNumber() == 2) { - csys.addCoordinate(input_csys.spectralCoordinate()); - } else if (input_csys.hasDirectionCoordinate()) { - auto dir_axes = input_csys.directionAxesNumbers(); - if (dir_axes(0) == 2) { - csys.addCoordinate(input_csys.directionCoordinate()); - csys.removeWorldAxis(3, 0.0); // Remove the second axis from direction axes - } else if (dir_axes(1) == 2) { - csys.addCoordinate(input_csys.directionCoordinate()); - csys.removeWorldAxis(2, 0.0); // Remove the first axis from direction axes - } else { - spdlog::error("Can not find depth axis from direction coordinate."); - } - } else { - spdlog::error("Can not find depth axis from spectral or direction coordinates."); - } + // Add spectral coordinate + csys.addCoordinate(input_csys.spectralCoordinate()); // Add stokes coordinate if input image has one if (input_csys.hasPolarizationCoordinate()) { From 91d4ef9d9d0c92a4ace832db6dc46f55aeffff69 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 4 Oct 2022 22:52:56 +0800 Subject: [PATCH 14/41] Refactor codes --- src/FileList/FileExtInfoLoader.cc | 8 ++++---- src/Frame/Frame.cc | 6 ++---- src/Frame/Frame.h | 4 ++-- src/ImageData/FileLoader.cc | 6 +++--- src/ImageData/FileLoader.h | 4 ++-- src/ImageData/StokesFilesConnector.cc | 9 +++++---- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index b329faaaf..144ecbe71 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -196,11 +196,11 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ AddDataTypeEntry(extended_info, data_type); - std::vector direction_axes; - int spectral_axis, depth_axis, stokes_axis; - if (_loader->FindCoordinateAxes(image_shape, direction_axes, spectral_axis, stokes_axis, depth_axis, message)) { + std::vector direction_axes, render_axes; + int spectral_axis, stokes_axis, depth_axis; + if (_loader->FindCoordinateAxes( + image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis - std::vector render_axes = _loader->GetRenderAxes(); AddShapeEntries(extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); info_ok = true; diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc index 8c636b931..9a39039a7 100644 --- a/src/Frame/Frame.cc +++ b/src/Frame/Frame.cc @@ -67,18 +67,16 @@ Frame::Frame(uint32_t session_id, std::shared_ptr loader, const std: // Get shape and axis values from the loader std::string log_message; - if (!_loader->FindCoordinateAxes(_image_shape, _direction_axes, _spectral_axis, _stokes_axis, _z_axis, log_message)) { + std::vector direction_axes, render_axes; + if (!_loader->FindCoordinateAxes(_image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, log_message)) { _open_image_error = fmt::format("Cannot determine file shape. {}", log_message); spdlog::error("Session {}: {}", session_id, _open_image_error); _valid = false; return; } - // Determine which axes are rendered, e.g. for pV images - std::vector render_axes = _loader->GetRenderAxes(); _x_axis = render_axes[0]; _y_axis = render_axes[1]; - _width = _image_shape(_x_axis); _height = _image_shape(_y_axis); _depth = (_z_axis >= 0 ? _image_shape(_z_axis) : 1); diff --git a/src/Frame/Frame.h b/src/Frame/Frame.h index baf46ec02..0104661d3 100644 --- a/src/Frame/Frame.h +++ b/src/Frame/Frame.h @@ -280,8 +280,8 @@ class Frame { // Shape and axis info: X, Y, Z, Stokes casacore::IPosition _image_shape; - int _x_axis, _y_axis, _z_axis, _spectral_axis, _stokes_axis; - std::vector _direction_axes; + int _x_axis, _y_axis, _z_axis; // X and Y are render axes, Z is depth axis (non-render axis) that is not stokes (if any) + int _spectral_axis, _stokes_axis; int _z_index, _stokes_index; // current index size_t _width, _height, _depth, _num_stokes; diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index e5ade7b48..55977a7f7 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -168,8 +168,8 @@ std::shared_ptr FileLoader::GetCoordinateSystem(cons return std::make_shared(); } -bool FileLoader::FindCoordinateAxes( - casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, int& z_axis, std::string& message) { +bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, + std::vector& render_axes, int& z_axis, std::string& message) { // Return image shape and axes for image. Spectral axis may or may not be z axis. // All parameters are return values. direction_axes.assign(2, -1); @@ -197,7 +197,7 @@ bool FileLoader::FindCoordinateAxes( } // Determine which axes will be rendered - std::vector render_axes = GetRenderAxes(); + render_axes = GetRenderAxes(); _width = shape(render_axes[0]); _height = shape(render_axes[1]); _image_plane_size = _width * _height; diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index cf171490a..f723e844c 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -76,8 +76,8 @@ class FileLoader { // Image shape and coordinate system axes casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); - bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, int& z_axis, - std::string& message); + bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, + std::vector& render_axes, int& z_axis, std::string& message); std::vector GetRenderAxes(); // Determine axes used for image raster data // Slice image data (with mask applied) diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc index f5eb8f761..6e2cd93b7 100644 --- a/src/ImageData/StokesFilesConnector.cc +++ b/src/ImageData/StokesFilesConnector.cc @@ -300,7 +300,7 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) } casacore::IPosition ref_shape(0); - std::vector ref_direction_axes; + std::vector ref_direction_axes, ref_render_axes; int ref_spectral_axis = -1; int ref_z_axis = -1; int ref_stokes_axis = -1; @@ -308,14 +308,15 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) for (auto& loader : _loaders) { casacore::IPosition shape; - std::vector direction_axes; + std::vector direction_axes, render_axes; int spectral_axis; int z_axis; if (ref_index == 0) { - loader.second->FindCoordinateAxes(ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_z_axis, err); + loader.second->FindCoordinateAxes( + ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, err); } else { - loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, z_axis, err); + loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, err); if ((ref_shape.nelements() != shape.nelements()) || (ref_shape != shape) || (ref_spectral_axis != spectral_axis) || (ref_stokes_axis != stokes_axis)) { err = "Image shapes or axes are not consistent!"; From 1f72ab2f30e5319af929850aba4f95b47987a882 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Mon, 21 Nov 2022 15:48:21 +0800 Subject: [PATCH 15/41] Update the protobuf submodule --- carta-protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index ece47327c..a3ee32869 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit ece47327cbadc27e849bc68a1cd740ef3358f289 +Subproject commit a3ee32869f34c5891f261da8871049af0dea1c46 From 8e65f58e565655f638411e45469464c6478305da Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 29 Nov 2022 13:18:07 +0800 Subject: [PATCH 16/41] Minor code changes --- src/FileList/FileExtInfoLoader.cc | 7 ++++--- src/ImageData/FileLoader.cc | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 144ecbe71..7af5afc54 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -596,7 +596,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: casacore::IPosition shape; std::vector direction_axes(2, -1); int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); - std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; + std::vector spectral_ctypes = {"WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; casacore::DataType data_type(casacore::DataType::TpFloat); for (int i = 0; i < extended_info.header_entries_size(); ++i) { @@ -630,12 +630,13 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: direction_axes[1] = axis_num; } else if (entry_value.find("STOKES") == 0) { stokes_axis = axis_num; - } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), + } else if ((entry_value.find("FREQ") == 0) || + std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { spectral_axis = axis_num; } - // Depth axis is non-render axis that is not stokes (if any) + // Depth axis is not the first two axes [0, 1], i.e., non-render axis that is not stokes (if any) if (axis_num > 1 && axis_num != stokes_axis) { depth_axis = axis_num; } diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 32f9161c4..1dcd44492 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -320,6 +320,7 @@ std::vector FileLoader::GetRenderAxes(bool get_dir_axes) { valid_axes.push_back(axis); } } + if (spectral_axis > 0) { // not reversed valid_axes.push_back(spectral_axis); } From 905eded64417caaa025d89572dfde1c39bc232e2 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 30 Nov 2022 10:57:12 +0800 Subject: [PATCH 17/41] Fix the problem of loading image file if it has both linear and direction coordinates --- src/FileList/FileExtInfoLoader.cc | 10 ++++------ src/ImageData/FileLoader.cc | 10 ++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 7af5afc54..d18e05e0f 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -734,21 +734,19 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, if (depth_axis >= 0) { // header entry for number of channels - unsigned int nchan = shape(depth_axis); auto entry = extended_info.add_computed_entries(); entry->set_name("Number of channels"); - entry->set_value(std::to_string(nchan)); + entry->set_value(std::to_string(depth)); entry->set_entry_type(CARTA::EntryType::INT); - entry->set_numeric_value(nchan); + entry->set_numeric_value(depth); } if (stokes_axis >= 0) { // header entry for number of stokes - unsigned int nstokes = shape(stokes_axis); auto entry = extended_info.add_computed_entries(); entry->set_name("Number of polarizations"); - entry->set_value(std::to_string(nstokes)); + entry->set_value(std::to_string(stokes)); entry->set_entry_type(CARTA::EntryType::INT); - entry->set_numeric_value(nstokes); + entry->set_numeric_value(stokes); } } diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 1dcd44492..92ab6a610 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -298,10 +298,12 @@ std::vector FileLoader::GetRenderAxes(bool get_dir_axes) { if (_image_shape.size() > 2) { // Normally, use direction axes - if (get_dir_axes && _coord_sys->hasDirectionCoordinate()) { - casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); - axes[0] = dir_axes[0]; - axes[1] = dir_axes[1]; + if (_coord_sys->hasDirectionCoordinate()) { + if (get_dir_axes) { + casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); + axes[0] = dir_axes[0]; + axes[1] = dir_axes[1]; + } } else if (_coord_sys->hasLinearCoordinate()) { // Check for PV image: usually [Linear, Spectral] axes but could be reversed // Returns -1 if no spectral axis From df993e4b460a69469e7a10894cfebdea57626b2a Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 30 Nov 2022 14:10:23 +0800 Subject: [PATCH 18/41] Fix the error of showing direction axes range names in the file info for swapped images --- src/FileList/FileExtInfoLoader.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index d18e05e0f..873c6e67e 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -1405,24 +1405,24 @@ void FileExtInfoLoader::AddCoordRanges( std::string y_end = direction_coord.format(units, casacore::Coordinate::DEFAULT, y_max, 1, true, true); // Set x and y coordinate names - if (axis_names(0) == "Right Ascension") { - axis_names(0) = "RA"; - } else if (axis_names(0) == "Longitude") { - axis_names(0) = "LON"; + if (axis_names(direction_axes[0]) == "Right Ascension") { + axis_names(direction_axes[0]) = "RA"; + } else if (axis_names(direction_axes[0]) == "Longitude") { + axis_names(direction_axes[0]) = "LON"; } - if (axis_names(1) == "Declination") { - axis_names(1) = "DEC"; - } else if (axis_names(1) == "Latitude") { - axis_names(1) = "LAT"; + if (axis_names(direction_axes[1]) == "Declination") { + axis_names(direction_axes[1]) = "DEC"; + } else if (axis_names(direction_axes[1]) == "Latitude") { + axis_names(direction_axes[1]) = "LAT"; } auto* x_entry = extended_info.add_computed_entries(); - x_entry->set_name(fmt::format("{} range", axis_names(0))); + x_entry->set_name(fmt::format("{} range", axis_names(direction_axes[0]))); x_entry->set_value(fmt::format("[{}, {}]", x_start, x_end)); x_entry->set_entry_type(CARTA::EntryType::STRING); auto* y_entry = extended_info.add_computed_entries(); - y_entry->set_name(fmt::format("{} range", axis_names(1))); + y_entry->set_name(fmt::format("{} range", axis_names(direction_axes[1]))); y_entry->set_value(fmt::format("[{}, {}]", y_start, y_end)); y_entry->set_entry_type(CARTA::EntryType::STRING); } From 8e39ce0d82fe6e52dfec361e0f705ef14b518aaf Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 1 Dec 2022 00:04:49 +0800 Subject: [PATCH 19/41] Modify file info on the file browser for swapped image cubes --- src/FileList/FileExtInfoLoader.cc | 103 ++++++++++++++++++-------- src/FileList/FileExtInfoLoader.h | 3 +- src/Frame/Frame.cc | 4 +- src/ImageData/FileLoader.cc | 5 +- src/ImageData/FileLoader.h | 2 +- src/ImageData/StokesFilesConnector.cc | 6 +- test/TestFileInfo.cc | 2 +- 7 files changed, 86 insertions(+), 39 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 873c6e67e..1931e4341 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -198,10 +198,12 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ std::vector direction_axes, render_axes; int spectral_axis, stokes_axis, depth_axis; + casacore::Vector axis_names; if (_loader->FindCoordinateAxes( - image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { + image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names, message)) { // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis - AddShapeEntries(extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); + AddShapeEntries( + extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names); AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); info_ok = true; } @@ -596,8 +598,9 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: casacore::IPosition shape; std::vector direction_axes(2, -1); int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); - std::vector spectral_ctypes = {"WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; + std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; casacore::DataType data_type(casacore::DataType::TpFloat); + casacore::Vector axis_names(4, "NA"); for (int i = 0; i < extended_info.header_entries_size(); ++i) { auto header_entry = extended_info.header_entries(i); @@ -626,14 +629,22 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0) { direction_axes[0] = axis_num; + axis_names[direction_axes[0]] = entry_value.find("RA") == 0 ? "RA" : "GLON"; } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0) { direction_axes[1] = axis_num; + axis_names[direction_axes[1]] = entry_value.find("DEC") == 0 ? "DEC" : "GLAT"; } else if (entry_value.find("STOKES") == 0) { stokes_axis = axis_num; - } else if ((entry_value.find("FREQ") == 0) || - std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), + axis_names[stokes_axis] = "STOKES"; + } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { spectral_axis = axis_num; + for (const auto& type : spectral_ctypes) { + if (entry_value.find(type) != std::string::npos) { + axis_names[spectral_axis] = type; + break; + } + } } // Depth axis is not the first two axes [0, 1], i.e., non-render axis that is not stokes (if any) @@ -652,7 +663,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: } AddDataTypeEntry(extended_info, data_type); - AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); + AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names); if (compressed_fits) { compressed_fits->SetShape(shape); @@ -675,7 +686,8 @@ void FileExtInfoLoader::AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, } void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, - const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis) { + const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, + const casacore::Vector& axis_names) { // Set fields/header entries for shape: dimensions, width, height, depth, stokes int num_dims(shape.size()); int width(shape(render_axes[0])); @@ -699,17 +711,41 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, // Set axis types with respect to axis numbers 0~3 std::vector axis_types(4, "NA"); - if (direction_axes[0] > -1) { - axis_types[direction_axes[0]] = "X"; + if (direction_axes[0] > -1 && direction_axes[0] < axis_names.size()) { + if (axis_names(direction_axes[0]) == "Right Ascension") { + axis_types[direction_axes[0]] = "RA"; + } else if (axis_names(direction_axes[0]) == "Longitude") { + axis_types[direction_axes[0]] = "LON"; + } } - if (direction_axes[1] > -1) { - axis_types[direction_axes[1]] = "Y"; + + if (direction_axes[1] > -1 && direction_axes[1] < axis_names.size()) { + if (axis_names(direction_axes[1]) == "Declination") { + axis_types[direction_axes[1]] = "DEC"; + } else if (axis_names(direction_axes[1]) == "Latitude") { + axis_types[direction_axes[1]] = "LAT"; + } } - if (spectral_axis > -1) { - axis_types[spectral_axis] = "Spectral"; + + if (spectral_axis > -1 && spectral_axis < axis_names.size()) { + std::string name = axis_names(spectral_axis); + auto len = name.length() > 3 ? 4 : name.length(); + if (len > 0) { + name = name.substr(0, len); + std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); + axis_types[spectral_axis] = name; + } } + if (stokes_axis > -1) { - axis_types[stokes_axis] = "Stokes"; + axis_types[stokes_axis] = "STOKES"; + } + + // For PV image + if (spectral_axis == 0 && axis_types[1] == "NA") { + axis_types[1] = "Spatial"; + } else if (spectral_axis == 1 && axis_types[0] == "NA") { + axis_types[0] = "Spatial"; } // shape computed_entry @@ -1405,26 +1441,29 @@ void FileExtInfoLoader::AddCoordRanges( std::string y_end = direction_coord.format(units, casacore::Coordinate::DEFAULT, y_max, 1, true, true); // Set x and y coordinate names - if (axis_names(direction_axes[0]) == "Right Ascension") { - axis_names(direction_axes[0]) = "RA"; - } else if (axis_names(direction_axes[0]) == "Longitude") { - axis_names(direction_axes[0]) = "LON"; - } - if (axis_names(direction_axes[1]) == "Declination") { - axis_names(direction_axes[1]) = "DEC"; - } else if (axis_names(direction_axes[1]) == "Latitude") { - axis_names(direction_axes[1]) = "LAT"; + if (direction_axes[0] > -1 && direction_axes[0] < axis_names.size()) { + if (axis_names(direction_axes[0]) == "Right Ascension") { + axis_names(direction_axes[0]) = "RA"; + } else if (axis_names(direction_axes[0]) == "Longitude") { + axis_names(direction_axes[0]) = "LON"; + } + auto* x_entry = extended_info.add_computed_entries(); + x_entry->set_name(fmt::format("{} range", axis_names(direction_axes[0]))); + x_entry->set_value(fmt::format("[{}, {}]", x_start, x_end)); + x_entry->set_entry_type(CARTA::EntryType::STRING); } - auto* x_entry = extended_info.add_computed_entries(); - x_entry->set_name(fmt::format("{} range", axis_names(direction_axes[0]))); - x_entry->set_value(fmt::format("[{}, {}]", x_start, x_end)); - x_entry->set_entry_type(CARTA::EntryType::STRING); - - auto* y_entry = extended_info.add_computed_entries(); - y_entry->set_name(fmt::format("{} range", axis_names(direction_axes[1]))); - y_entry->set_value(fmt::format("[{}, {}]", y_start, y_end)); - y_entry->set_entry_type(CARTA::EntryType::STRING); + if (direction_axes[1] > -1 && direction_axes[1] < axis_names.size()) { + if (axis_names(direction_axes[1]) == "Declination") { + axis_names(direction_axes[1]) = "DEC"; + } else if (axis_names(direction_axes[1]) == "Latitude") { + axis_names(direction_axes[1]) = "LAT"; + } + auto* y_entry = extended_info.add_computed_entries(); + y_entry->set_name(fmt::format("{} range", axis_names(direction_axes[1]))); + y_entry->set_value(fmt::format("[{}, {}]", y_start, y_end)); + y_entry->set_entry_type(CARTA::EntryType::STRING); + } } } diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index 3b2c3ef01..a32230d03 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -51,7 +51,8 @@ class FileExtInfoLoader { // Computed entries void AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, casacore::DataType data_type); void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& direction_axes, - int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis); + int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, + const casacore::Vector& axis_names); void AddInitialComputedEntries(const std::string& hdu, CARTA::FileInfoExtended& extended_info, const std::string& filename, const std::vector& render_axes, CompressedFits* compressed_fits = nullptr); void AddComputedEntries(CARTA::FileInfoExtended& extended_info, casacore::ImageInterface* image, diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc index d61125dba..2f21645e9 100644 --- a/src/Frame/Frame.cc +++ b/src/Frame/Frame.cc @@ -68,7 +68,9 @@ Frame::Frame(uint32_t session_id, std::shared_ptr loader, const std: // Get shape and axis values from the loader std::string log_message; std::vector direction_axes, render_axes; - if (!_loader->FindCoordinateAxes(_image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, log_message)) { + casacore::Vector axis_names; + if (!_loader->FindCoordinateAxes( + _image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, axis_names, log_message)) { _open_image_error = fmt::format("Cannot determine file shape. {}", log_message); spdlog::error("Session {}: {}", session_id, _open_image_error); _valid = false; diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 92ab6a610..3295bd1ae 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -169,7 +169,7 @@ std::shared_ptr FileLoader::GetCoordinateSystem(cons } bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, - std::vector& render_axes, int& z_axis, std::string& message) { + std::vector& render_axes, int& z_axis, casacore::Vector& axis_names, std::string& message) { // Return image shape and axes for image. Spectral axis may or may not be z axis. // All parameters are return values. direction_axes.assign(2, -1); @@ -196,6 +196,9 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector return false; } + // Get world axis names + axis_names = _coord_sys->worldAxisNames(); + // Determine which axes will be rendered render_axes = GetRenderAxes(); _width = shape(render_axes[0]); diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index 6c69574d9..294ef3169 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -77,7 +77,7 @@ class FileLoader { casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, - std::vector& render_axes, int& z_axis, std::string& message); + std::vector& render_axes, int& z_axis, casacore::Vector& axis_names, std::string& message); std::vector GetRenderAxes(bool get_dir_axes = false); // Determine axes used for image raster data // Slice image data (with mask applied) diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc index 6e2cd93b7..08a2a0e16 100644 --- a/src/ImageData/StokesFilesConnector.cc +++ b/src/ImageData/StokesFilesConnector.cc @@ -301,6 +301,7 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) casacore::IPosition ref_shape(0); std::vector ref_direction_axes, ref_render_axes; + casacore::Vector ref_axis_names; int ref_spectral_axis = -1; int ref_z_axis = -1; int ref_stokes_axis = -1; @@ -309,14 +310,15 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) for (auto& loader : _loaders) { casacore::IPosition shape; std::vector direction_axes, render_axes; + casacore::Vector axis_names; int spectral_axis; int z_axis; if (ref_index == 0) { loader.second->FindCoordinateAxes( - ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, err); + ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, ref_axis_names, err); } else { - loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, err); + loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, axis_names, err); if ((ref_shape.nelements() != shape.nelements()) || (ref_shape != shape) || (ref_spectral_axis != spectral_axis) || (ref_stokes_axis != stokes_axis)) { err = "Image shapes or axes are not consistent!"; diff --git a/test/TestFileInfo.cc b/test/TestFileInfo.cc index d94b53344..9625aa978 100644 --- a/test/TestFileInfo.cc +++ b/test/TestFileInfo.cc @@ -115,7 +115,7 @@ class FileExtInfoLoaderTest : public ::testing::Test { } else if (computed_entries.name() == "HDU") { CheckHeaderEntry(computed_entries, "0", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Shape") { - CheckHeaderEntry(computed_entries, "[6, 6, 5, 1] (X, Y, Spectral, Stokes)", CARTA::EntryType::STRING); + CheckHeaderEntry(computed_entries, "[6, 6, 5, 1] (RA, DEC, FREQ, STOKES)", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Number of channels") { CheckHeaderEntry(computed_entries, "5", CARTA::EntryType::INT, 5); } else if (computed_entries.name() == "Number of polarizations") { From 732c82400778455627e4fa47a05a0f8276e2454f Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 1 Dec 2022 00:26:54 +0800 Subject: [PATCH 20/41] Fix the problem of showing direction axis names for compressed images --- src/FileList/FileExtInfoLoader.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 1931e4341..e98983223 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -716,6 +716,8 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axis_types[direction_axes[0]] = "RA"; } else if (axis_names(direction_axes[0]) == "Longitude") { axis_types[direction_axes[0]] = "LON"; + } else { + axis_types[direction_axes[0]] = axis_names(direction_axes[0]); } } @@ -724,6 +726,8 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axis_types[direction_axes[1]] = "DEC"; } else if (axis_names(direction_axes[1]) == "Latitude") { axis_types[direction_axes[1]] = "LAT"; + } else { + axis_types[direction_axes[1]] = axis_names(direction_axes[1]); } } From 51feea87a53d34d67c856f56bac4612acd7f1e63 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Fri, 2 Dec 2022 23:29:21 +0800 Subject: [PATCH 21/41] Update the protobuf with the new dev branch --- carta-protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index a3ee32869..21d9ee728 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit a3ee32869f34c5891f261da8871049af0dea1c46 +Subproject commit 21d9ee728fdad1cb05a7d0e9f2d922f223a72b48 From a7a37c08123a7f1be2aa535ebb34bc1ed2f9d119 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Fri, 2 Dec 2022 23:54:38 +0800 Subject: [PATCH 22/41] Change the name of linear axis for a PV image as OFFSET --- src/FileList/FileExtInfoLoader.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index e98983223..4995deec7 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -747,9 +747,9 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, // For PV image if (spectral_axis == 0 && axis_types[1] == "NA") { - axis_types[1] = "Spatial"; + axis_types[1] = "OFFSET"; } else if (spectral_axis == 1 && axis_types[0] == "NA") { - axis_types[0] = "Spatial"; + axis_types[0] = "OFFSET"; } // shape computed_entry From 511bdfde53052d08b0e1f35d15a807c60805be70 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 6 Dec 2022 13:57:02 +0800 Subject: [PATCH 23/41] Fix the name of non-direction axis for axis number is 0 or 1 --- src/FileList/FileExtInfoLoader.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 4995deec7..458e7a6c0 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -745,11 +745,15 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axis_types[stokes_axis] = "STOKES"; } - // For PV image - if (spectral_axis == 0 && axis_types[1] == "NA") { - axis_types[1] = "OFFSET"; - } else if (spectral_axis == 1 && axis_types[0] == "NA") { - axis_types[0] = "OFFSET"; + // For rest of non-direction axes (like PV images) + if (spectral_axis == 0 && axis_types[1] == "NA" && !axis_names[1].empty()) { + std::string name = axis_names[1]; + std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); + axis_types[1] = name; + } else if (spectral_axis == 1 && axis_types[0] == "NA" && !axis_names[0].empty()) { + std::string name = axis_names[0]; + std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); + axis_types[0] = name; } // shape computed_entry From a9c4f04fa0abc27962eb6423343ff2dda55487b0 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 6 Dec 2022 14:30:35 +0800 Subject: [PATCH 24/41] Remove the function GetRenderAxes from the FileLoader --- src/ImageData/FileLoader.cc | 59 ++----------------------------------- src/ImageData/FileLoader.h | 2 -- 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 3295bd1ae..0d3eb1cea 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -199,8 +199,8 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector // Get world axis names axis_names = _coord_sys->worldAxisNames(); - // Determine which axes will be rendered - render_axes = GetRenderAxes(); + // Determine axes [0, 1] will be rendered + render_axes.assign({0, 1}); _width = shape(render_axes[0]); _height = shape(render_axes[1]); _image_plane_size = _width * _height; @@ -287,61 +287,6 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector return true; } -std::vector FileLoader::GetRenderAxes(bool get_dir_axes) { - // Determine which axes will be rendered - std::vector axes; - - if (!_render_axes.empty()) { - axes = _render_axes; - return axes; - } - - // Default unless PV image - axes.assign({0, 1}); - - if (_image_shape.size() > 2) { - // Normally, use direction axes - if (_coord_sys->hasDirectionCoordinate()) { - if (get_dir_axes) { - casacore::Vector dir_axes = _coord_sys->directionAxesNumbers(); - axes[0] = dir_axes[0]; - axes[1] = dir_axes[1]; - } - } else if (_coord_sys->hasLinearCoordinate()) { - // Check for PV image: usually [Linear, Spectral] axes but could be reversed - // Returns -1 if no spectral axis - int spectral_axis = _coord_sys->spectralAxisNumber(); - - if (spectral_axis >= 0) { - // Find valid (not -1) linear axes - std::vector valid_axes; - if (spectral_axis == 0) { // reversed - valid_axes.push_back(spectral_axis); - } - - casacore::Vector lin_axes = _coord_sys->linearAxesNumbers(); - for (auto axis : lin_axes) { - if (axis >= 0) { - valid_axes.push_back(axis); - } - } - - if (spectral_axis > 0) { // not reversed - valid_axes.push_back(spectral_axis); - } - - // One linear + spectral axis = pV image - if (valid_axes.size() == 2) { - axes = valid_axes; - } - } - } - } - - _render_axes = axes; - return axes; -} - bool FileLoader::GetSlice(casacore::Array& data, const StokesSlicer& stokes_slicer) { StokesSource stokes_source = stokes_slicer.stokes_source; casacore::Slicer slicer = stokes_slicer.slicer; diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index 294ef3169..374b34bd0 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -78,7 +78,6 @@ class FileLoader { std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, std::vector& render_axes, int& z_axis, casacore::Vector& axis_names, std::string& message); - std::vector GetRenderAxes(bool get_dir_axes = false); // Determine axes used for image raster data // Slice image data (with mask applied) bool GetSlice(casacore::Array& data, const StokesSlicer& stokes_slicer); @@ -146,7 +145,6 @@ class FileLoader { size_t _num_dims, _image_plane_size; size_t _width, _height, _depth, _num_stokes; int _z_axis, _stokes_axis; - std::vector _render_axes; std::shared_ptr _coord_sys; bool _has_pixel_mask; casacore::DataType _data_type; From 0c59ee0407ae88f296eec8b9665a1f70536c16db Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 15 Dec 2022 13:29:39 +0800 Subject: [PATCH 25/41] Fix the problem of axis names displayed on the file info panel --- src/FileList/FileExtInfoLoader.cc | 83 ++++++++------------------- src/FileList/FileExtInfoLoader.h | 3 +- src/Frame/Frame.cc | 4 +- src/ImageData/FileLoader.cc | 5 +- src/ImageData/FileLoader.h | 2 +- src/ImageData/StokesFilesConnector.cc | 6 +- 6 files changed, 31 insertions(+), 72 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 458e7a6c0..cab95ddfb 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -198,12 +198,10 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ std::vector direction_axes, render_axes; int spectral_axis, stokes_axis, depth_axis; - casacore::Vector axis_names; if (_loader->FindCoordinateAxes( - image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names, message)) { + image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis - AddShapeEntries( - extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names); + AddShapeEntries(extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); info_ok = true; } @@ -600,7 +598,6 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; casacore::DataType data_type(casacore::DataType::TpFloat); - casacore::Vector axis_names(4, "NA"); for (int i = 0; i < extended_info.header_entries_size(); ++i) { auto header_entry = extended_info.header_entries(i); @@ -627,24 +624,15 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: auto entry_value = header_entry.value(); std::transform(entry_value.begin(), entry_value.end(), entry_value.begin(), [](unsigned char c) { return std::toupper(c); }); - if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0) { + if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0 || entry_value.find("UU") == 0) { direction_axes[0] = axis_num; - axis_names[direction_axes[0]] = entry_value.find("RA") == 0 ? "RA" : "GLON"; - } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0) { + } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0 || entry_value.find("VV") == 0) { direction_axes[1] = axis_num; - axis_names[direction_axes[1]] = entry_value.find("DEC") == 0 ? "DEC" : "GLAT"; } else if (entry_value.find("STOKES") == 0) { stokes_axis = axis_num; - axis_names[stokes_axis] = "STOKES"; } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { spectral_axis = axis_num; - for (const auto& type : spectral_ctypes) { - if (entry_value.find(type) != std::string::npos) { - axis_names[spectral_axis] = type; - break; - } - } } // Depth axis is not the first two axes [0, 1], i.e., non-render axis that is not stokes (if any) @@ -663,7 +651,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: } AddDataTypeEntry(extended_info, data_type); - AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axis_names); + AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); if (compressed_fits) { compressed_fits->SetShape(shape); @@ -686,8 +674,7 @@ void FileExtInfoLoader::AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, } void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, - const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, - const casacore::Vector& axis_names) { + const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis) { // Set fields/header entries for shape: dimensions, width, height, depth, stokes int num_dims(shape.size()); int width(shape(render_axes[0])); @@ -711,51 +698,31 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, // Set axis types with respect to axis numbers 0~3 std::vector axis_types(4, "NA"); - if (direction_axes[0] > -1 && direction_axes[0] < axis_names.size()) { - if (axis_names(direction_axes[0]) == "Right Ascension") { - axis_types[direction_axes[0]] = "RA"; - } else if (axis_names(direction_axes[0]) == "Longitude") { - axis_types[direction_axes[0]] = "LON"; - } else { - axis_types[direction_axes[0]] = axis_names(direction_axes[0]); - } - } - - if (direction_axes[1] > -1 && direction_axes[1] < axis_names.size()) { - if (axis_names(direction_axes[1]) == "Declination") { - axis_types[direction_axes[1]] = "DEC"; - } else if (axis_names(direction_axes[1]) == "Latitude") { - axis_types[direction_axes[1]] = "LAT"; - } else { - axis_types[direction_axes[1]] = axis_names(direction_axes[1]); - } - } - - if (spectral_axis > -1 && spectral_axis < axis_names.size()) { - std::string name = axis_names(spectral_axis); - auto len = name.length() > 3 ? 4 : name.length(); - if (len > 0) { - name = name.substr(0, len); - std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); - axis_types[spectral_axis] = name; + for (int i = 0; i < extended_info.header_entries_size(); ++i) { + auto header_entry = extended_info.header_entries(i); + auto entry_name = header_entry.name(); + if (entry_name.find("CTYPE") == 0) { + auto entry_value = header_entry.value(); + if (!entry_value.empty()) { + entry_value = entry_value.substr(0, entry_value.find("-", 0)); + if (entry_name.back() == '1') { + axis_types[0] = entry_value; + } else if (entry_name.back() == '2') { + axis_types[1] = entry_value; + } else if (entry_name.back() == '3') { + axis_types[2] = entry_value; + } else if (entry_name.back() == '4') { + axis_types[3] = entry_value; + } + } } } - if (stokes_axis > -1) { + // In case if the stokes axis name is not available from the header info + if (stokes_axis > -1 && axis_types[stokes_axis] == "NA") { axis_types[stokes_axis] = "STOKES"; } - // For rest of non-direction axes (like PV images) - if (spectral_axis == 0 && axis_types[1] == "NA" && !axis_names[1].empty()) { - std::string name = axis_names[1]; - std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); - axis_types[1] = name; - } else if (spectral_axis == 1 && axis_types[0] == "NA" && !axis_names[0].empty()) { - std::string name = axis_names[0]; - std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); }); - axis_types[0] = name; - } - // shape computed_entry std::string shape_string; switch (num_dims) { diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index a32230d03..3b2c3ef01 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -51,8 +51,7 @@ class FileExtInfoLoader { // Computed entries void AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, casacore::DataType data_type); void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& direction_axes, - int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, - const casacore::Vector& axis_names); + int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis); void AddInitialComputedEntries(const std::string& hdu, CARTA::FileInfoExtended& extended_info, const std::string& filename, const std::vector& render_axes, CompressedFits* compressed_fits = nullptr); void AddComputedEntries(CARTA::FileInfoExtended& extended_info, casacore::ImageInterface* image, diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc index ca1c27b34..2b454eec1 100644 --- a/src/Frame/Frame.cc +++ b/src/Frame/Frame.cc @@ -69,9 +69,7 @@ Frame::Frame(uint32_t session_id, std::shared_ptr loader, const std: // Get shape and axis values from the loader std::string log_message; std::vector direction_axes, render_axes; - casacore::Vector axis_names; - if (!_loader->FindCoordinateAxes( - _image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, axis_names, log_message)) { + if (!_loader->FindCoordinateAxes(_image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, log_message)) { _open_image_error = fmt::format("Cannot determine file shape. {}", log_message); spdlog::error("Session {}: {}", session_id, _open_image_error); _valid = false; diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 0d3eb1cea..1f018cc04 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -169,7 +169,7 @@ std::shared_ptr FileLoader::GetCoordinateSystem(cons } bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, - std::vector& render_axes, int& z_axis, casacore::Vector& axis_names, std::string& message) { + std::vector& render_axes, int& z_axis, std::string& message) { // Return image shape and axes for image. Spectral axis may or may not be z axis. // All parameters are return values. direction_axes.assign(2, -1); @@ -196,9 +196,6 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector return false; } - // Get world axis names - axis_names = _coord_sys->worldAxisNames(); - // Determine axes [0, 1] will be rendered render_axes.assign({0, 1}); _width = shape(render_axes[0]); diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index 374b34bd0..75f13a490 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -77,7 +77,7 @@ class FileLoader { casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, - std::vector& render_axes, int& z_axis, casacore::Vector& axis_names, std::string& message); + std::vector& render_axes, int& z_axis, std::string& message); // Slice image data (with mask applied) bool GetSlice(casacore::Array& data, const StokesSlicer& stokes_slicer); diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc index 08a2a0e16..6e2cd93b7 100644 --- a/src/ImageData/StokesFilesConnector.cc +++ b/src/ImageData/StokesFilesConnector.cc @@ -301,7 +301,6 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) casacore::IPosition ref_shape(0); std::vector ref_direction_axes, ref_render_axes; - casacore::Vector ref_axis_names; int ref_spectral_axis = -1; int ref_z_axis = -1; int ref_stokes_axis = -1; @@ -310,15 +309,14 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) for (auto& loader : _loaders) { casacore::IPosition shape; std::vector direction_axes, render_axes; - casacore::Vector axis_names; int spectral_axis; int z_axis; if (ref_index == 0) { loader.second->FindCoordinateAxes( - ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, ref_axis_names, err); + ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, err); } else { - loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, axis_names, err); + loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, err); if ((ref_shape.nelements() != shape.nelements()) || (ref_shape != shape) || (ref_spectral_axis != spectral_axis) || (ref_stokes_axis != stokes_axis)) { err = "Image shapes or axes are not consistent!"; From 3d9afd3db16e2d2f441805ea34009e024daa6f5b Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 4 Jan 2023 11:01:50 +0800 Subject: [PATCH 26/41] Fix the problem of an image without direction axes info for AST rendering --- src/ImageData/FileLoader.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 1f018cc04..8a3d4fefd 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -207,6 +207,11 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector auto tmp_axes = _coord_sys->directionAxesNumbers(); direction_axes[0] = tmp_axes[0]; direction_axes[1] = tmp_axes[1]; + } else if (_coord_sys->hasLinearCoordinate()) { + auto tmp_axes = _coord_sys->linearAxesNumbers(); + for (int i = 0; i < casacore::min(tmp_axes.size(), 2); ++i) { // Assume the first two linear axes are direction axes, if any + direction_axes[i] = tmp_axes[i]; + } } // Spectral and stokes axis From 93806302b21a92a06cd9c7e71fd0a2bc6cfb3b32 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 10 Jan 2023 10:18:04 +0800 Subject: [PATCH 27/41] Update the protobuf submodule with the new dev branch --- carta-protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index 21d9ee728..e42c22652 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit 21d9ee728fdad1cb05a7d0e9f2d922f223a72b48 +Subproject commit e42c22652d3af676e9e2dfbe8112a6577c654751 From e10be2f8d1d1c17e0fa154aa42998efdf8e3b6ab Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 10 Jan 2023 11:18:30 +0800 Subject: [PATCH 28/41] Update the protobuf and modify the changelog and the index --- carta-protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index e42c22652..d2a608afa 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit e42c22652d3af676e9e2dfbe8112a6577c654751 +Subproject commit d2a608afa80f17805390be582b2201720e015a90 From b81fbf7528679e5bbe6173b4c2b3ea346eb51d16 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 12 Jan 2023 22:56:05 +0800 Subject: [PATCH 29/41] Get axes names through the image loader or the header entries --- src/FileList/FileExtInfoLoader.cc | 78 ++++++++++++++----------------- src/FileList/FileExtInfoLoader.h | 3 +- test/TestFileInfo.cc | 3 +- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index cab95ddfb..03217cdd8 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -200,8 +200,11 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ int spectral_axis, stokes_axis, depth_axis; if (_loader->FindCoordinateAxes( image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { + auto axes_names = _loader->GetCoordinateSystem()->worldAxisNames(); + AddShapeEntries( + extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); + // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis - AddShapeEntries(extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); info_ok = true; } @@ -596,6 +599,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: casacore::IPosition shape; std::vector direction_axes(2, -1); int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); + casacore::Vector axes_names(4, "NA"); std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; casacore::DataType data_type(casacore::DataType::TpFloat); @@ -622,17 +626,28 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: std::string ctype_index(&entry_name.back()); int axis_num = stoi(ctype_index) - 1; auto entry_value = header_entry.value(); - std::transform(entry_value.begin(), entry_value.end(), entry_value.begin(), [](unsigned char c) { return std::toupper(c); }); - - if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0 || entry_value.find("UU") == 0) { - direction_axes[0] = axis_num; - } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0 || entry_value.find("VV") == 0) { - direction_axes[1] = axis_num; - } else if (entry_value.find("STOKES") == 0) { - stokes_axis = axis_num; - } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), - [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { - spectral_axis = axis_num; + + if (!entry_value.empty()) { + entry_value = entry_value.substr(0, entry_value.find("-", 0)); + std::transform( + entry_value.begin(), entry_value.end(), entry_value.begin(), [](unsigned char c) { return std::toupper(c); }); + + // Fill in axis names + if (axis_num >= 0 && axis_num < axes_names.size()) { + axes_names[axis_num] = entry_value; + } + + // Assign axis numbers for different types + if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0 || entry_value.find("UU") == 0) { + direction_axes[0] = axis_num; + } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0 || entry_value.find("VV") == 0) { + direction_axes[1] = axis_num; + } else if (entry_value.find("STOKES") == 0) { + stokes_axis = axis_num; + } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), + [&](const std::string& key_word) { return (entry_value.find(key_word) != std::string::npos); })) { + spectral_axis = axis_num; + } } // Depth axis is not the first two axes [0, 1], i.e., non-render axis that is not stokes (if any) @@ -651,7 +666,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: } AddDataTypeEntry(extended_info, data_type); - AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis); + AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); if (compressed_fits) { compressed_fits->SetShape(shape); @@ -674,7 +689,8 @@ void FileExtInfoLoader::AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, } void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, - const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis) { + const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, + casacore::Vector& axes_names) { // Set fields/header entries for shape: dimensions, width, height, depth, stokes int num_dims(shape.size()); int width(shape(render_axes[0])); @@ -696,46 +712,24 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axes_numbers_info->set_stokes(stokes_axis + 1); axes_numbers_info->set_depth(depth_axis + 1); - // Set axis types with respect to axis numbers 0~3 - std::vector axis_types(4, "NA"); - for (int i = 0; i < extended_info.header_entries_size(); ++i) { - auto header_entry = extended_info.header_entries(i); - auto entry_name = header_entry.name(); - if (entry_name.find("CTYPE") == 0) { - auto entry_value = header_entry.value(); - if (!entry_value.empty()) { - entry_value = entry_value.substr(0, entry_value.find("-", 0)); - if (entry_name.back() == '1') { - axis_types[0] = entry_value; - } else if (entry_name.back() == '2') { - axis_types[1] = entry_value; - } else if (entry_name.back() == '3') { - axis_types[2] = entry_value; - } else if (entry_name.back() == '4') { - axis_types[3] = entry_value; - } - } - } - } - // In case if the stokes axis name is not available from the header info - if (stokes_axis > -1 && axis_types[stokes_axis] == "NA") { - axis_types[stokes_axis] = "STOKES"; + if (stokes_axis > -1 && axes_names[stokes_axis] == "NA") { + axes_names[stokes_axis] = "STOKES"; } // shape computed_entry std::string shape_string; switch (num_dims) { case 2: - shape_string = fmt::format("[{}, {}] ({}, {})", shape(0), shape(1), axis_types[0], axis_types[1]); + shape_string = fmt::format("[{}, {}] ({}, {})", shape(0), shape(1), axes_names[0], axes_names[1]); break; case 3: shape_string = - fmt::format("[{}, {}, {}] ({}, {}, {})", shape(0), shape(1), shape(2), axis_types[0], axis_types[1], axis_types[2]); + fmt::format("[{}, {}, {}] ({}, {}, {})", shape(0), shape(1), shape(2), axes_names[0], axes_names[1], axes_names[2]); break; case 4: - shape_string = fmt::format("[{}, {}, {}, {}] ({}, {}, {}, {})", shape(0), shape(1), shape(2), shape(3), axis_types[0], - axis_types[1], axis_types[2], axis_types[3]); + shape_string = fmt::format("[{}, {}, {}, {}] ({}, {}, {}, {})", shape(0), shape(1), shape(2), shape(3), axes_names[0], + axes_names[1], axes_names[2], axes_names[3]); break; } auto shape_entry = extended_info.add_computed_entries(); diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index 3b2c3ef01..88be4704e 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -51,7 +51,8 @@ class FileExtInfoLoader { // Computed entries void AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, casacore::DataType data_type); void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& direction_axes, - int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis); + int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, + casacore::Vector& axes_names); void AddInitialComputedEntries(const std::string& hdu, CARTA::FileInfoExtended& extended_info, const std::string& filename, const std::vector& render_axes, CompressedFits* compressed_fits = nullptr); void AddComputedEntries(CARTA::FileInfoExtended& extended_info, casacore::ImageInterface* image, diff --git a/test/TestFileInfo.cc b/test/TestFileInfo.cc index 9625aa978..1301fde4f 100644 --- a/test/TestFileInfo.cc +++ b/test/TestFileInfo.cc @@ -115,7 +115,8 @@ class FileExtInfoLoaderTest : public ::testing::Test { } else if (computed_entries.name() == "HDU") { CheckHeaderEntry(computed_entries, "0", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Shape") { - CheckHeaderEntry(computed_entries, "[6, 6, 5, 1] (RA, DEC, FREQ, STOKES)", CARTA::EntryType::STRING); + CheckHeaderEntry( + computed_entries, "[6, 6, 5, 1] (Right Ascension, Declination, Frequency, Stokes)", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Number of channels") { CheckHeaderEntry(computed_entries, "5", CARTA::EntryType::INT, 5); } else if (computed_entries.name() == "Number of polarizations") { From f8d44fc9829e1c9ff88abc9abb2c52a3ab9e5066 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 12 Jan 2023 23:11:48 +0800 Subject: [PATCH 30/41] Correct the definition of number of channels is spectral axis size --- src/FileList/FileExtInfoLoader.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 03217cdd8..98780a896 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -696,6 +696,7 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, int width(shape(render_axes[0])); int height(shape(render_axes[1])); int depth(depth_axis >= 0 ? shape(depth_axis) : 1); + int channels(spectral_axis >= 0 ? shape(spectral_axis) : 1); int stokes(stokes_axis >= 0 ? shape(stokes_axis) : 1); extended_info.set_dimensions(num_dims); @@ -737,13 +738,13 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, shape_entry->set_value(shape_string); shape_entry->set_entry_type(CARTA::EntryType::STRING); - if (depth_axis >= 0) { + if (spectral_axis >= 0) { // header entry for number of channels auto entry = extended_info.add_computed_entries(); entry->set_name("Number of channels"); - entry->set_value(std::to_string(depth)); + entry->set_value(std::to_string(channels)); entry->set_entry_type(CARTA::EntryType::INT); - entry->set_numeric_value(depth); + entry->set_numeric_value(channels); } if (stokes_axis >= 0) { // header entry for number of stokes From 55d6f7502329c197dbd77ca46875114b0bf5c981 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 22 Feb 2023 09:46:23 +0800 Subject: [PATCH 31/41] Skip the stokes axis when rendering an image --- src/ImageData/FileLoader.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index 9b8c0cb20..ae2cbcff7 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -203,8 +203,18 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector return false; } - // Determine axes [0, 1] will be rendered - render_axes.assign({0, 1}); + // Get spectral and stokes axis + spectral_axis = _coord_sys->spectralAxisNumber(); + stokes_axis = _coord_sys->polarizationAxisNumber(); + + // Set render axes are the first two axes that are not stokes + render_axes.resize(0); + for (int i = 0; i < _num_dims && render_axes.size() < 2; ++i) { + if (i != stokes_axis) { + render_axes.push_back(i); + } + } + _width = shape(render_axes[0]); _height = shape(render_axes[1]); _image_plane_size = _width * _height; @@ -221,10 +231,6 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector } } - // Spectral and stokes axis - spectral_axis = _coord_sys->spectralAxisNumber(); - stokes_axis = _coord_sys->polarizationAxisNumber(); - // 2D image if (_num_dims == 2) { // Save z values From 77a33ffe11daba6d11b7d8a660e3424985cbf350 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 22 Feb 2023 10:25:36 +0800 Subject: [PATCH 32/41] Get axis names from header entries that shown on the file info panel --- src/FileList/FileExtInfoLoader.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 98780a896..2672bfa4a 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -200,7 +200,7 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ int spectral_axis, stokes_axis, depth_axis; if (_loader->FindCoordinateAxes( image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { - auto axes_names = _loader->GetCoordinateSystem()->worldAxisNames(); + casacore::Vector axes_names; AddShapeEntries( extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); @@ -713,6 +713,30 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, axes_numbers_info->set_stokes(stokes_axis + 1); axes_numbers_info->set_depth(depth_axis + 1); + if (axes_names.empty()) { + // Set axis names with respect to axis numbers 1~4 + axes_names.resize(4, "NA"); + for (int i = 0; i < extended_info.header_entries_size(); ++i) { + auto header_entry = extended_info.header_entries(i); + auto entry_name = header_entry.name(); + if (entry_name.find("CTYPE") == 0) { + auto entry_value = header_entry.value(); + if (!entry_value.empty()) { + entry_value = entry_value.substr(0, entry_value.find("-", 0)); + if (entry_name.back() == '1') { + axes_names[0] = entry_value; + } else if (entry_name.back() == '2') { + axes_names[1] = entry_value; + } else if (entry_name.back() == '3') { + axes_names[2] = entry_value; + } else if (entry_name.back() == '4') { + axes_names[3] = entry_value; + } + } + } + } + } + // In case if the stokes axis name is not available from the header info if (stokes_axis > -1 && axes_names[stokes_axis] == "NA") { axes_names[stokes_axis] = "STOKES"; From 91e1c58e5338f446c7f32cd5230c5227531f91bc Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 22 Feb 2023 10:28:43 +0800 Subject: [PATCH 33/41] Modify the file info tester --- test/TestFileInfo.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/TestFileInfo.cc b/test/TestFileInfo.cc index 1301fde4f..9625aa978 100644 --- a/test/TestFileInfo.cc +++ b/test/TestFileInfo.cc @@ -115,8 +115,7 @@ class FileExtInfoLoaderTest : public ::testing::Test { } else if (computed_entries.name() == "HDU") { CheckHeaderEntry(computed_entries, "0", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Shape") { - CheckHeaderEntry( - computed_entries, "[6, 6, 5, 1] (Right Ascension, Declination, Frequency, Stokes)", CARTA::EntryType::STRING); + CheckHeaderEntry(computed_entries, "[6, 6, 5, 1] (RA, DEC, FREQ, STOKES)", CARTA::EntryType::STRING); } else if (computed_entries.name() == "Number of channels") { CheckHeaderEntry(computed_entries, "5", CARTA::EntryType::INT, 5); } else if (computed_entries.name() == "Number of polarizations") { From 793a2b6f533b379ef7dd1c7d4fee0158dbc61e1d Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Sun, 26 Feb 2023 21:14:55 +0800 Subject: [PATCH 34/41] Represent the longitudinal coordinate value in the rangge [0, 360] deg --- src/FileList/FileExtInfoLoader.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 2672bfa4a..20e184fe5 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -843,8 +843,8 @@ void FileExtInfoLoader::AddComputedEntries(CARTA::FileInfoExtended& extended_inf entry->set_value(format_coords); entry->set_entry_type(CARTA::EntryType::STRING); - bool coord0IsDir(coord0.isConform("deg")), coord1IsDir(coord1.isConform("deg")); - if (coord0IsDir || coord1IsDir) { + bool is_coord0_dir(coord0.isConform("deg")), is_coord1_dir(coord1.isConform("deg")); + if (is_coord0_dir || is_coord1_dir) { // Reference coord(s) converted to deg std::string ref_coords_deg = ConvertCoordsToDeg(coord0, coord1); // Add ref coords in deg @@ -1305,19 +1305,22 @@ std::string FileExtInfoLoader::MakeAngleString(const std::string& type, double v return fmt::format("{:.6g} {}", val, unit); } - casacore::Quantity quant1(val, unit); + casacore::Quantity quant1(val, unit), pi2(360, "deg"); + if (format == casacore::MVAngle::ANGLE && quant1.get("deg").getValue() < 0) { + quant1 += pi2; + } casacore::MVAngle mva(quant1); return mva.string(format, 10); } std::string FileExtInfoLoader::ConvertCoordsToDeg(const casacore::Quantity& coord0, const casacore::Quantity& coord1) { // If possible, convert quantities to degrees. Return formatted string - casacore::Quantity coord0_deg(coord0), coord1_deg(coord1); + casacore::Quantity coord0_deg(coord0), coord1_deg(coord1), pi2(360, "deg"); if (coord0.isConform("deg")) { - coord0_deg = coord0.get("deg"); + coord0_deg = coord0.get("deg").getValue() < 0 ? (coord0 + pi2).get("deg") : coord0.get("deg"); } if (coord1.isConform("deg")) { - coord1_deg = coord1.get("deg"); + coord1_deg = coord1.get("deg").getValue() < 0 ? (coord1 + pi2).get("deg") : coord1.get("deg"); } return fmt::format("[{}, {}]", coord0_deg, coord1_deg); From a9463a464c8c45cea15328d346a5a02001026d52 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 1 Mar 2023 01:33:53 +0800 Subject: [PATCH 35/41] Correct the syntax to initialize values for axis names --- src/FileList/FileExtInfoLoader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 20e184fe5..0f18d836c 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -715,7 +715,7 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, if (axes_names.empty()) { // Set axis names with respect to axis numbers 1~4 - axes_names.resize(4, "NA"); + axes_names.assign(casacore::Vector(4, "NA")); for (int i = 0; i < extended_info.header_entries_size(); ++i) { auto header_entry = extended_info.header_entries(i); auto entry_name = header_entry.name(); From 36868ea1ed56fe6e984d3ef9a5cfa8719aadcba6 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Thu, 2 Mar 2023 09:21:27 +0800 Subject: [PATCH 36/41] Fix the reversed PV generation when getting with fixed angular region profiles --- src/Region/RegionHandler.cc | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Region/RegionHandler.cc b/src/Region/RegionHandler.cc index 792002233..5304de6ec 100644 --- a/src/Region/RegionHandler.cc +++ b/src/Region/RegionHandler.cc @@ -2379,7 +2379,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in // Set matrix size to fill in rows; ncol = image depth (PV data) or 1 (spatial profile) auto profile_depth = per_z ? (z_range.to - z_range.from + 1) : 1; - profiles.resize(casacore::IPosition(2, num_regions, profile_depth)); + if (reverse) { + profiles.resize(casacore::IPosition(2, profile_depth, num_regions)); + } else { + profiles.resize(casacore::IPosition(2, num_regions, profile_depth)); + } int start_idx, end_idx; // for start and end of overlapping box regions float rotation = GetLineRotation(line_start, line_end); // for temporary RegionState @@ -2411,7 +2415,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in if (region_start.empty() || region_end.empty()) { // Likely part of line off image - profiles.row(iregion) = NAN; + if (reverse) { + profiles.column(iregion) = NAN; + } else { + profiles.row(iregion) = NAN; + } } else { // Set temporary region for reference image and get profile for requested file_id // pix_mvdir_mutex is not needed, locked in function while determining polygon corners @@ -2423,7 +2431,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in iregion, file_id, temp_region_state, reference_csys, per_z, z_range, stokes_index, num_pixels); spdlog::debug("Line profile {} max num pixels={}", iregion, num_pixels); - profiles.row(iregion) = region_profile; + if (reverse) { + profiles.column(iregion) = region_profile; + } else { + profiles.row(iregion) = region_profile; + } } progress = float(iregion + 1) / float(num_regions); @@ -2442,7 +2454,7 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in } else { // Polyline profiles, for spatial profile only bool trim_line(false); // Whether to skip first region after vertex - int profile_row(0); + int profile_idx(0); for (size_t iline = 0; iline < num_lines; iline++) { // Check if requirements removed @@ -2514,7 +2526,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in if (iregion == 0) { // Add rows for this line's region profiles auto num_line_profiles = trim_line ? num_regions - 1 : num_regions; - profiles.resize(casacore::IPosition(2, profiles.nrow() + num_line_profiles, 1), true); + if (reverse) { + profiles.resize(casacore::IPosition(2, 1, profiles.nrow() + num_line_profiles), true); + } else { + profiles.resize(casacore::IPosition(2, profiles.nrow() + num_line_profiles, 1), true); + } if (trim_line) { spdlog::debug("Polyline segment {} trimmed", iline); @@ -2529,7 +2545,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in if (region_start.empty() || region_end.empty()) { // Likely part of line off image - profiles.row(profile_row++) = NAN; + if (reverse) { + profiles.column(profile_idx++) = NAN; + } else { + profiles.row(profile_idx++) = NAN; + } } else { // Set temporary region for reference image and get profile for requested file_id // pix_mvdir_mutex is not needed, locked in function while determining polygon corners @@ -2541,7 +2561,11 @@ bool RegionHandler::GetFixedAngularRegionProfiles(int file_id, int region_id, in iregion, file_id, temp_region_state, reference_csys, per_z, z_range, stokes_index, num_pixels); spdlog::debug("Polyline segment {} profile {} max num pixels={}", iline, iregion, num_pixels); - profiles.row(profile_row++) = region_profile; + if (reverse) { + profiles.column(profile_idx++) = region_profile; + } else { + profiles.row(profile_idx++) = region_profile; + } } } // Done with regions along line segment From 3a3085a26abd907522633982bfe507a1087fd2de Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Mon, 13 Mar 2023 23:37:04 +0800 Subject: [PATCH 37/41] Rename variables for directional axes as spatial axes --- src/FileList/FileExtInfoLoader.cc | 51 +++++++++++++-------------- src/FileList/FileExtInfoLoader.h | 2 +- src/Frame/Frame.cc | 4 +-- src/ImageData/FileLoader.cc | 14 ++++---- src/ImageData/FileLoader.h | 2 +- src/ImageData/StokesFilesConnector.cc | 8 ++--- 6 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 72ed7d40c..e763ac5dc 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -196,13 +196,12 @@ bool FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended& extended_ AddDataTypeEntry(extended_info, data_type); - std::vector direction_axes, render_axes; + std::vector spatial_axes, render_axes; int spectral_axis, stokes_axis, depth_axis; - if (_loader->FindCoordinateAxes( - image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { + if (_loader->FindCoordinateAxes(image_shape, spatial_axes, spectral_axis, stokes_axis, render_axes, depth_axis, message)) { casacore::Vector axes_names; AddShapeEntries( - extended_info, image_shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); + extended_info, image_shape, spatial_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); // Computed entries for rendered image axes, depth axis (may not be spectral), stokes axis AddComputedEntries(extended_info, image.get(), render_axes, use_image_for_entries); @@ -597,7 +596,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: // Use header entries to determine computed entries casacore::IPosition shape; - std::vector direction_axes(2, -1); + std::vector spatial_axes(2, -1); int spectral_axis(-1), stokes_axis(-1), depth_axis(-1); casacore::Vector axes_names(4, "NA"); std::vector spectral_ctypes = {"FREQ", "WAV", "ENER", "VOPT", "ZOPT", "VELO", "VRAD", "BETA", "FELO"}; @@ -639,9 +638,9 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: // Assign axis numbers for different types if (entry_value.find("RA") == 0 || entry_value.find("GLON") == 0 || entry_value.find("UU") == 0) { - direction_axes[0] = axis_num; + spatial_axes[0] = axis_num; } else if (entry_value.find("DEC") == 0 || entry_value.find("GLAT") == 0 || entry_value.find("VV") == 0) { - direction_axes[1] = axis_num; + spatial_axes[1] = axis_num; } else if (entry_value.find("STOKES") == 0) { stokes_axis = axis_num; } else if (std::any_of(spectral_ctypes.begin(), spectral_ctypes.end(), @@ -666,7 +665,7 @@ void FileExtInfoLoader::AddInitialComputedEntries(const std::string& hdu, CARTA: } AddDataTypeEntry(extended_info, data_type); - AddShapeEntries(extended_info, shape, direction_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); + AddShapeEntries(extended_info, shape, spatial_axes, spectral_axis, stokes_axis, render_axes, depth_axis, axes_names); if (compressed_fits) { compressed_fits->SetShape(shape); @@ -689,7 +688,7 @@ void FileExtInfoLoader::AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, } void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, - const std::vector& direction_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, + const std::vector& spatial_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, casacore::Vector& axes_names) { // Set fields/header entries for shape: dimensions, width, height, depth, stokes int num_dims(shape.size()); @@ -707,8 +706,8 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, auto* axes_numbers_info = extended_info.mutable_axes_numbers(); // Change to 1-based axis indices - axes_numbers_info->set_dir_x(direction_axes[0] + 1); - axes_numbers_info->set_dir_y(direction_axes[1] + 1); + axes_numbers_info->set_dir_x(spatial_axes[0] + 1); + axes_numbers_info->set_dir_y(spatial_axes[1] + 1); axes_numbers_info->set_spectral(spectral_axis + 1); axes_numbers_info->set_stokes(stokes_axis + 1); axes_numbers_info->set_depth(depth_axis + 1); @@ -1395,7 +1394,7 @@ void FileExtInfoLoader::AddCoordRanges( if (coord_system.hasDirectionCoordinate()) { auto direction_coord = coord_system.directionCoordinate(); if (direction_coord.referenceValue().size() == 2) { - casacore::Vector direction_axes = coord_system.directionAxesNumbers(); + casacore::Vector spatial_axes = coord_system.directionAxesNumbers(); casacore::Vector axis_names = coord_system.worldAxisNames(); casacore::Vector pixels(2, 0); casacore::Vector world(2, 0); @@ -1422,8 +1421,8 @@ void FileExtInfoLoader::AddCoordRanges( } }; - double x_max_pixel = image_shape[direction_axes[0]] - 1; - double y_max_pixel = image_shape[direction_axes[1]] - 1; + double x_max_pixel = image_shape[spatial_axes[0]] - 1; + double y_max_pixel = image_shape[spatial_axes[1]] - 1; get_xy_minmax(0, 0); get_xy_minmax(x_max_pixel, y_max_pixel); get_xy_minmax(0, y_max_pixel); @@ -1438,26 +1437,26 @@ void FileExtInfoLoader::AddCoordRanges( std::string y_end = direction_coord.format(units, casacore::Coordinate::DEFAULT, y_max, 1, true, true); // Set x and y coordinate names - if (direction_axes[0] > -1 && direction_axes[0] < axis_names.size()) { - if (axis_names(direction_axes[0]) == "Right Ascension") { - axis_names(direction_axes[0]) = "RA"; - } else if (axis_names(direction_axes[0]) == "Longitude") { - axis_names(direction_axes[0]) = "LON"; + if (spatial_axes[0] > -1 && spatial_axes[0] < axis_names.size()) { + if (axis_names(spatial_axes[0]) == "Right Ascension") { + axis_names(spatial_axes[0]) = "RA"; + } else if (axis_names(spatial_axes[0]) == "Longitude") { + axis_names(spatial_axes[0]) = "LON"; } auto* x_entry = extended_info.add_computed_entries(); - x_entry->set_name(fmt::format("{} range", axis_names(direction_axes[0]))); + x_entry->set_name(fmt::format("{} range", axis_names(spatial_axes[0]))); x_entry->set_value(fmt::format("[{}, {}]", x_start, x_end)); x_entry->set_entry_type(CARTA::EntryType::STRING); } - if (direction_axes[1] > -1 && direction_axes[1] < axis_names.size()) { - if (axis_names(direction_axes[1]) == "Declination") { - axis_names(direction_axes[1]) = "DEC"; - } else if (axis_names(direction_axes[1]) == "Latitude") { - axis_names(direction_axes[1]) = "LAT"; + if (spatial_axes[1] > -1 && spatial_axes[1] < axis_names.size()) { + if (axis_names(spatial_axes[1]) == "Declination") { + axis_names(spatial_axes[1]) = "DEC"; + } else if (axis_names(spatial_axes[1]) == "Latitude") { + axis_names(spatial_axes[1]) = "LAT"; } auto* y_entry = extended_info.add_computed_entries(); - y_entry->set_name(fmt::format("{} range", axis_names(direction_axes[1]))); + y_entry->set_name(fmt::format("{} range", axis_names(spatial_axes[1]))); y_entry->set_value(fmt::format("[{}, {}]", y_start, y_end)); y_entry->set_entry_type(CARTA::EntryType::STRING); } diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index 88be4704e..f76655eaf 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -50,7 +50,7 @@ class FileExtInfoLoader { // Computed entries void AddDataTypeEntry(CARTA::FileInfoExtended& extended_info, casacore::DataType data_type); - void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& direction_axes, + void AddShapeEntries(CARTA::FileInfoExtended& extended_info, const casacore::IPosition& shape, const std::vector& spatial_axes, int spectral_axis, int stokes_axis, const std::vector& render_axes, int depth_axis, casacore::Vector& axes_names); void AddInitialComputedEntries(const std::string& hdu, CARTA::FileInfoExtended& extended_info, const std::string& filename, diff --git a/src/Frame/Frame.cc b/src/Frame/Frame.cc index 39912b78f..fc72191b2 100644 --- a/src/Frame/Frame.cc +++ b/src/Frame/Frame.cc @@ -68,8 +68,8 @@ Frame::Frame(uint32_t session_id, std::shared_ptr loader, const std: // Get shape and axis values from the loader std::string log_message; - std::vector direction_axes, render_axes; - if (!_loader->FindCoordinateAxes(_image_shape, direction_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, log_message)) { + std::vector spatial_axes, render_axes; + if (!_loader->FindCoordinateAxes(_image_shape, spatial_axes, _spectral_axis, _stokes_axis, render_axes, _z_axis, log_message)) { _open_image_error = fmt::format("Cannot determine file shape. {}", log_message); spdlog::error("Session {}: {}", session_id, _open_image_error); _valid = false; diff --git a/src/ImageData/FileLoader.cc b/src/ImageData/FileLoader.cc index ae2cbcff7..95fb6e892 100644 --- a/src/ImageData/FileLoader.cc +++ b/src/ImageData/FileLoader.cc @@ -175,11 +175,11 @@ std::shared_ptr FileLoader::GetCoordinateSystem(cons return std::make_shared(); } -bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, +bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector& spatial_axes, int& spectral_axis, int& stokes_axis, std::vector& render_axes, int& z_axis, std::string& message) { // Return image shape and axes for image. Spectral axis may or may not be z axis. // All parameters are return values. - direction_axes.assign(2, -1); + spatial_axes.assign(2, -1); spectral_axis = -1; z_axis = -1; stokes_axis = -1; @@ -219,15 +219,15 @@ bool FileLoader::FindCoordinateAxes(casacore::IPosition& shape, std::vector _height = shape(render_axes[1]); _image_plane_size = _width * _height; - // Find direction axes + // Find spatial axes if (_coord_sys->hasDirectionCoordinate()) { auto tmp_axes = _coord_sys->directionAxesNumbers(); - direction_axes[0] = tmp_axes[0]; - direction_axes[1] = tmp_axes[1]; + spatial_axes[0] = tmp_axes[0]; + spatial_axes[1] = tmp_axes[1]; } else if (_coord_sys->hasLinearCoordinate()) { auto tmp_axes = _coord_sys->linearAxesNumbers(); - for (int i = 0; i < casacore::min(tmp_axes.size(), 2); ++i) { // Assume the first two linear axes are direction axes, if any - direction_axes[i] = tmp_axes[i]; + for (int i = 0; i < casacore::min(tmp_axes.size(), 2); ++i) { // Assume the first two linear axes are spatial axes, if any + spatial_axes[i] = tmp_axes[i]; } } diff --git a/src/ImageData/FileLoader.h b/src/ImageData/FileLoader.h index ad20f6be9..b38c24197 100644 --- a/src/ImageData/FileLoader.h +++ b/src/ImageData/FileLoader.h @@ -76,7 +76,7 @@ class FileLoader { // Image shape and coordinate system axes casacore::IPosition GetShape(); std::shared_ptr GetCoordinateSystem(const StokesSource& stokes_source = StokesSource()); - bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& direction_axes, int& spectral_axis, int& stokes_axis, + bool FindCoordinateAxes(casacore::IPosition& shape, std::vector& spatial_axes, int& spectral_axis, int& stokes_axis, std::vector& render_axes, int& z_axis, std::string& message); // Slice image data (with mask applied) diff --git a/src/ImageData/StokesFilesConnector.cc b/src/ImageData/StokesFilesConnector.cc index 6e2cd93b7..5a0c3b280 100644 --- a/src/ImageData/StokesFilesConnector.cc +++ b/src/ImageData/StokesFilesConnector.cc @@ -300,7 +300,7 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) } casacore::IPosition ref_shape(0); - std::vector ref_direction_axes, ref_render_axes; + std::vector ref_spatial_axes, ref_render_axes; int ref_spectral_axis = -1; int ref_z_axis = -1; int ref_stokes_axis = -1; @@ -308,15 +308,15 @@ bool StokesFilesConnector::StokesFilesValid(std::string& err, int& stokes_axis) for (auto& loader : _loaders) { casacore::IPosition shape; - std::vector direction_axes, render_axes; + std::vector spatial_axes, render_axes; int spectral_axis; int z_axis; if (ref_index == 0) { loader.second->FindCoordinateAxes( - ref_shape, ref_direction_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, err); + ref_shape, ref_spatial_axes, ref_spectral_axis, ref_stokes_axis, ref_render_axes, ref_z_axis, err); } else { - loader.second->FindCoordinateAxes(shape, direction_axes, spectral_axis, stokes_axis, render_axes, z_axis, err); + loader.second->FindCoordinateAxes(shape, spatial_axes, spectral_axis, stokes_axis, render_axes, z_axis, err); if ((ref_shape.nelements() != shape.nelements()) || (ref_shape != shape) || (ref_spectral_axis != spectral_axis) || (ref_stokes_axis != stokes_axis)) { err = "Image shapes or axes are not consistent!"; From b1e71770500a06b83aa74a665212f4de6085ff76 Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Tue, 14 Mar 2023 11:53:53 +0800 Subject: [PATCH 38/41] Update the protobuf messages for spatial axes --- carta-protobuf | 2 +- src/FileList/FileExtInfoLoader.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/carta-protobuf b/carta-protobuf index d2a608afa..1db79c8fb 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit d2a608afa80f17805390be582b2201720e015a90 +Subproject commit 1db79c8fb8aba6958b75c3b2c183b547aae86338 diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index e763ac5dc..92d1444a7 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -706,8 +706,8 @@ void FileExtInfoLoader::AddShapeEntries(CARTA::FileInfoExtended& extended_info, auto* axes_numbers_info = extended_info.mutable_axes_numbers(); // Change to 1-based axis indices - axes_numbers_info->set_dir_x(spatial_axes[0] + 1); - axes_numbers_info->set_dir_y(spatial_axes[1] + 1); + axes_numbers_info->set_spatial_x(spatial_axes[0] + 1); + axes_numbers_info->set_spatial_y(spatial_axes[1] + 1); axes_numbers_info->set_spectral(spectral_axis + 1); axes_numbers_info->set_stokes(stokes_axis + 1); axes_numbers_info->set_depth(depth_axis + 1); From a01fe00fd5ef7c1bd4b652249b0e7600f356523a Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 15 Mar 2023 01:06:57 +0800 Subject: [PATCH 39/41] Fix the reference Dec value shown on the file info panel --- src/FileList/FileExtInfoLoader.cc | 13 +++++++------ src/FileList/FileExtInfoLoader.h | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index 92d1444a7..e91dc8266 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -845,7 +845,7 @@ void FileExtInfoLoader::AddComputedEntries(CARTA::FileInfoExtended& extended_inf bool is_coord0_dir(coord0.isConform("deg")), is_coord1_dir(coord1.isConform("deg")); if (is_coord0_dir || is_coord1_dir) { // Reference coord(s) converted to deg - std::string ref_coords_deg = ConvertCoordsToDeg(coord0, coord1); + std::string ref_coords_deg = ConvertCoordsToDeg(axis_names(display_axis0), coord0, axis_names(display_axis1), coord1); // Add ref coords in deg entry = extended_info.add_computed_entries(); entry->set_name("Image ref coords (deg)"); @@ -1140,7 +1140,7 @@ void FileExtInfoLoader::AddComputedEntriesFromHeaders( bool q1IsDir(q1.isConform("deg")), q2IsDir(q2.isConform("deg")); if (q1IsDir || q2IsDir) { // Reference coord(s) converted to deg - std::string ref_coords_deg = ConvertCoordsToDeg(q1, q2); + std::string ref_coords_deg = ConvertCoordsToDeg(coord_name1, q1, coord_name2, q2); auto comp_entry = extended_info.add_computed_entries(); comp_entry->set_name("Image ref coords (deg)"); comp_entry->set_value(ref_coords_deg); @@ -1305,21 +1305,22 @@ std::string FileExtInfoLoader::MakeAngleString(const std::string& type, double v } casacore::Quantity quant1(val, unit), pi2(360, "deg"); - if (format == casacore::MVAngle::ANGLE && quant1.get("deg").getValue() < 0) { + if (type.find("Longitude") != std::string::npos && quant1.get("deg").getValue() < 0) { quant1 += pi2; } casacore::MVAngle mva(quant1); return mva.string(format, 10); } -std::string FileExtInfoLoader::ConvertCoordsToDeg(const casacore::Quantity& coord0, const casacore::Quantity& coord1) { +std::string FileExtInfoLoader::ConvertCoordsToDeg( + const std::string& type0, const casacore::Quantity& coord0, const std::string& type1, const casacore::Quantity& coord1) { // If possible, convert quantities to degrees. Return formatted string casacore::Quantity coord0_deg(coord0), coord1_deg(coord1), pi2(360, "deg"); if (coord0.isConform("deg")) { - coord0_deg = coord0.get("deg").getValue() < 0 ? (coord0 + pi2).get("deg") : coord0.get("deg"); + coord0_deg = (type0 == "Longitude" && coord0.get("deg").getValue() < 0) ? (coord0 + pi2).get("deg") : coord0.get("deg"); } if (coord1.isConform("deg")) { - coord1_deg = coord1.get("deg").getValue() < 0 ? (coord1 + pi2).get("deg") : coord1.get("deg"); + coord1_deg = (type1 == "Longitude" && coord1.get("deg").getValue() < 0) ? (coord1 + pi2).get("deg") : coord1.get("deg"); } return fmt::format("[{}, {}]", coord0_deg, coord1_deg); diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index f76655eaf..338dbb5b1 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -67,7 +67,8 @@ class FileExtInfoLoader { std::string MakeAngleString(const std::string& type, double val, const std::string& unit); // Convert Quantities and return formatted string - std::string ConvertCoordsToDeg(const casacore::Quantity& coord0, const casacore::Quantity& coord1); + std::string ConvertCoordsToDeg( + const std::string& type0, const casacore::Quantity& coord0, const std::string& type1, const casacore::Quantity& coord1); std::string ConvertIncrementToArcsec(const casacore::Quantity& inc0, const casacore::Quantity& inc1); void GetCoordNames(std::string& ctype1, std::string& ctype2, std::string& radesys, std::string& coord_name1, std::string& coord_name2, From 341e7993701ed19788fb2399a62c34e85a6ee97a Mon Sep 17 00:00:00 2001 From: Cheng-Chin Chiang Date: Wed, 15 Mar 2023 09:25:20 +0800 Subject: [PATCH 40/41] Minor code changes --- src/FileList/FileExtInfoLoader.cc | 20 ++++++++------------ src/FileList/FileExtInfoLoader.h | 3 +-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/FileList/FileExtInfoLoader.cc b/src/FileList/FileExtInfoLoader.cc index e91dc8266..75befb3fb 100644 --- a/src/FileList/FileExtInfoLoader.cc +++ b/src/FileList/FileExtInfoLoader.cc @@ -845,7 +845,8 @@ void FileExtInfoLoader::AddComputedEntries(CARTA::FileInfoExtended& extended_inf bool is_coord0_dir(coord0.isConform("deg")), is_coord1_dir(coord1.isConform("deg")); if (is_coord0_dir || is_coord1_dir) { // Reference coord(s) converted to deg - std::string ref_coords_deg = ConvertCoordsToDeg(axis_names(display_axis0), coord0, axis_names(display_axis1), coord1); + std::string ref_coords_deg = fmt::format("[{}, {}]", ConvertCoordsToDeg(axis_names(display_axis0), coord0), + ConvertCoordsToDeg(axis_names(display_axis1), coord1)); // Add ref coords in deg entry = extended_info.add_computed_entries(); entry->set_name("Image ref coords (deg)"); @@ -1140,7 +1141,7 @@ void FileExtInfoLoader::AddComputedEntriesFromHeaders( bool q1IsDir(q1.isConform("deg")), q2IsDir(q2.isConform("deg")); if (q1IsDir || q2IsDir) { // Reference coord(s) converted to deg - std::string ref_coords_deg = ConvertCoordsToDeg(coord_name1, q1, coord_name2, q2); + std::string ref_coords_deg = fmt::format("[{}, {}]", ConvertCoordsToDeg(coord_name1, q1), ConvertCoordsToDeg(coord_name2, q2)); auto comp_entry = extended_info.add_computed_entries(); comp_entry->set_name("Image ref coords (deg)"); comp_entry->set_value(ref_coords_deg); @@ -1312,18 +1313,13 @@ std::string FileExtInfoLoader::MakeAngleString(const std::string& type, double v return mva.string(format, 10); } -std::string FileExtInfoLoader::ConvertCoordsToDeg( - const std::string& type0, const casacore::Quantity& coord0, const std::string& type1, const casacore::Quantity& coord1) { +std::string FileExtInfoLoader::ConvertCoordsToDeg(const std::string& type, const casacore::Quantity& coord) { // If possible, convert quantities to degrees. Return formatted string - casacore::Quantity coord0_deg(coord0), coord1_deg(coord1), pi2(360, "deg"); - if (coord0.isConform("deg")) { - coord0_deg = (type0 == "Longitude" && coord0.get("deg").getValue() < 0) ? (coord0 + pi2).get("deg") : coord0.get("deg"); + casacore::Quantity coord_deg(coord), pi2(360, "deg"); + if (coord.isConform("deg")) { + coord_deg = (type == "Longitude" && coord.get("deg").getValue() < 0) ? (coord + pi2).get("deg") : coord.get("deg"); } - if (coord1.isConform("deg")) { - coord1_deg = (type1 == "Longitude" && coord1.get("deg").getValue() < 0) ? (coord1 + pi2).get("deg") : coord1.get("deg"); - } - - return fmt::format("[{}, {}]", coord0_deg, coord1_deg); + return fmt::format("{}", coord_deg); } std::string FileExtInfoLoader::ConvertIncrementToArcsec(const casacore::Quantity& inc0, const casacore::Quantity& inc1) { diff --git a/src/FileList/FileExtInfoLoader.h b/src/FileList/FileExtInfoLoader.h index 338dbb5b1..23e3bf80a 100644 --- a/src/FileList/FileExtInfoLoader.h +++ b/src/FileList/FileExtInfoLoader.h @@ -67,8 +67,7 @@ class FileExtInfoLoader { std::string MakeAngleString(const std::string& type, double val, const std::string& unit); // Convert Quantities and return formatted string - std::string ConvertCoordsToDeg( - const std::string& type0, const casacore::Quantity& coord0, const std::string& type1, const casacore::Quantity& coord1); + std::string ConvertCoordsToDeg(const std::string& type, const casacore::Quantity& coord); std::string ConvertIncrementToArcsec(const casacore::Quantity& inc0, const casacore::Quantity& inc1); void GetCoordNames(std::string& ctype1, std::string& ctype2, std::string& radesys, std::string& coord_name1, std::string& coord_name2, From c446d83d2788686adff1c4f85598a929c3b10b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrianna=20Pi=C5=84ska?= Date: Wed, 22 Mar 2023 12:44:37 +0200 Subject: [PATCH 41/41] bumped protobuf commit --- carta-protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carta-protobuf b/carta-protobuf index d2a608afa..aeb52e8a8 160000 --- a/carta-protobuf +++ b/carta-protobuf @@ -1 +1 @@ -Subproject commit d2a608afa80f17805390be582b2201720e015a90 +Subproject commit aeb52e8a87c80708665532a525af1fd42b9d807b