Open Yicircle opened 4 weeks ago
Dear Won-hyeong,
Happy to read you are trying the tool. Unfortunately GalaPy does not support yet multiple fits at a time from the same parameter file, it is a feature I am going to add at some point though. At the moment what I would suggest is to write a shell script to automatically write down the parameter files and launch the fits.
What I do in these cases is something like this (assuming the file galapy_table.txt
contains 4 objects with keys 'NGC3898', 'NGC4351', 'NGC3364' and 'NGC4254'):
#! /bin/bash
gxy=('NGC3898' 'NGC4351' 'NGC3364' 'NGC4254')
for g in ${gxy[@]}
do
cat <<EOF > ${g}_galapy_hyper_parameters.py
key = '${g}'
from galapy.internal.utils import cat_to_dict
catalogue = cat_to_dict('galapy_table.txt')
##################################################
# Parameters for building the observation to fit #
##################################################
# The observed dataset is expressed as 4 array-likes containing respectively:
# - bands: a list of strings corresponding to the unique identifiers also used
# in the 'filters' variable above (i.e. if you have provided as a list
# of filters already present in the database you can set
# bands = filters
# - fluxes: measures of fluxes (or upper limits) at the corresponding bands
# listed in variable 'bands'.
# The input measure should be given in units of milli-Jansky
# - errors: 1-sigma error on the measures of the fluxes (or upper limits) listed
# in the variable 'fluxes'
# - uplims: sequence of booleans identifying whether the values listed
# in argument \`fluxes\` should be considered non-detection (\`True\`)
# or a detection (\`False\`)
obj = catalogue[key]
obj['uplims'] = np.where(obj['errors'] < 0.0, True, False)
obj['errors'][obj['uplims']] = obj['fluxes'][obj['uplims']]
bands = obj['bands']
fluxes = obj['fluxes']
errors = obj['errors']
uplims = obj['uplims']
[... the rest of your parameter file here ...]
#############################
# ... and that's all folks! #
#############################
EOF
galapy-fit ${g}_galapy_hyper_parameters.py
done
You can save (and modify according to your necessities) the above code into a generate_and_run.sh
file.
NOTE that there is a [... the rest of your parameter file here ...]
that has to be substituted with... well, the rest of your parameter file :sweat_smile:
NOTE 2: I would suggest to use different names for the outputs as well (you can set e.g. run_id = '${g}'
in the parameters for the sampler section of the parameter file).
Once the file is saved, you will have your sequential fits running by calling source generate_and_run.sh
.
Of course, this will be done serially (one object a time), you can modify the above script in order to make the different fits run in parallel, e.g., on a cluster.
I am sorry, this is not very elegant. Even though I would consider your question answered, I will keep this issue open until I do not manage to publish a new release with a feature automatizing this process.
Best, Tommaso
Hello again Tommaso,
Thank you for your kind reply. It is helpful enough to solve my problem. Since it is not urgent, I could consider the features coming up later. Please let me know when you add it later.
Thank you again for your detailed reply.
Best, Won-hyeong Lee
p.s Sorry for closing issue because I'm not familiar to git system. I reopened it.
Hello Tommaso,
I'm trying to use GalaPy for fitting multiple galaxies at once. I found
galapy.internal.utils.cat_to_dict
and successfully load the data from ASCII catalogue. But there's some trouble with just modifyinggalapy_hyper_parameters.py
file This is a part of code in mygalapy_hyper_parameters.py
file I tyied.To summarize, my question is,
Thank you for reading this questions.
Best regards, Won-hyeong Lee.