<jupyter_start><jupyter_text>Fussing with Slit Tracing [v1]<jupyter_code># imports
import os

from pypit import traceslits<jupyter_output><empty_output><jupyter_text>To run this Notebook, you must have an environmental variable pointed at the PYPIT Development suite And you will need to have downloaded and unpacked the 'Cooked' set of files<jupyter_code>print(os.getenv('PYPIT_DEV'))<jupyter_output>/data/Projects/Python/PYPIT-development-suite/<jupyter_text>----  Checking edges  Launch an RC Ginga viewer in your terminal    ginga --modules=RC  Point at a PYPIT MasterTrace frame<jupyter_code>mstrace_root = os.getenv('PYPIT_DEV')+'Cooked/Trace/MasterTrace_KeckLRISr_150420_402'<jupyter_output><empty_output><jupyter_text>PYPYIT Script    pypit_chk_edges $PYPIT_DEV/Cooked/Trace/MasterTrace_KeckLRISr_150420_402     The image and the traces should show in the Ginga viewer  Using the TraceSlits class  Load<jupyter_code>Tslits = traceslits.TraceSlits.from_master_files(mstrace_root)<jupyter_output>[1;32m[INFO]    ::[0m [1;34mtraceslits.py 214 from_master_files()[0m - Loading BPM from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_150420_402.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 228 from_master_files()[0m - Loading LCEN, RCEN from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_150420_402.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 231 from_master_files()[0m - Loading EDGEARR from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_150420_402.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 234 from_master_files()[0m - Loading SIGLEV from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_150420_402.fits.gz<jupyter_text>Show<jupyter_code>Tslits.show('edges')<jupyter_output><empty_output><jupyter_text>----  Add a Slit    There will be cases when one needs to manually add a slit    This frame is missing a slit due to 2 alignment star boxes    Here are ways to add one  Internal (with the TraceSlits class)<jupyter_code>#  left edge, right edge, row on image
add_user_slits = [[489,563,1024]]
# run_to_finish resets things in a proper manner
Tslits.add_user_slits(add_user_slits, run_to_finish=True)
# check -- S11 is the new one
Tslits.show('edges')
# write to disk (this will over-write so be careful)
new_root = os.path.basename(mstrace_root)+'_new'
Tslits.save_master(new_root)<jupyter_output>[1;32m[INFO]    ::[0m [1;34mtraceslits.py 881 save_master()[0m - Wrote TraceSlit arrays to MasterTrace_KeckLRISr_150420_402_new.fits
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 883 save_master()[0m - gzip compressing MasterTrace_KeckLRISr_150420_402_new.fits
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 897 save_master()[0m - Writing TraceSlit dict to MasterTrace_KeckLRISr_150420_402_new.json<jupyter_text>PYPIT script (coming someday, especially if requested) ----  Remove a slit    There are edge cases (e.g. ghost images) that lead to erroneous slits    Here is a way to remove one  Internal<jupyter_code># Frame with extra slit
mstrace_root2 = os.getenv('PYPIT_DEV')+'Cooked/Trace/MasterTrace_KeckLRISr_20160110_A'
# Load
Tslits2 = traceslits.TraceSlits.from_master_files(mstrace_root2)
# Show
Tslits2.show('edges')
# Setup slit to remove --  xleft, yleft at yrow=nrow/2
rm_slits = [[229, 380]]
# Remove
Tslits2.remove_slit(rm_slits)
# Check
Tslits2.show('edges')
# write to disk (this will over-write so be careful)
new_root2 = os.path.basename(mstrace_root2)+'_new'
Tslits.save_master(new_root2)<jupyter_output>[1;32m[INFO]    ::[0m [1;34mtraceslits.py 881 save_master()[0m - Wrote TraceSlit arrays to MasterTrace_KeckLRISr_20160110_A_new.fits
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 883 save_master()[0m - gzip compressing MasterTrace_KeckLRISr_20160110_A_new.fits
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 897 save_master()[0m - Writing TraceSlit dict to MasterTrace_KeckLRISr_20160110_A_new.json<jupyter_text>----  Re-run Tracing (only recommended for Developers)<jupyter_code>mstrace_root3 = os.getenv('PYPIT_DEV')+'Cooked/Trace/MasterTrace_KeckLRISr_20160110_A'<jupyter_output><empty_output><jupyter_text>Load<jupyter_code>Tslits2 = traceslits.TraceSlits.from_master_files(mstrace_root3)<jupyter_output>[1;32m[INFO]    ::[0m [1;34mtraceslits.py 214 from_master_files()[0m - Loading BPM from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_20160110_A.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 228 from_master_files()[0m - Loading LCEN, RCEN from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_20160110_A.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 231 from_master_files()[0m - Loading EDGEARR from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_20160110_A.fits.gz
[1;32m[INFO]    ::[0m [1;34mtraceslits.py 234 from_master_files()[0m - Loading SIGLEV from /data/Projects/Python/PYPIT-development-suite/Cooked/Trace/MasterTrace_KeckLRISr_20160110_A.fits.gz<jupyter_text>Run<jupyter_code>tslit_dict = Tslits2.run()
tslit_dict<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup