Ejemplo n.º 1
0
    def tool_preinit(self):
        """
        Pre-initialize any required attributes for the interface.
        """
        #initialize engine objects
        self.telescope = Telescope()
        self.camera = Camera()
        self.exposure = Exposure()
        self.telescope.add_camera(self.camera)
        self.camera.add_exposure(self.exposure)

        #set interface variables
        self.templates = [
            'fab', 'bb', 'o5v', 'b5v', 'g2v', 'm2v', 'orion', 'elliptical',
            'sbc', 'starburst', 'ngc1068'
        ]
        self.template_options = [SpectralLibrary[t] for t in self.templates]
        self.help_text = help_text
        self.snr_hover_tooltip = hover_tooltip.format("S/N")
        self.mag_hover_tooltip = hover_tooltip.format("Magnitude")
        self.exp_hover_tooltip = hover_tooltip.format("Exptime")

        #update default exposure based on tool_defaults
        self.update_exposure()

        #Formatting & interface stuff:
        self.format_string = interface_format
        self.interface_file = os.path.join(script_dir, "interface.yaml")

        #For saving calculations
        self.current_savefile = ""
        self.overwrite_save = False
Ejemplo n.º 2
0
 def tool_preinit(self):
     """
     Pre-initialize any required attributes for the interface.
     """
     #initialize engine objects
     self.telescope = Telescope(temperature=pre_encode(280.0*u.K))
     self.spectrograph = Spectrograph()
     self.exposure = Exposure()
     self.telescope.add_spectrograph(self.spectrograph)
     self.spectrograph.add_exposure(self.exposure)
     
     #set interface variables
     self.templates = ['flam', 'qso', 's99', 'o5v', 'g2v', 'g191b2b', 
                       'gd71', 'gd153', 'ctts', 'mdwarf', 'orion', 'nodust',
                       'ebv6', 'hi1hei1', 'hi0hei1']
     self.template_options = [SpectralLibrary[t] for t in self.templates]
     self.help_text = help_text
     self.gratings = self.spectrograph.modes
     self.grating_options = [self.spectrograph.descriptions[g] for g in self.gratings]
     self.dl_filename = ""
     
     #set default input values
     self.update_exposure()
     
     #Formatting & interface stuff:
     self.format_string = interface_format
     self.interface_file = os.path.join(script_dir, "interface.yaml")
     
     #For saving calculations
     self.current_savefile = ""
     self.overwrite_save = False
Ejemplo n.º 3
0
    def tool_preinit(self):
        """
        Pre-initialize any required attributes for the interface.
        """
        #set up holoviews & load data for datashader
        #note that right now the data is read from a pickle, not loaded separately;
        #I'm leaving load_dataset.py in the directory, but it's not used currently
        self.dataframe = pandas.read_pickle(
            os.path.join(basedir, 'data', 'cmd_frame_large_no_noise.pkl'))
        self.cmap_picker = ColormapPicker(rename={'colormap': 'cmap'}, name='')

        #initialize engine objects
        self.telescope = Telescope()
        self.camera = Camera()
        self.exposure = Exposure()
        self.telescope.add_camera(self.camera)
        self.camera.add_exposure(self.exposure)

        #set interface variables
        self.help_text = help_text

        #Formatting & interface stuff:
        self.format_string = interface_format
        self.interface_file = os.path.join(script_dir, "interface.yaml")

        #For saving calculations
        self.current_savefile = ""
        self.overwrite_save = False
Ejemplo n.º 4
0
 def tool_preinit(self):
     """
     Pre-initialize any required attributes for the interface.
     """
     #initialize engine objects
     self.telescope = Telescope(temperature=pre_encode(280.0 * u.K))
     self.spectrograph = Spectropolarimeter()
     self.exposure = Exposure()
     self.telescope.add_spectrograph(self.spectrograph)
     self.spectrograph.add_exposure(self.exposure)
Ejemplo n.º 5
0
def test_camera():
    c = Camera()
    t = Telescope()
    t.aperture = pre_encode(15.08 * u.m)
    t.add_camera(c)
    sval = [49.70, 11.58, 257.88, 530.75, 962.04, 2075.26, 1819.15, 8058.30, 11806.49, 15819.07]
    
    expt = 3600. * u.s
    qe = c.recover('total_qe')
    fsky = c._fsky()
    wav = c.recover("pivotwave")
    print("Sky counts:")
    for i in range(c.n_bands):
        skc = (fsky[i] * expt * qe[i]).value
        rat = skc / sval[i] * 100.
        print("{:8.2f} ({:5.1f}% of spreadsheet value) at {:4.0f}".format(skc, rat, wav[i]))
Ejemplo n.º 6
0
def test_specetc(print_models=True):
    
    print("\n\n==Instantiating models==")
    print("(setting verbose = True)\n")
    
    e, s, t = SpectrographicExposure(), Spectrograph(), Telescope()
    t.add_spectrograph(s)
    s.add_exposure(e)
    e.verbose = True

    print(e.zmin, e.zmax)
    
    if print_models:
        print("\n\n==Parameter values (aka defaults):==")
        print("\n=TELESCOPE=\n")
        for attr in t._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(t,attr))))
        #pprint(t.encode(), indent=2)
        print("\n=SPECTROGRAPH=\n")
        for attr in s._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(s,attr))))
        #pprint(s.encode(), indent=2)
        print("\n=EXPOSURE=\n")
        for attr in e._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(e,attr))))
        #pprint(e.encode(), indent=2)
        
    print("\n\nSetting spectrograph mode to 'G300M'")
    s.mode = "G300M"
    
    print("\n\n==Setting SED to QSO at z=0.04 & recalculating==\n")
    e.disable() #since we're updating more than one parameter, turn off calculations
    e.sed_id = 'qso'
    e.redshift = 1.0
    e.enable() #turn calculations back on again
    
    print("\n\n==Current unknown: {}==".format(e.unknown))
    print("\nSNR: {}".format(e.recover('snr')))
    
    print("No other unknown types currently supported.")
    
    """
Ejemplo n.º 7
0
def test_photetc(print_models=True):

    print("\n\n==Instantiating models==")
    print("(setting verbose = True)\n")
    
    e, c, t = PhotometricExposure(), Camera(), Telescope()
    t.add_camera(c)
    c.add_exposure(e)
    e.verbose = True
    
    if print_models:
        print("\n\n==Parameter values (aka defaults):==")
        print("\n=TELESCOPE=\n")
        for attr in t._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(t,attr))))
        #pprint(t.encode(), indent=2)
        print("\n=CAMERA=\n")
        for attr in c._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(c,attr))))
        #pprint(c.encode(), indent=2)
        print("\n=EXPOSURE=\n")
        for attr in e._tracked_attributes:
            print('{}: {}'.format(attr, str_jsunit(getattr(e, attr))))
        #pprint(e.encode(), indent=2)
    
    print("\n\n==Setting spectrum to QSO & recalculating==\n")
    e.sed_id = 'qso'
    
    print("\n\n==Current unkown: {}==".format(e.unknown))
    print("\nSNR: {}".format(e.snr))
    
    print("\n\n==Setting unknown to 'magnitude'==\n")
    e.unknown = "magnitude"
    print("\nMagnitude: {}".format(e.magnitude))
    
    print("\n\n==Setting unknown to 'exptime'==\n")
    e.unknown = "exptime"
    print("\nExptime: {}".format(e.exptime))
Ejemplo n.º 8
0
                fill_alpha=0.2,
                fill_color='black',
                line_alpha=0.2,
                line_width=1,
                line_color='black')
plot.state.text('textx',
                'texty',
                'text',
                source=confusion_limit_source,
                text_align='left',
                text_color='black')

###########################################
# CREATE THE SYOTOOLS ELEMENTS AND MODELS #
###########################################
e, c, t = PhotometricExposure(), Camera(), Telescope()
t.add_camera(c)
t.aperture = 15.0 * u.meter
c.add_exposure(e)
e.sed_id = 'fab'
t.aperture = 15. * u.meter
e.exptime = 3600. * u.s

new_snrs = np.arange(5)  # derives the S/N at various magnitude limits
for ii in [0, 1, 2, 3, 4]:
    e.renorm_sed(mag_label_source.data['mags'][ii] * u.ABmag)
    new_snrs[ii] = e.snr[1]['value'][4]

# results of ETC are stored weirdly as a list of AB mags = e.magnitude[1]['value'][:]
etc_label_source = ColumnDataSource(
    data={