コード例 #1
0
ファイル: inputs.py プロジェクト: ucsbdeepspace/atmodel
    def energy_changed(text):

        try: # ensure both fields are filled with floating point numbers

            # currently selected unit of photon energy
            energy_form = gui.energy_list[inputs2["e_units"].widget.currentIndex()]

            freq1 = energy_form.to_hz(float(inputs2["energy1"].widget.text()))
            freq2 = energy_form.to_hz(float(inputs2["energy2"].widget.text()))

            if freq1 < freq2:
                freq_range = aux.interval(freq1, freq2)
            else:
                freq_range = aux.interval(freq2, freq1)

            # set interpolation range
            if energy_form.is_freq:
                gui.interp.set_freq_hz(freq_range)
            else:
                gui.interp.set_wl_m(aux.interval(const.c / freq_range.max,
                    const.c / freq_range.min))

        except Exception:
            pass # assume fields are incomplete, so ignore now and try again later

        # mark that project has been edited since last save
        gui.changed = True
コード例 #2
0
ファイル: interpolate.py プロジェクト: ucsbdeepspace/atmodel
    def set_wl_m (self, wl_range, divisions = 1000):
        self.freq_range = \
            auxil.interval(const.c / wl_range.max, const.c / wl_range.min)
        self.divisions = divisions

        # compute list of frequencies with even wavelength spacing
        self.freq_list = [self.freq_range.min]
        lnspace = (math.log(wl_range.max) - math.log(wl_range.min)) / divisions

        for i in range(1, divisions):
            self.freq_list.append(const.c / math.exp(math.log(wl_range.min) + i * lnspace))
        self.freq_list.sort()

        self.freq_array = np.array(self.freq_list)
        return self.freq_list
コード例 #3
0
ファイル: gui.py プロジェクト: ucsbdeepspace/atmodel
    def __init__(self, energy_list, sites, source, galactic, mirror, zodiac):
        super(gui, self).__init__()

        self.energy_list = energy_list # ways of measuring photon energy
        self.atmos_files = sites # list of observer sites
        self.source_files = source # list of source galaxies
        self.galactic_files = galactic # list of galactic emission files
        self.mirror_consts = mirror # dictionary of constants for mirror types (metals)
        self.zodiac_files = zodiac # list of ecliptic emission files

        # Project settings
        self.interp = Interpolate(aux.interval(1e11, 1e13)) # frequency range (Hz)
        self.bling_units = 0 # use W/Hz^1/2 as default units of BLING
        self.flux_units = 0 # use W/sr*Hz*m^2 as default units of flux
        self.signal_units = 0 # use W as default units of signal
        self.noise_what = 0 # plot BLING by default for noise
        self.compos_what = 0 # plot total BLING by default for composite

        self.collections = {} # dictionary of collections of data input widgets
        self.groups = {} # dictionary of lone widget groups not part of a collection
        self.floating = {} # free-floating widgets not in any group or collection

        # calculation in separate worker thread
        self.main_thread = QtCore.QThread.currentThread()
        self.worker = work.Worker(self.main_thread)
        self.worker.ready.connect(self.done_work)

        self.init_UI()

        # Set default state
        self.changed = False # no edits made so far
        self.proj_file = "" # current project file path

        # Load project file if specified
        if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
            project.open(self, sys.argv[1])