# `NOT` Guidelines
Version: 2023-08-05
## General Notes
Soft ToO (submit at latest 2 PM Stockholm time) and hard ToO (override, can also override visitor, but that *rarely* happens)
Every Monday a observing time reminder is sent via the `#pypeit` channel on the `ztftransient` Slack -> that is already the cleaned version (compared to [here](https://www.not.iac.es/observing/schedules/schedule.php?period=67&output=html))
- if half night available is shown; it is not clear which half (the part with the Spanish time I did not get)
## Standard stars
The standard stars can be found [here](https://www.not.iac.es/instruments/alfosc/fluxstandard.html), but choose only the ESO/HST standards (they are well behaved and are included in `pypeit`), with a preference for the blue ones.
One standard per night is enough. If you schedule two obs ore more, add the standard only to your most important observation.
## Visibility
Use [betterNOT](https://github.com/simeonreusch/betterNOT)
It can also plot the standard stars.
Minimum moon separation: 30 deg
## Triggering
Choose the current program: (at the moment: 68-001)
Submission is done using this amazing frontend [here](https://www.not.iac.es/observing/forms/ob/login.php)
- Usually we observe with ALFOSC (no time at NOTCam)
- Priority: 1 (highest) - 5 (lowest)
- Nevr submit an Observing Block (OB) that is valid for multiple nights
- NOTE: One can import OBs from previous proposals, but these will be auto-flagged as "Monitoring". Always make sure that the correct observing mode is selected (Hard or soft ToO)
- For a given spec target, always submit 2 OBs: One for good seeing, one for bad seeing. Name format: `DATE_ZTFID_seeing_i_i` (e.g. `20230615_ztfabacdfd_1_0`).
- Cloud conditions: "Thin" is usually fine. "Moon" select "Any", but check yourself with the visibility plot
- Details of the OB:
- If it is red, it is not marked as "verified" yet. Submit block to make them green.
- Change date of OB
### Notes on the sequence
- Always import the finding chart first, or "Save Draft" first (otherwise, everything will be overwritten after import)
- Finding chart: Fritz/ALERCE works fine
- they are also saved to a DB, so you can get them from that for multiple obs of the same target
- Fritz: Change to 5 arcmin when creating the chart, and remove the reference stars. Print as `.pdf` and convert to `.png` or `.jpg`
- Press "Unlink" first when doing shenanigans in the finding chart DB
- in general: There is a **high chance** of the finding chart disappearing! Always check it is there and the correct version before submitting.
- For each of the OB, no matter if standard or sci image, **always** obtain arcs and flats.
- Arcs: Do Helium/Neon **plus** Thorium/Argon
- Flat: Use the Halogen Flat
- The exposures for both are hard coded to 14 s, you don't have to change that
- The standard exp time is documented on the [standards page](https://www.not.iac.es/instruments/alfosc/fluxstandard.html)
### Notes on Exposure
- **Minimal exposure time: 600 s**
- **Maximum integrated exp time: 1.5 hours** for total execution time of the highest priority targets
- Not much fainter than 20-20.5 mag
- Prioritize S/N
- Exposure time calculator is [here](https://www.not.iac.es/observing/forms/signal/index.php)
### ADC
Atmospheric Dispersion Corrector: If you observe with a position angle that is not the parallactic angle, use the ADC; but **only** in that case.
### Imaging
- Put imaging requests in a separate OB (do not include it in the spec OB)
- Do not worry about calibration except triggering lamps, the rest is done automatically on a nightly basis
## Data reduction
### Data access
Go [here](https://data.not.iac.es:5001/sharing/fGsCYVWU5) to download the observations.
### Install instructions:
- [`pypeit`](https://pypeit.readthedocs.io/en/release/installing.html), and for this a custom [NOT environment](https://gitlab.com/steveschulze/pypeit_alfosc_env)
Or, alternatively, use
- [`PyNOT`](https://github.com/steveschulze/PyNOT)
### Custom `pypeit` environment
`pypeit` is a multi-instrument spectroscopy framework, and it has all the instrument settings to do deal with ALFOSC data. Danger with out of the box usage is that you lose S/N (because of overzealous sky-subtraction in the IR).
Usage is nicely explained [here](https://gitlab.com/steveschulze/pypeit_alfosc_env). Do everything within the `pypeit_alfosc_env` directory. First, we define a date variable and one for the standard star we want to use in the flux calibration:
```bash
DATE="2023-07-24"
STANDARD="SP1550+330"
```
Copy all the files in a flat `2023-07-24` directory in `raw`.
```bash
cp /Users/simeon/Downloads/${DATE}.zip /Users/simeon/not/pypeit_alfosc_env/raw/
unzip /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}.zip -d /Users/simeon/not/pypeit_alfosc_env/raw
mv /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/alfosc/*.fits /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/
mv /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/alfosc/calib/*.fits /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/
rm -rf /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/alfosc/calib /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}/alfosc
rm /Users/simeon/not/pypeit_alfosc_env/raw/${DATE}.zip
```
Then, create `.pypeit` instruction files by issuing
``` bash
scripts/create_datasets.py $DATE
```
Then, do the **actual reduction**:
``` bash
ls datasets/$DATE*pypeit | grep "ZTF\|$STANDARD" | xargs -n 1 -P 4 run_pypeit
```
This grabs everything in the folder, creates 1 output (-n 1), uses 4 parallel session (`-P 4`) and executes `run_pypeit`.
Now we create a **sensitivity function**:
```bash
scripts/create_sensfunc.py $DATE
```
Finally, for **flux calibration** issue
``` bash
ls sci/$DATE-ZTF${DATE:2:2}a*/spec1d*.fits | grep ZTF | xargs -n 1 -P 1 scripts/apply_fluxcal.py
```
This grabs all the 1D spectra, generates 1 output (`-n 1`), uses 1 session (`-P 1`) and runs `scripts/apply_fluxcal.py` (we can only use 1 session, otherwise the processes talk to each other and make a mess).
Now, in case we have multiple exposures, we **combine the spectra**:
```bash
OBJ="ZTF23aatekmu"
scripts/combine_spectra.py -o sci/${DATE}-${OBJ}/${OBJ}_combined.fits sci/${DATE}-${OBJ}/spec1d_*.fits
```
Now we can produced ascii and previews:
```bash
scripts/convert_spec1d.py sci/${DATE}-${OBJ}/${OBJ}_combined.fits datasets/${DATE}-${OBJ}.pypeit --obs-name "Simeon Reusch" --red-name "Simeon Reusch"
```
Note: `check the .pypeit` files to see if there are calibrations missing.
NOTE: PUT EVERYTHING ON FRITZ AND WISEREP
### `PyNOT`
`PyNOT` is more tied to ALFOSC, and it can also do imaging.
## Bookkeeping
Please protocol everything [here](https://docs.google.com/spreadsheets/d/1daAm0Jae3mu89YakgY5321Du6HtLYe1-eWkyQ8GlMRw/edit#gid=0)