-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# config.py | ||
|
||
""" | ||
This module handles dynamic loading of constants for the QSO absorber finder. | ||
It first loads the default constants from the constants module and then optionally | ||
overwrites them with user-provided constants from a specified file. | ||
If an environment variable 'QSO_CONSTANTS_FILE' is set and points to a valid file, the constants | ||
from that file will be loaded and used instead of the default ones. | ||
Usage: | ||
1. Ensure the default constants are defined in the constants module. | ||
2. Optionally provide a custom constants file path in the environment variable 'QSO_CONSTANTS_FILE'. | ||
3. Import constants from this module in other parts of the application to use the loaded constants. | ||
""" | ||
|
||
import importlib.util | ||
import os | ||
|
||
# Default constants | ||
from .constants import * | ||
|
||
def load_constants(constants_file): | ||
""" | ||
Dynamically loads constants from a user-provided file. | ||
Parameters: | ||
constants_file (str): Path to the file containing user-defined constants. | ||
""" | ||
spec = importlib.util.spec_from_file_location("user_constants", constants_file) | ||
user_constants = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(user_constants) | ||
|
||
# Update the globals dictionary with the user-defined constants | ||
globals().update(user_constants.__dict__) | ||
|
||
# Check if the environment variable for the constants file is set | ||
constants_file = os.getenv('QSO_CONSTANTS_FILE') | ||
if constants_file and os.path.isfile(constants_file): | ||
load_constants(constants_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
qsoabsfind | ||
============ | ||
|
||
Instructions | ||
------------- | ||
|
||
Please read/perform following details. | ||
|
||
`qsoabsfind --help` | ||
|
||
Please go through all the functions and their instructions in case you have any doubt. | ||
|
||
The **input** `fits file` must have a specific structure with following hdu extensions. | ||
|
||
- `FLUX` Should contain ideally the residual spectra (usually the flux/continuum, i.e. the continuum normalized spectra) | ||
- `WAVELENGTH` observed wavelength (in Ang) | ||
- `ERROR` error on residuals | ||
- `TGTDETALS` spectral details (like Z_QSO, RA_QSO, DEC_QSO...) | ||
|
||
The user-defined **constant-file** must follow the same structure as the `qsoabsfind.constants`, otherwise the code will fail. In case, users want to use the default search parameters, they can tun without `constant-file` option. | ||
|
||
The **output** `fits file` will have the hdu `ABSORBER`, that will arrays such as | ||
|
||
- `INDEX_SPEC` index of quasar (can be used to read the RA, DEC ans Z of QSOs) | ||
- `Z_ABS`: redshift of absorber | ||
- `${METAL}_${line}_EW`: Rest-frame EWs of absorber lines (like MgII 2796, 2803 or CIV 1548, 1550) (in Ang) | ||
- `${METAL}_${line}_EW_ERROR`: uncertainities in rest-frame EWs of absorber lines (like MgII 2796, 2803 or CIV 1548, 1550) (in Ang) | ||
- `Z_ABS_ERR`: measured error in redshift of absorber | ||
- `GAUSS_FIT`: rest-frame fitting parameters of double gaussian to the absorber doublet (the width can be used to measure the velocity dispersion) | ||
- `GAUSS_FIT_STD`: uncertainities in rest-frame fitting parameters of double gaussian to the absorber doublet (the width can be used to measure the velocity dispersion) | ||
- `SN_${METAL}_${line}`: S/N of the lines | ||
- `${metal}_EW_TOTAL`: Total EW of the lines (in Ang) | ||
- `${metal}_EW_TOTAL_ERROR`: uncertainities in total EW of the lines (in Ang) | ||
|
||
|
||
Thanks, | ||
Abhijeet Anand | ||
Lawrence Berkeley National Lab | ||
|
||
If you have any questions/suggestions, please feel free to write to [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters