Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • andrea.giannetti/swiss_army_knife_stable
1 result
Select Git revision
Show changes
Commits on Source (2)
......@@ -13,6 +13,16 @@ A docker-compose script is included in the root folder of this repository ([dock
```bash
docker compose up --build
```
*Before the first run:* Set the following environment variables, as specified in the documentation:
- DB_USER: the database user;
- DB_PASS: the password for the user;
- DB_HOST: the database host, if you are running SAK locally, set it to localhost;
- DB_NAME: the database name;
- DB_PORT: the port to use to connect to the database.
A convenience script is provided to create the credentials file for future connections [create_db_credentials_file.py](etl/create_db_credentials_file.py).
This must be executed before running docker compose, or the credentials file can be compiled by hand.
The following parameters can be set by adding the `command` override in the `etl` section of the docker-compose file:
* --run_id: the run id of the grid to process; if not provided, generates a new run_id;
......
import base64
import os
import argparse
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('--user', default='sak_user')
parser.add_argument('--psw')
parser.add_argument('--host', default='localhost')
parser.add_argument('--db_name', default='sak_database')
parser.add_argument('--port', default=31000)
args = parser.parse_args()
args_dict = vars(args)
key_map = {'user': 'DB_USER',
'psw': 'DB_PASS',
'host': 'DB_HOST',
'db_name': 'DB_NAME',
'port': 'DB_PORT'}
for key in args_dict.keys():
print(os.getenv(key_map[key]))
if os.getenv(key_map[key]) is not None:
args_dict[key] = os.getenv(key_map[key])
assert args.psw is not None
credentials_dict = {}
for key in key_map.keys():
credentials_dict[key_map[key]] = getattr(args, key)
for key in ['DB_USER', 'DB_PASS']:
print(credentials_dict[key])
credentials_dict[key] = base64.b64encode(credentials_dict[key].encode()).decode()
with open(os.path.join('credentials', 'db_credentials.yml'), 'w') as outfile:
yaml.dump(credentials_dict, outfile)
......@@ -69,7 +69,11 @@ def main(ratios_to_fit: Union[List[str], None] = None):
plt.scatter(data_clean[_column_to_fit], data_clean['avg_nh2'], marker='+', alpha=0.1, color='red')
for components in x0[ratio_string]:
plt.plot(x_reg, approx(x_reg, *components), color='cyan')
plt.show()
plt.savefig(os.path.join('..',
'publications',
'6373bb408e4040043398e495',
'referee',
f'analytical_expressions_comparison_{ratio_string}.png'))
if __name__ == '__main__':
......
......@@ -86,7 +86,7 @@ def make_volume_densities_comparison_figure(df_full: pd.DataFrame):
df_merge['best_fit'],
yerr=uncertainty_array,
fmt='none')
plt.plot([2e4, 8e5], [2e4, 8e6], color='red')
plt.plot([2e4, 2e6], [2e4, 2e6], color='red')
plt.loglog()
plt.xlabel('<$n$(H$_{2, dust}$)> [cm$^{-3}$]')
plt.ylabel('<$n$(H$_{2, SAK}$)> [cm$^{-3}$]')
......@@ -98,10 +98,10 @@ def make_volume_densities_comparison_figure(df_full: pd.DataFrame):
def main():
df_full = get_poc_results(line_fit_filename='ch3oh_data_top35.csv')
df_full.rename(columns={'class_phys': 'Class'}, inplace=True)
make_volume_densities_comparison_figure(df_full=df_full)
df_full = df_full[(df_full['mass'] < 10000) & (df_full['mass'] > 300)]
make_ecdf_figure(df_full=df_full)
make_violin_figure(df_full=df_full)
make_volume_densities_comparison_figure(df_full=df_full)
if __name__ == '__main__':
......
......@@ -61,21 +61,21 @@ remap_columns = OrderedDict([
('hpd_interval', ('67\% HPD', density_format)),
('mass', ('Mass', '$[10^2 \mathrm{M_\odot}]$')),
('distance', ('Distance', '[kpc]')),
('tpeak_86', ('$T_{MB, 86}$', '[K]')),
('tpeak_86', ('$T_{MB,(2_{-1}-1_{-1})}$', '[K]')),
('linewidth_86', ('$FWHM_{(2_K-1_K)}$', fwhm_units)),
('tpeak_87', ('$T_{MB, 87}$', '[K]')),
('tpeak_87', ('$T_{MB,(2_{0}-1_{0})}$', '[K]')),
('linewidth_87', ('$FWHM_{87}$', '[km s$^{-1}]$')),
('tpeak_88', ('$T_{MB, 88}$', '[K]')),
('tpeak_88', ('$T_{MB,(2_{1}-1_{1})}$', '[K]')),
('linewidth_88', ('$FWHM_{88}$', '[km s$^{-1}]$')),
# ('rms_noise_86', ('$\sigma_{96.7GHz}$', '[K]')),
('tpeak_256', ('$T_{MB, 256}$', '[K]')),
('tpeak_256', ('$T_{MB,(5_{0}-4_{0})}$', '[K]')),
('linewidth_256', ('$FWHM_{256}$', fwhm_units)),
('tpeak_257', ('$T_{MB, 257}$', '[K]')),
('tpeak_257', ('$T_{MB,(5_{-1}-4_{-1})}$', '[K]')),
('linewidth_257', ('$FWHM_{(5_K-4_K)}$', fwhm_units)),
# ('rms_noise_256', ('$\sigma_{241.7GHz}$', '[K]')),
('tpeak_380', ('$T_{MB, 380}$', '[K]')),
('tpeak_380', ('$T_{MB,(7_{0}-6_{0})}$', '[K]')),
('linewidth_380', ('$FWHM_{380}$', fwhm_units)),
('tpeak_381', ('$T_{MB, 381}$', '[K]')),
('tpeak_381', ('$T_{MB,(7_{-1}-6_{-1})}$', '[K]')),
('linewidth_381', ('$FWHM_{(7_K-6_K)}$', fwhm_units)),
# ('rms_noise_380', ('$\sigma_{338.3GHz}$', '[K]')),
])
......@@ -98,14 +98,14 @@ with open(os.path.join('prs', 'output', 'poc_tables', 'fit_results.tex'), 'w') a
outfile.write(latex_table)
table_cols = [
[('Source', ''), ('$T_{MB, 86}$', '[K]'), ('$T_{MB, 87}$', '[K]'), ('$T_{MB, 88}$', '[K]'), ('$FWHM_{(2_K-1_K)}$',
[('Source', ''), ('$T_{MB,(2_{-1}-1_{-1})}$', '[K]'), ('$T_{MB,(2_{0}-1_{0})}$', '[K]'), ('$T_{MB,(2_{1}-1_{1})}$', '[K]'), ('$FWHM_{(2_K-1_K)}$',
fwhm_units)],
[('Source', ''), ('$T_{MB, 256}$', '[K]'), ('$T_{MB, 257}$', '[K]'), ('$FWHM_{(5_K-4_K)}$', fwhm_units), ('$T_{MB, 380}$', '[K]'), ('$T_{MB, 381}$', '[K]'), ('$FWHM_{(7_K-6_K)}$',
[('Source', ''), ('$T_{MB,(5_{0}-4_{0})}$', '[K]'), ('$T_{MB,(5_{-1}-4_{-1})}$', '[K]'), ('$FWHM_{(5_K-4_K)}$', fwhm_units), ('$T_{MB,(7_{0}-6_{0})}$', '[K]'), ('$T_{MB,(7_{-1}-6_{-1})}$', '[K]'), ('$FWHM_{(7_K-6_K)}$',
fwhm_units), ]
]
captions = [
'Line properties of the lines in the $(2_K-1_K)$ methanol band. Only one FWHM is listed because the fit is performed forcing all lines to have the same width. A non-detection is indicated with three dots.',
'Line properties of the lines in the $(5_K-4_K)$ and $(7_K-6_K)$ methanol bands. Only one FWHM is listed per band because the fit is performed forcing all lines to have the same width. A non-detection is indicated with three dots, while missing data are indicated with \'N/A\'.',
"Line properties of the lines in the $(2_K-1_K)$ methanol band. Only one FWHM is listed because the fit is performed forcing all lines to have the same width. The main-beam temperature of the lines is indicated as $T_{MB,J_K-J',_K'}$. A non-detection is indicated with three dots.",
"Line properties of the lines in the $(5_K-4_K)$ and $(7_K-6_K)$ methanol bands. Only one FWHM is listed per band because the fit is performed forcing all lines to have the same width. The main-beam temperature of the lines is indicated as $T_{MB,J_K-J',_K'}$. A non-detection is indicated with three dots, while missing data are indicated with \'N/A\'.",
]
labels = [
'tab:poc_lines_3mm',
......