Skip to content

rethink how user-added models are stored #161

Description

@mpound

From a user:

I followed the instructions to create and save the FITS file of a new model ratio, with the code below. But, despite the model was added to the list,
it seems the FITS file is not saved under ~/anaconda3/lib/python3.10/site-packages/pdrtpy/models/wolfirekaufman/version2020/constant_density/z=1/
The new model is listed as “user.fits”, (though it should be name CO43_CI609.fits) but it is not found inside the aforementioned directory (nor anywhere).

Here is the code I am using to create the new model:

ms              = ModelSet("wk2020",z=1.0)
l_mod_x     = ms.get_model("CO_43")   
l_mod_y     = ms.get_model("CI_609")   
mode_header = ms.get_model("CI_609/CO_43")
r_new         = l_mod_x/l_mod_y
r_new.header  = deepcopy(mode_header.header)
r_new.header["TITLE"]         = 'CO (J=4-3)/[CI] 609 micron/'
r_new.header["DATAMAX"]  = r_new.data.max()
r_new.header["DATAMIN"]   = r_new.data.min()
r_new.header["HISTORY"]   = "Computed arithmetically from CO_43/CI_609"
r_new.header["DATE"]          = utils.now() # the current time and date
r_new.header
ms.add_model("CO_43/CI_609",r_new,title="CO(J=4-3) / [C I] 609 $\mu$m",overwrite=True)
ms.supported_ratios.show_in_notebook()

After this, the new ratio is listed in the current supported models, at the end:

Then, to save the FITS file:

r_new.write("CO43_CI609.fits",overwrite=True)

Context

User added files are stored internally (memory only) with the name 'user.fits' as a placeholder. This causes confusion for someone looking for an output file. The option should be added to give an actual output file so the additional write() is not necessary. We should also consider allowing the user to specify default directory where user-added models should go and could be read from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions