Exo-TiC / ExoTiC-ISM

This is a repository for the reduction pipeline detailed in Wakeford, et al., 2016, ApJ. The method implements marginalization across a series of models to represent stochastic models for observatory and instrument systematics. This is primarily for HST WFC3, however, may be extended to STIS in the future.
MIT License
8 stars 6 forks source link

Produce human readable PDF report of results #50

Closed ivalaginja closed 5 years ago

ivalaginja commented 5 years ago

This PR implements issue #42 and the solution suggested within.

This solution requires to install the packages jinja2, weasyprint, cairo and pango, which are all also available through conda. We will need to update the environment.yml file with that.

ivalaginja commented 5 years ago

Inserting the images turned out to be really hard, weasyprint is weird when it comes to dealing with absolute paths. I tried my luck on Stackoverflow so we'll see whether there's someone who's smart with this: https://stackoverflow.com/questions/57211774/image-ignored-in-pdf-rendering-with-jinja2-and-weasyprint

hrwakeford commented 5 years ago

Did not work for me. I got the following error

Screen Shot 2019-07-26 at 2 57 19 PM
ivalaginja commented 5 years ago

I don't know exactly what I did, but the embedding images magically started working, although we have to use png images instead of embedding pdf files. I will push my changes and then see whether I can figure out what happened on Hannah's machine in the comment above.

ivalaginja commented 5 years ago

Did not work for me. I got the following error

Screen Shot 2019-07-26 at 2 57 19 PM

The error message says image not found, which makes sense since the images we were trying to embed exist only on my local machine and I suspect we didn't run the marginalization code in order to generate them before trying to create the PDF report, or we set the paths up in a wrong way.

ivalaginja commented 5 years ago

Code used to test this (need to adjust the paths):

import os
from margmodule import create_pdf_report

fig2_fname ='/Users/ilaginja/Documents/data_from_repos/hst_marg_data/outputs/weights-stdr-rl_testing.png'
fig3_fname = '/Users/ilaginja/Documents/data_from_repos/hst_marg_data/outputs/residuals_best-model_testing.png'

template_vars = {'data_file': 123,
                 'run_name': 123,
                 'rl_in': 123,
                 'c1': 5,
                 'c2': 5,
                 'c3': 5,
                 'c4': 5,
                 'top_five_numbers': 'test',
                 'top_five_weights': 'test',
                 'top_five_sndr': 'test',
                 'white_noise': 'test',
                 'red_noise': 'test',
                 'photon_noise': 'test',
                 'rl_marg': 9,
                 'rl_marg_err': 9,
                 'epoch_marg': 9,
                 'epoch_marg_err': 9,
                 'inclin_rad_marg': 9,
                 'inclin_rad_marg_err': 9,
                 'inclin_deg_marg': 9,
                 'inclin_deg_marg_err': 9,
                 'msmpr_marg': 9,
                 'msmpr_marg_err': 9,
                 'aor_marg': 9,
                 'aor_marg_err': 9,
                 'lightcurve_figure': fig2_fname,
                 'systematics_figure': fig3_fname}

create_pdf_report(template_vars, os.path.join('/Users/ilaginja/', 'report.pdf'))
ivalaginja commented 5 years ago

The only last bit that's missing are is the output for red and white noise. This will be incorporated with issue #44.