<jupyter_start><jupyter_text><NAME> <EMAIL> DescriptionThis Notebook shows how to use hstgrism.to_fullframe.to_fullframe function to put any cutout images back to a given full image.In this demo, we will use cutflat.fits (which was generated from earlier step) back to iab901ekq_flt.fits (which can be downloaded from [MAST](https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html). (Note: we are replacing a grism image with a cutout section from a flatfield image to make the output obvious for demonstration purpose). The cutout corner is defined in bbcorner.csv (which was created from earlier step). Quick Walkthrough- Read cutout image as cutdata.- Specify full frame as (path to file, extension).- Specify bb0x,bb1x,bb0y,bb1y to be replaced in the full frame.- Specify Container object.- Specify savesuffix. (Output will be saved as ./savefolder/saveprefix_savesuffix.fits).<jupyter_code>from hstgrism.container import Container
from hstgrism.to_fullframe import to_fullframe
from astropy.io import fits
import pandas as pd
import matplotlib.pyplot as plt
saveprefix = 'iab901ekq_replaced'
savefolder = 'testfolder'
plotformat = 'pdf'
overwrite = False

container_params = {'saveprefix':saveprefix,
                    'savefolder':savefolder,
                    'plotformat':plotformat,
                    'overwrite':overwrite
                   }
containerobj = Container(**container_params)

cutfile = ('./testfolder/testprefix_cutflat.fits',1)
cutdata = fits.open(cutfile[0])[cutfile[1]].data
fullfile = ('/Users/kbhirombhakdi/_work/_data/11552/G102_set/mastDownload/HST/iab901ekq/iab901ekq_flt.fits',1)
bb = pd.read_csv('./testfolder/testprefix_bbcorner.csv')
bb0x = bb.bb0x[0]
bb1x = bb.bb1x[0]
bb0y = bb.bb0y[0]
bb1y = bb.bb1y[0]
savesuffix = 'FlattoFullFrame'

to_fullframe(cutdata,fullfile,
             bb0x,bb1x,bb0y,bb1y,
             savesuffix,containerobj
            )

plt.figure(figsize=(10,10))
string = './{0}/{1}_{2}.fits'.format(savefolder,saveprefix,savesuffix)
tmpdata = fits.open(string)[fullfile[1]].data
plt.imshow(tmpdata,origin='lower',cmap='viridis',vmin=0.,vmax=2.)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1092436974789916, 'fraction_numerical': 0.025210084033613446, 'mean_word_length': 4.5089974293059125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '149464', 'license': 'MIT', 'n_tokens_mistral': 754, 'n_tokens_neox': 710, 'n_words': 174, 'path': 'demo_8-0-0/05_tofullframe.ipynb', 'repo_name': 'bkornpob/hstgrism', 'size': '2171'}