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

STIX SRM reader in IDL giving the same format as stx_build_pixel_drm #154

Open
afbattaglia opened this issue Mar 29, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@afbattaglia
Copy link
Collaborator

Hi all,

I am not entirely certain, but I believe there is room for improvement in a process that I was unable to find instructions for. Therefore, I am documenting the issue here.

Using IDL procedures to convert STIX data to an OSPEX-readable format (such as stx_convert_pixel_data and related procedures), we create the SRM structure and store it externally in a FITS file. However, I was unable to find an easy way to read the SRM FITS into IDL in the same format as that returned by stx_build_pixel_drm. This format is necessary when manually providing the SRM to OSPEX, such as when providing an external flux (e.g., the flux obtained from fwdfit for imaging-spectroscopy). As a temporary fix on my own installation, I am storing a save file externally and restoring it before giving it to OSPEX. This is not an ideal solution, however, so we should work to find a better way to do this.

Below, the piece of code of concern.

In stx_fsw_sd_spectrogram2ospex one can find how to manually give to OSPEX an input spectrum, float(spectrogram.counts), and an SRM (as IDL structure), srm. I report the code here

ospex_obj  = ospex(/no)
ospex_obj->set, spex_data_source = 'spex_user_data'
ospex_obj->set, spectrum = float(spectrogram.counts),  $
  spex_ct_edges = energy_edges, $
  spex_ut_edges = utime2, $
  livetime = livetime, $
  errors = spectrogram.error
srm = rep_tag_name(srm,'smatrix','drm')
ospex_obj->set, spex_respinfo = srm
ospex_obj->set, spex_area = srm.area
ospex_obj->set, spex_detectors = 'STIX'
ospex_obj->set, spex_drm_ct_edges = energy_edges
ospex_obj->set, spex_drm_ph_edges = ph_edges2

The problem with this code is that it only works if srm has the same format as the structure returned by stx_build_pixel_drm. However, this function takes parameters that are not easy to retrieve externally. Kim and Richard created two other readers, but the above code does not work with the format of these readers. It's possible that Kim and Richard's readers are thought to be used internally by OSPEX, which would explain why this code crashes.

Long story short. We need to find a proper way to read the SRM in IDL that will be compatible with externally provided fluxes and SRMs. This may involve creating a wrapper (if it is not possible yet) or a demo (if it is already possible), so that I can include it in the imaging-spectroscopy pipeline. Without this, we cannot import the imaging fluxes for imaging-spectroscopy into OSPEX (easily).

We have quickly discussed this with @grazwegian but we sill need to figure this out.

Thanks,
Andrea

@afbattaglia afbattaglia added the enhancement New feature or request label Mar 29, 2023
@afbattaglia
Copy link
Collaborator Author

Just to add to my previous comment, @annavolp and I created a diagram summarizing the current situation. See below.

97a4e36c-d442-4c3c-ab2e-30ffa6bce9a0

@afbattaglia
Copy link
Collaborator Author

I had an e-mail exchange with @grazwegian. I report here a short summary of his explanations.

Using the current software, there is a way of importing the SRM from a file to the OPSEX object via the spex_user_data method. The key is just changing the tag name for the photon energies.

fdrm = rep_tag_name(fdrm,'PH_EDGES','edges_in’)

The solution of changing the tag names should be fine for reading in a DRM from the file and passing it to the OSPEX object via spex_user_data. For normal use, we will anyway need to streamline the DRM generation step in making the construction procedures more standalone and automatically generating responses with the correct energy binning for a given set of images.

Therefore, this issue is not yet closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant