#!/usr/bin/python

from numpy                          import searchsorted as np_searchsorted
from DZ_DataExplorer                import Plots_Manager
from ManageFlow                     import DataToTreat

# We declare the folder and log file to drop the lines data
Catalogue_Dic       = DataToTreat()
Pattern             = Catalogue_Dic['Datatype'] + '_dered2nd_Neb2nd.fits'                               #First batch process for untreated spectra
DataLog_Extension   = '_' + Catalogue_Dic['Datatype'] + '_dered2nd_Neb2nd_LinesLog_v3.txt'    #First data log for reduced spectra

# Importing Dazer libraries for launching the batch measurement
pv                  = Plots_Manager()

# Forcing the remake of new files
pv.RemakeFiles      = True

#Find and organize files from terminal command or .py file
FilesList           = pv.Folder_Explorer(Pattern, Catalogue_Dic['Obj_Folder'], CheckComputer=False)

for i in range(len(FilesList)):

#       Get the spectrum:              
        CodeName, FileName, FileFolder  = pv.Analyze_Address(FilesList[i])
        Wave, Int, ExtraData            = pv.File2Data(FileFolder, FileName)
    
#       Get the text file:  
        Lick_TextFileName               = CodeName + '_LickIndexes.txt'
        Lick_TextFile                   = open(FileFolder + Lick_TextFileName,"r")
        TextLines                       = Lick_TextFile.readlines()
        Lick_TextFile.close()
from DZ_DataExplorer                import Plots_Manager


# We declare the folder and log file to drop the lines data
dz = Plots_Manager()
  
# Forcing the remake of new log file
dz.RemakeFiles = True
    
#Identify spectrum (It assumes it is on the same folder of the code)
FileFolder, FileName = '', 'objSHOC579_WHT.fits'
  
#Load fits file data
Wave, Int, Header = dz.File2Data(FileFolder, FileName)

#Six wavelengths which mark the blue continuum, the line, and the red continuum (example for OIII 5007Angstroms)
Wavelength_points = [4967.758991, 4984.263585, 4999.928963, 5012.657082, 5030.420501, 5046.505486]

#Using a direct gausshermite
results_dict = dz.Command_LineMesuring(Wave, Int, Wavelength_points, Measuring_Method = 'kmpfit_GaussHermite')

#Using a MC gauss-hermite
results_dict_MCMC = dz.Command_LineMesuring(Wave, Int, Wavelength_points, Measuring_Method = 'kmpfit_GaussHermite_MCMC')

#Dictionary with the results from the analysis
print '\nResults example1'
for key in results_dict:
    print key, results_dict[key]

print '\nResults example2'
#Dictionary with the results from the analysis
    scale_params = OrderedDict()
 
    for i in range(N_comps):
        index = str(i)
        scale_params['A'+ index]     = ufloat(fit_output['A'+ index].value, fit_output['A'+ index].stderr) * y_scale
        scale_params['mu'+ index]    = ufloat(fit_output['mu'+ index].value, fit_output['mu'+ index].stderr) + x_scale
        scale_params['sigma'+ index] = ufloat(fit_output['sigma'+ index].value, fit_output['sigma'+ index].stderr)
        scale_params['fwhm'+ index]  = ufloat(fit_output['fwhm'+ index].value, fit_output['fwhm'+ index].stderr)
        scale_params['FWHM'+ index]  = ufloat(fit_output['FWHM'+ index].value, fit_output['FWHM'+ index].stderr)
        scale_params['Flux'+ index]  = ufloat(fit_output['Flux'+ index].value, fit_output['Flux'+ index].stderr) * y_scale
        
    return scale_params

# We declare the folder and log file to drop the lines data

pv = Plots_Manager()
  
# Forcing the remake of new files
pv.RemakeFiles = True
  
#Object and line to treat
Obj_Folder      = '/home/vital/Dropbox/Astrophysics/Data/WHT_Catalogue_SulfurRegression/Objects/SHOC579/'
Obj_Pattern     = 'objSHOC579_WHT.fits'
 
#Find and organize files from terminal command or .py file
FilesList = pv.Folder_Explorer(Obj_Pattern, Obj_Folder, CheckComputer=False)
List_wide_component = ['SHOC579']

#Set color format
pv.FigFormat_One(ColorConf='Night1')
Exemple #4
0
        GUI.quit()
        print "Cerrando el programa"

        return
    
    #Unknown Key combination
    else:
        print '--', event.key, '-- has not been assigned a command'

    #Plot the corresponding images        
    pv.ManagePlots()

    #Redraw the image
    pv.FigCanvas.draw()

pv = Plots_Manager()

#---- Find files within root folder according to log files ".log"
pv.FilesList = pv.FindAndOrganize_dazer(pv.Pattern_PlotFiles, pv.Catalogue_Folder, unpack=True, CheckComputer = False)

#---- Generate Initial Frame
pv.FigConf('night')
pv.Axis.text(0.95, 0.05, 'Initiating visualizer', verticalalignment='bottom', horizontalalignment='right',transform = pv.Axis.transAxes, fontsize=15)

GUI = Tk_GUI(PlottingVector = pv)

pv.FigCanvas.show()
pv.FigCanvas.mpl_connect('key_press_event', Key_Manager)
Span = widgets.SpanSelector(pv.Axis, Span_Manager, 'horizontal', useblit=False, rectprops=dict(alpha=1, facecolor='Blue'))

GUI.mainloop()
Exemple #5
0

def Detect_LineData(CodeName, Folder, LineLabel):
       
    LineLogName = Folder +  CodeName + '_LickIndexes.txt'
       
    Labels = pv.get_ColumnData(['Line_Label'], LineLogName, datatype = str)
    TheoWavelengthC, Wave1C, Wave2C, Wave3C, Wave4C, Wave5C, Wave6C  = pv.get_ColumnData(['TheoWavelength', 'Wave1', 'Wave2', 'Wave3', 'Wave4', 'Wave5', 'Wave6'], LineLogName, datatype=float)
    
    Str_ind = where(Labels == LineLabel)
    
    return TheoWavelengthC[Str_ind][0], Wave1C[Str_ind][0], Wave2C[Str_ind][0], Wave3C[Str_ind][0], Wave4C[Str_ind][0], Wave5C[Str_ind][0], Wave6C[Str_ind][0]
  
# We declare the folder and log file to drop the lines data

pv = Plots_Manager()
  
# Forcing the remake of new files
pv.RemakeFiles = True
  
#Object and line to treat
Obj_Folder      = '/home/vital/Dropbox/Astrophysics/Data/WHT_Catalogue/Objects/SHOC579/'
Obj_Pattern     = 'objSHOC579_WHT.fits'
 
#Find and organize files from terminal command or .py file
FilesList = pv.Folder_Explorer(Obj_Pattern, Obj_Folder, CheckComputer=False)
  
#Set color format
pv.FigFormat_One(ColorConf='Night1')
  
#Identify file