11. Solutions to exercises

11.1. Solutions to the Local calibration manager exercises

11.1.1. Solution to Exercise - Caldb 1

The rsys.cfg file should look like this:

[calibs]
standalone = True

#database_dir = <where_the_data_package_is>/niriimg_tutorial/playground
database_dir = <where_the_data_package_is>/niriimg_tutorial

ls <where_the_data_package_is>/niriimg_tutorial should show a file called cal_manager.db. And

caldb config

Using configuration file: ~/.geminidr/rsys.cfg
Active database directory: <where_the_data_package_is>/niriimg_tutorial/
Database file: <where_the_data_package_is>/niriimg_tutorial/cal_manager.db

The 'standalone' flag is active, meaning that local calibrations will be used

11.1.2. Solution to Exercise - Caldb 2

It is important do to successfully complete Exercise - Caldb 1 before attempting Exercise 2.

First confirm that the new calibration manager, the one niriimg_tutorial is active.

caldb config

Using configuration file: ~/.geminidr/rsys.cfg
Active database directory: <where_the_data_package_is>/niriimg_tutorial/
Database file: <where_the_data_package_is>/niriimg_tutorial/cal_manager.db

The 'standalone' flag is active, meaning that local calibrations will be used

Question 1

caldb add N20160102S0373_flat.fits

Question 2

caldb list

N20160102S0373_flat.fits       /data/workspace/niriimg_tutorial/playground

Question 3

Edit rsys.cfg. Comment out the niriimg_tutorial path and uncomment the playground path.

[calibs]
standalone = True

database_dir = <where_the_data_package_is>/niriimg_tutorial/playground
#database_dir = <where_the_data_package_is>/niriimg_tutorial

Confirm activation with caldb config.

caldb list

N20160102S0373_flat.fits       /data/workspace/niriimg_tutorial/playground
N20160102S0423_dark.fits       /data/workspace/niriimg_tutorial/playground

11.2. Solutions to the reduce exercises

11.2.1. Solution to Exercise - “reduce” 1

reduce @flats.lis -p normalizeFlat:scale=mean --suffix _exercise1

11.2.2. Solution to Exercise - “reduce” 2

reduce @target.lis -r makeSkyFlat --suffix _skyflat

11.2.3. Solution to Exercise - “reduce” 3

While it is not recommended to use a processed dark of the wrong exposure, here is how you would force DRAGONS to use the science’s master dark on the flux standard from the demo.

reduce @stdstar.lis --user_cal processed_dark:N20160102S0423_dark.fits

11.3. Solutions to the Customize recipes exercise

11.3.1. Solution to Exercise - Custom Recipe 1

showrecipes ../playdata/N20160102S0363.fits
cp /Users/klabrie/condaenvs/public3.7_3.0.1_20211206/lib/python3.7/site-packages/geminidr/niri/recipes/sq/recipes_FLAT_IMAGE.py .
mv recipes_FLAT_IMAGE.py myNIRIflats.py
 def makeProcessedFlat(p):

    p.prepare()
    p.addDQ()
    p.addVAR(read_noise=True)
    p.nonlinearityCorrect()
    p.ADUToElectrons()
    p.addVAR(poisson_noise=True)
    p.makeLampFlat()
    p.writeOutputs()
    p.normalizeFlat()
    p.thresholdFlatfield()
    p.storeProcessedFlat()
    p.display()
reduce @flats.lis -r myNIRIflats.makeProcessedFlat

11.4. Solutions to the Tools exercise

11.4.1. Solution to Exercise - Tools 1

showd -d exposure_time,filter_name,ut_date ../playdata/*.fits

--------------------------------------------------------------------------
filename                          exposure_time   filter_name      ut_date
--------------------------------------------------------------------------
../playdata/N20160102S0270.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0271.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0272.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0273.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0274.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0275.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0276.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0277.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0278.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0279.fits          20.002       H_G0203   2016-01-02
../playdata/N20160102S0295.fits          10.005       H_G0203   2016-01-02
../playdata/N20160102S0296.fits          10.005       H_G0203   2016-01-02
../playdata/N20160102S0297.fits          10.005       H_G0203   2016-01-02
../playdata/N20160102S0298.fits          10.005       H_G0203   2016-01-02
../playdata/N20160102S0299.fits          10.005       H_G0203   2016-01-02
../playdata/N20160102S0363.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0364.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0365.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0366.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0367.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0368.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0369.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0370.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0371.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0372.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0373.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0374.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0375.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0376.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0377.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0378.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0379.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0380.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0381.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0382.fits          42.001       H_G0203   2016-01-02
../playdata/N20160102S0423.fits          20.002         blank   2016-01-02
../playdata/N20160102S0424.fits          20.002         blank   2016-01-02
../playdata/N20160102S0425.fits          20.002         blank   2016-01-02
../playdata/N20160102S0426.fits          20.002         blank   2016-01-02
../playdata/N20160102S0427.fits          20.002         blank   2016-01-02
../playdata/N20160102S0428.fits          20.002         blank   2016-01-02
../playdata/N20160102S0429.fits          20.002         blank   2016-01-02
../playdata/N20160102S0430.fits          20.002         blank   2016-01-02
../playdata/N20160102S0431.fits          20.002         blank   2016-01-02
../playdata/N20160102S0432.fits          20.002         blank   2016-01-02
../playdata/N20160103S0463.fits           1.001         blank   2016-01-03
../playdata/N20160103S0464.fits           1.001         blank   2016-01-03
../playdata/N20160103S0465.fits           1.001         blank   2016-01-03
../playdata/N20160103S0466.fits           1.001         blank   2016-01-03
../playdata/N20160103S0467.fits           1.001         blank   2016-01-03
../playdata/N20160103S0468.fits           1.001         blank   2016-01-03
../playdata/N20160103S0469.fits           1.001         blank   2016-01-03
../playdata/N20160103S0470.fits           1.001         blank   2016-01-03
../playdata/N20160103S0471.fits           1.001         blank   2016-01-03
../playdata/N20160103S0472.fits           1.001         blank   2016-01-03

11.4.2. Solution to Exercise - Tools 2

dataselect ../playdata/*.fits --expr='observation_class=="science" and observation_type=="OBJECT"' | showd -d object

-----------------------------------------
filename                           object
-----------------------------------------
../playdata/N20160102S0270.fits   SN2014J
../playdata/N20160102S0271.fits   SN2014J
../playdata/N20160102S0272.fits   SN2014J
../playdata/N20160102S0273.fits   SN2014J
../playdata/N20160102S0274.fits   SN2014J
../playdata/N20160102S0275.fits   SN2014J
../playdata/N20160102S0276.fits   SN2014J
../playdata/N20160102S0277.fits   SN2014J
../playdata/N20160102S0278.fits   SN2014J
../playdata/N20160102S0279.fits   SN2014J
dataselect ../playdata/*.fits --expr='observation_class=="partnerCal" and observation_type=="OBJECT"' | showd -d object

----------------------------------------
filename                          object
----------------------------------------
../playdata/N20160102S0295.fits    FS 17
../playdata/N20160102S0296.fits    FS 17
../playdata/N20160102S0297.fits    FS 17
../playdata/N20160102S0298.fits    FS 17
../playdata/N20160102S0299.fits    FS 17