Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tool Meerkat Galaxy clusters to 0.0.1+galaxy0 #160

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tools/meerkat-galaxy-clusters/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
categories:
- Astronomy
description: Meerkat Galaxy clusters
homepage_url: null
long_description: Meerkat Galaxy clusters
name: meerkat_galaxy_clusters_astro_tool
owner: astroteam
remote_repository_url: https://github.com/esg-epfl-apc/tools-astro/tree/main/tools
type: unrestricted
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<tool id="meerkat_galaxy_clusters_astro_tool" name="Meerkat Galaxy clusters" version="0.0.1+galaxy0" profile="23.0">
<requirements>
<requirement type="package" version="8.31.0">ipython</requirement>
<requirement type="package" version="2.2.3">pandas</requirement>
<requirement type="package" version="3.10.0">matplotlib</requirement>
<requirement type="package" version="7.0.0">astropy</requirement>
<requirement type="package" version="2.2.1">numpy</requirement>
<requirement type="package" version="1.2.27">oda-api</requirement>
<requirement type="package" version="2.0.2">photutils</requirement>
<requirement type="package" version="1.35.88">boto3</requirement>
<requirement type="package" version="7.16.4">nbconvert</requirement>
<!--Requirements string 'nb2workflow[cwl,service,rdf,mmoda]
' can't be converted automatically. Please add the galaxy/conda requirement manually or modify the requirements file!-->
</requirements>
<command detect_errors="exit_code">python '$__tool_directory__/ps_around_source.py'</command>
<configfiles>
<inputs name="inputs" filename="inputs.json" data_style="paths" />
</configfiles>
<inputs>
<param name="ra" type="float" value="260" label="ra (unit: deg)" />
<param name="dec" type="float" value="-82" label="dec (unit: deg)" />
<param name="thresh_arcmin" type="integer" value="20" label="thresh_arcmin (unit: arcmin)" />
<param name="clust_name" type="text" value="test_if_in_clusters(ra, dec)" label="clust_name" />
</inputs>
<outputs />
<tests>
<test expect_num_outputs="0">
<param name="ra" value="260" />
<param name="dec" value="-82" />
<param name="thresh_arcmin" value="20" />
<param name="clust_name" value="test_if_in_clusters(ra, dec)" />
<assert_stdout>
<has_text text="*** Job finished successfully ***" />
</assert_stdout>
</test>
</tests>
<environment_variables>
<environment_variable name="BASEDIR">$__tool_directory__</environment_variable>
<environment_variable name="GALAXY_TOOL_DIR">$__tool_directory__</environment_variable>
</environment_variables>
</tool>
89 changes: 89 additions & 0 deletions tools/meerkat-galaxy-clusters/ps_around_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env python
# coding: utf-8

# flake8: noqa

import json
import os
import warnings

warnings.filterwarnings("ignore")

from catalogs_methods import *
from data_treatment import *
from parameters import *
from plots import *

# ------------------------------------------------------------------------------------
# ra/dec coordinates of target point of the sky, and the aperture to find sources in
# ------------------------------------------------------------------------------------
ra = 260 # http://odahub.io/ontology#AngleDegrees
dec = -82 # http://odahub.io/ontology#AngleDegrees
thresh_arcmin = 20 # http://odahub.io/ontology#arcmin

# -----------------------------------------------------
# Handling errors and exceptions
# -----------------------------------------------------
if ra < 0 or ra > 360:
raise ValueError(
"Wrong value: the right ascension (ra) must be between 0 and 360 degrees!"
)
if dec < -90 or dec > 90:
raise ValueError(
"Wrong value: the declination (dec) must be between -90 and 90 degrees!"
)

# Test if the ra/dec coordinates lie in a MGCLS field (cluster)
# -----------------------------------------------------------------------------
clust_name = test_if_in_clusters(ra, dec)

if clust_name == 0:

raise Exception(
"Error: the entered coordinates do not lie within any MGCLS field (cluster)"
)

_galaxy_wd = os.getcwd()

with open("inputs.json", "r") as fd:
inp_dic = json.load(fd)
if "_data_product" in inp_dic.keys():
inp_pdic = inp_dic["_data_product"]
else:
inp_pdic = inp_dic

for _vn in ["ra", "dec", "thresh_arcmin", "clust_name"]:
globals()[_vn] = type(globals()[_vn])(inp_pdic[_vn])

# ----------------------------------------------------------------------------------
# Determination of the sources found (or not) in the given aperture
# ----------------------------------------------------------------------------------
sources = find_sources_around_coordinates(ra, dec, thresh_arcmin)
msg_out = sources["out_msg"] # http://odahub.io/ontology#String
print(msg_out)

# ----------------------------------------------------------------------------------
# Computation of the power spectrum of the sources within the aperture
# ----------------------------------------------------------------------------------
plot_power_spectrum(ra, dec, thresh_arcmin)

# # ----------------------------------------------------------------------------------
# # Plotting of the enhanced image, the target location and the corresponding sources
# # ----------------------------------------------------------------------------------
# freq_index = 0
# plot_enhanced_image(clust_name, freq_index)
# plt.show()

# # ----------------------------------------------------------------------------------
# # Plotting of the enhanced image, the target location and the corresponding sources
# # ----------------------------------------------------------------------------------
# freq_index = 0
# plot_enhanced_image(clust_name, freq_index)
# plt.show()

# output gathering
_galaxy_meta_data = {}

with open(os.path.join(_galaxy_wd, "galaxy.json"), "w") as fd:
json.dump(_galaxy_meta_data, fd)
print("*** Job finished successfully ***")
Loading