Beispiel #1
0
def MkPlot():
    [tst, ted] = gettime()
    if ted.mjd <= tst.mjd:
        Div_info.text = '''Error: start time must occur earlier than end time. please re-enter start time and end time!!!'''
    else:
        labelsactive = [
            Wavelngth_checkbox.labels[ll] for ll in Wavelngth_checkbox.active
        ]
        Slabelsactive = set(labelsactive)
        Swavelength = set(
            ["1700", "1600", "304", "171", "193", "211", "335", "94", "131"])
        if len(Swavelength.intersection(Slabelsactive)) == 1:
            MkPlot_args_dict['wavelength'] = list(
                Swavelength.intersection(Slabelsactive))[0]
            MkPlot_args_dict['tst'] = tst.iso
            MkPlot_args_dict['ted'] = ted.iso
            MkPlot_args_dict['PlotID'] = Text_PlotID.value
            fout = database_dir + 'MkPlot_args.json'
            with open(fout, 'w') as fp:
                json.dump(MkPlot_args_dict, fp)
            Div_info.text = '''<p><b>{} saved.</b></p>'''.format(fout)
            port = DButil.getfreeport()
            print 'bokeh serve {}aiaBrowser/MkPlot --show --port {} &'.format(
                suncasa_dir, port)
            os.system(
                'bokeh serve {}aiaBrowser/MkPlot --show --port {} &'.format(
                    suncasa_dir, port))
            ports.append(port)
            Div_info.text = Div_info.text + """<p>Check the <b>MkPlot</b> in the <b>new tab</b></p>"""
        else:
            Div_info.text = Div_info.text + """<p>Choose one <b>AIA</b> wavelength to <b>MkPlot!!</b></p>"""
Beispiel #2
0
def tab1_update_VDSpecStrID():
    global dftmp
    global ports
    if tab1_selected_StrID_entry:
        StrIDList = pd.read_json(event_dir + 'StrID_list_tmp.json')
        StrIDList = StrIDList.sort_values(by='timeran', ascending=1)
        StrID = StrIDList.iloc[tab1_selected_StrID_entry[0]]
        struct_id = StrID['str_id'][0] + '/'
        CleanID = tab1_Select_CleanID.value
        ImfitID = tab1_Select_ImfitID.value
        dumpCurrFS(StrID, {'cleanid': CleanID, 'imfitid': ImfitID})
        ImfitIDdir = event_dir + struct_id + CleanID + '/' + ImfitID + '/'
        FS_dspecDF = ImfitIDdir + 'dspecDF-save'
        if CleanIDdir != '' and os.path.exists(FS_dspecDF):
            tab1_Div_FSview.text = """<p>Check the <b>VDSpec</b> in the <b>new tab</b></p>"""
            port = DButil.getfreeport()
            print 'bokeh serve {}DataBrowser/FSview/VDSpec --show --port {} &'.format(
                suncasa_dir, port)
            os.system(
                'bokeh serve {}DataBrowser/FSview/VDSpec --show --port {} &'.
                format(suncasa_dir, port))
            ports.append(port)
        else:
            tab1_Div_FSview.text = """<p>Click <b>FSview </b> to extract images information first!!</p>"""
    else:
        tab1_Div_FSview.text = """<p><b>Warning: No StrID selected. Select one StrID first!!!</b></p>"""
Beispiel #3
0
def tab2_panel_XCorr_update():
    global clickmode
    if tab2_BUT_XCorr.label == 'XCorr':
        clickmode = 'doubleclick'
        But_ClickMode.label = 'ClickMode: Double'
        tab2_BUT_XCorr.label = 'GoXCorr'
        tab2_panel_Div_exit.text = '<p><b>click two points in dynamic spectrum to select time and frequency range.</b></p>'
    elif 'GoXCorr':
        clickmode = 'singleclick'
        But_ClickMode.label = 'ClickMode: Single'
        tab2_BUT_XCorr.label = 'XCorr'
        global dspecDF_select
        time0, time1 = Time(
            (dspecDF_select['time'].min() + timestart) / 3600. / 24.,
            format='jd'), Time(
                (dspecDF_select['time'].max() + timestart) / 3600. / 24.,
                format='jd')
        freq0, freq1 = dspecDF_select['freq'].min(
        ), dspecDF_select['freq'].max()
        timeidx0 = next(i for i in xrange(tab2_ntim)
                        if tab2_tim[i] >= time0.mjd * 24. * 3600.)
        timeidx1 = next(i for i in xrange(tab2_ntim - 1, -1, -1)
                        if tab2_tim[i] <= time1.mjd * 24. * 3600.) + 1
        freqidx0 = next(i for i in xrange(tab2_nfreq) if tab2_freq[i] >= freq0)
        freqidx1 = next(i for i in xrange(tab2_nfreq - 1, -1, -1)
                        if tab2_freq[i] <= freq1) + 1
        dspecSel = tab2_r_dspec.data_source.data['image'][0][freqidx0:(
            freqidx1 + 1), timeidx0:(timeidx1 + 1)]
        freqSel = tab2_freq[freqidx0:(freqidx1 + 1)]
        timSel = tab2_tim[timeidx0:(timeidx1 + 1)]
        CC_dict = DButil.XCorrMap(dspecSel, timSel, freqSel)
        CC_save = struct_dir + 'CC_save.npz'
        np.savez(CC_save,
                 spec=dspecSel,
                 specfit=CC_dict['zfit'],
                 ccmax=CC_dict['ccmax'],
                 ccpeak=CC_dict['ccpeak'],
                 tim=CC_dict['x'],
                 ntim=CC_dict['nx'],
                 timfit=CC_dict['xfit'],
                 ntimfit=CC_dict['nxfit'],
                 freq=CC_dict['y'],
                 nfreq=CC_dict['ny'],
                 freqv=CC_dict['yv'],
                 freqa=CC_dict['ya'],
                 fidxv=CC_dict['yidxv'],
                 fidxa=CC_dict['yidxa'])
        try:
            tab2_panel_Div_exit.text = '<p><b>{}</b> saved.</p>'.format(
                CC_save)
        except:
            pass
        port = DButil.getfreeport()
        print 'bokeh serve {}DataBrowser/XCorr --show --port {} &'.format(
            suncasa_dir, port)
        os.system('bokeh serve {}DataBrowser/XCorr --show --port {} &'.format(
            suncasa_dir, port))
        ports.append(port)
        tab2_r_dspec_patch.data_source.data = {'xx': [], 'yy': []}
Beispiel #4
0
def tab1_update_CleanStrID():
    global dftmp
    global ports
    if tab1_selected_StrID_entry:
        StrIDList = pd.read_json(event_dir + 'StrID_list_tmp.json')
        StrIDList = StrIDList.sort_values(by='timeran', ascending=1)
        StrID = StrIDList.iloc[tab1_selected_StrID_entry[0]]
        out_json = event_dir + StrID['str_id'][0] + '.json'
        StrID.to_json(out_json)
        struct_id = StrID['str_id'][0] + '/'
        FS_config = dumpCurrFS(StrID, {'cleanid': Text_CleanID.value, 'imfitid': ''})
        FS_specfile = FS_config['datadir']['FS_specfile']
        CleanIDdir = event_dir + struct_id + Text_CleanID.value + '/'
        print CleanIDdir
        if not os.path.exists(CleanIDdir):
            os.makedirs(CleanIDdir)
        FS_dspecDF = CleanIDdir + 'dspecDF-base'
        if not os.path.exists(FS_specfile):
            time0, time1 = StrID['time'][0], StrID['time'][1]
            freq0, freq1 = StrID['freq'][0], StrID['freq'][-1]
            bl = tab1_specdata['bl']
            spec = tab1_specdata['spec']
            npol = tab1_specdata['npol']
            nbl = tab1_specdata['nbl']
            ntim = tab1_specdata['ntim']
            nfreq = tab1_specdata['nfreq']
            tim = tab1_specdata['tim'][:]
            freq = tab1_specdata['freq'] / 1e9
            timeidx0 = next(i for i in xrange(ntim) if tim[i] >= time0)
            timeidx1 = next(i for i in xrange(ntim - 1, -1, -1) if tim[i] <= time1) + 1
            freqidx0 = next(i for i in xrange(nfreq) if freq[i] >= freq0)
            freqidx1 = next(i for i in xrange(nfreq - 1, -1, -1) if freq[i] <= freq1) + 1
            spec = spec[:, :, freqidx0:(freqidx1 + 1), timeidx0:(timeidx1 + 1)]
            tim = tim[timeidx0:(timeidx1 + 1)]
            freq = freq[freqidx0:(freqidx1 + 1)] * 1.0e9
            ntim = len(tim)
            nfreq = len(freq)
            np.savez(FS_specfile, spec=spec, tim=tim, freq=freq, bl=bl, npol=npol, nbl=nbl, nfreq=nfreq, ntim=ntim)

        if os.path.exists(FS_dspecDF):
            Text_CleanID.value = DButil.getcurtimstr()
            tab1_Div_Tb.text = """<p>CleanID existed. Click <b>FSview</b> to see the results or use the <b>new CleanID</b> to continue.</p>"""
        else:
            port = DButil.getfreeport()
            print 'bokeh serve {}DataBrowser/ToClean --show --port {} &'.format(suncasa_dir, port)
            os.system('bokeh serve {}DataBrowser/ToClean --show --port {} &'.format(suncasa_dir, port))
            ports.append(port)
            tab1_Div_Tb.text = """<p>Check the <b>ToClean </b> in the <b>new tab</b></p>"""
    else:
        tab1_Div_Tb.text = """<p><b>Warning: No StrID selected. Select one StrID first!!!</b></p>"""