#include <casacore/images/Images/ImageInterface.h>
#include <casacore/images/Images/ImageOpener.h>
#include <casacore/scimath/Mathematics/GaussianBeam.h>
|
bool | CheckFolderPaths (std::string &top_level_string, std::string &starting_string) |
| Validates and resolves folder paths, ensuring the starting directory is within the top-level directory.
|
|
bool | IsSubdirectory (std::string folder, std::string top_folder) |
| Determines whether a given folder is a subdirectory of a specified top-level folder.
|
|
casacore::String | GetResolvedFilename (const std::string &root_dir, const std::string &directory, const std::string &file, std::string &message) |
| Resolves a file path based on a given root directory and relative subdirectory.
|
|
casacore::ImageOpener::ImageTypes | CasacoreImageType (const std::string &filename) |
| Determines the image type of a given filename using Casacore.
|
|
void | GetSpectralCoordPreferences (casacore::ImageInterface< float > *image, bool &prefer_velocity, bool &optical_velocity, bool &prefer_wavelength, bool &air_wavelength) |
| Determines the spectral coordinate preferences based on an image's native spectral type.
|
|
std::string | FormatBeam (const casacore::GaussianBeam &gaussian_beam) |
| Formats a Gaussian beam's parameters into a human-readable string.
|
|
std::string | FormatQuantity (const casacore::Quantity &quantity) |
| Formats a Casacore quantity into a human-readable string.
|
|
void | NormalizeUnit (casacore::String &unit) |
| Normalizes a given unit string to conform to standard Casacore unit conventions (case-sensitive).
|
|
bool | IsGildasUnit (const casacore::String &unit) |
|
bool | ParseHistoryBeamHeader (std::string &header, std::string &bmaj, std::string &bmin, std::string &bpa) |
| Parses an AIPS-style beam header to extract beam parameters with regular expression.
|
|
◆ CasacoreImageType()
casacore::ImageOpener::ImageTypes CasacoreImageType |
( |
const std::string & |
filename | ) |
|
|
inline |
Determines the image type of a given filename using Casacore.
This function utilizes casacore::ImageOpener::imageType
to identify the type of an image file based on its name.
- Parameters
-
[in] | filename | A string reference to the path to the image file.. |
- Returns
- The image type as a
casacore::ImageOpener::ImageTypes
value.
◆ CheckFolderPaths()
bool CheckFolderPaths |
( |
std::string & |
top_level_string, |
|
|
std::string & |
starting_string |
|
) |
| |
Validates and resolves folder paths, ensuring the starting directory is within the top-level directory.
- Parameters
-
[in,out] | top_level_string | Reference to the top-level directory path. It is updated to its resolved absolute path. |
[in,out] | starting_string | Reference to the starting directory path. It is updated to its resolved absolute path. |
- Returns
true
if the paths are valid and the starting directory is within the top-level directory, otherwise false
.
◆ FormatBeam()
std::string FormatBeam |
( |
const casacore::GaussianBeam & |
gaussian_beam | ) |
|
Formats a Gaussian beam's parameters into a human-readable string.
- Parameters
-
[in] | gaussian_beam | The reference to the Casacore Gaussian beam object whose parameters will be formatted. |
- Returns
- A formatted string containing the beam's major axis, minor axis, and position angle, including their respective units.
This function retrieves the major axis, minor axis, and position angle (PA) of a given casacore::GaussianBeam
and formats them into a structured string with six decimal places of precision.
- Note
- The output format is:
"major: <value> <unit> minor: <value> <unit> pa: <value> <unit>"
◆ FormatQuantity()
std::string FormatQuantity |
( |
const casacore::Quantity & |
quantity | ) |
|
Formats a Casacore quantity into a human-readable string.
- Parameters
-
[in] | quantity | A reference to a Casacore Quantity object that represents the quantity to be formatted. |
- Returns
- A formatted string in the form of
"<value> <unit>"
, where <value>
is displayed with six decimal places.
This function converts a casacore::Quantity
into a string representation with six decimal places of precision, including its unit.
◆ GetResolvedFilename()
casacore::String GetResolvedFilename |
( |
const std::string & |
root_dir, |
|
|
const std::string & |
directory, |
|
|
const std::string & |
file, |
|
|
std::string & |
message |
|
) |
| |
Resolves a file path based on a given root directory and relative subdirectory.
- Parameters
-
[in] | root_dir | A string refence to the root directory in which the file is expected to reside. |
[in] | directory | A string refence to the relative directory path within the root directory. |
[in] | file | A string refence to the name of the file to resolve. |
[out] | message | A reference to a string that will contain an error message if the resolution fails. |
- Returns
- The resolved absolute filename as a
casacore::String
if successful, otherwise an empty string.
This function constructs an absolute file path using a specified root directory, a relative subdirectory, and a file name. It checks whether the resulting file path exists and is readable. If any issue is encountered, an error message is set.
◆ GetSpectralCoordPreferences()
void GetSpectralCoordPreferences |
( |
casacore::ImageInterface< float > * |
image, |
|
|
bool & |
prefer_velocity, |
|
|
bool & |
optical_velocity, |
|
|
bool & |
prefer_wavelength, |
|
|
bool & |
air_wavelength |
|
) |
| |
Determines the spectral coordinate preferences based on an image's native spectral type.
- Parameters
-
[in] | image | Pointer to a casacore::ImageInterface<float> representing the image whose spectral coordinate system will be analyzed. |
[out] | prefer_velocity | A boolean value set to true if velocity-based representation is preferred. |
[out] | optical_velocity | A boolean value set to true if optical velocity representation is preferred. |
[out] | prefer_wavelength | A boolean value set to true if wavelength-based representation is preferred. |
[out] | air_wavelength | A boolean value set to true if air wavelength representation is preferred. |
This function analyses the spectral coordinate system of the provided image
and sets preference flags for velocity, wavelength, and their specific variations. It considers the image's native spectral type and applies special handling for CartaMiriadImage
types.
- Note
- If the image contains a spectral axis, its native type is determined and used to update the preference flags accordingly.
- Warning
- The function modifies the output parameters in place; ensure they are initialized properly.
◆ IsGildasUnit()
bool IsGildasUnit |
( |
const casacore::String & |
unit | ) |
|
This function uses regex to check if unit is in the GILDAS CLASS software format "unit (Ttype)" where the "type" describes the temperature T. It also tests for casacore Unit name changes where " " and "*" are replaced with ".". For example: "K (Ta*)" --> "K.(Ta.)" in casacore.
◆ IsSubdirectory()
bool IsSubdirectory |
( |
std::string |
folder, |
|
|
std::string |
top_folder |
|
) |
| |
Determines whether a given folder is a subdirectory of a specified top-level folder.
- Parameters
-
[in] | folder | The folder path to check, represented as a string. |
[in] | top_folder | The top-level folder path to compare against, represented as a string. |
- Returns
true
if folder
is a subdirectory of top_folder
or the same directory, false
otherwise.
This function checks if folder
is a subdirectory of top_folder
by resolving both paths to their absolute, weakly canonical forms and then traversing up the directory hierarchy.
- Warning
- If
top_folder
is empty, the function will always return true
.
◆ NormalizeUnit()
void NormalizeUnit |
( |
casacore::String & |
unit | ) |
|
Normalizes a given unit string to conform to standard Casacore unit conventions (case-sensitive).
- Parameters
-
[in,out] | unit | A string reference to the unit string to normalise. It is modified in place with the corrected and validated unit name if possible. |
This function converts various unit representations into their standardised Casacore equivalents. It replaces non-standard units with correct forms, fixes case inconsistencies, and removes invalid characters. Additionally, it attempts to map the unit to a valid Casacore unit using UnitMap::fromFITS
and UnitVal::check
.
- Note
- If the unit contains a recognized prefix, the function attempts to normalise with and without the prefix.
- Warning
- If the unit cannot be resolved to a known Casacore unit, it remains unchanged.
- Exceptions
-
casacore::AipsError | Caught internally when Casacore unit conversions fail. |
◆ ParseHistoryBeamHeader()
bool ParseHistoryBeamHeader |
( |
std::string & |
header, |
|
|
std::string & |
bmaj, |
|
|
std::string & |
bmin, |
|
|
std::string & |
bpa |
|
) |
| |
Parses an AIPS-style beam header to extract beam parameters with regular expression.
- Parameters
-
[in] | header | A string reference to the history beam header string to be parsed. |
[out] | bmaj | A string reference to the extracted major axis value with its unit. |
[out] | bmin | A string reference to the extracted minor axis value with its unit. |
[out] | bpa | A string reference to the extracted position angle value with its unit. |
- Returns
true
if the header was successfully parsed and values were extracted, otherwise false
.
This function uses regular expressions to extract the major axis (BMAJ), minor axis (BMIN), and position angle (BPA) from an AIPS-style history beam header string. It handles two common formats: one using "Beam =" notation and another using "BMAJ=", "BMIN=", and "BPA=" notation.
- Note
- Units are normalized to "deg" when "degrees" is found in the header.
- Warning
- If the header format does not match expected patterns, the function logs a debug message and returns
false
.