class Spectrum(object): def Spectrum_def(self, spectrum_array): mjd, plate, fiber = spectrum_array self.url = "http://api.sdss3.org/spectrum?plate={0}&mjd={1}&fiber={2}&format=json".format(plate, mjd, fiber) response = urllib2.urlopen(self.url) spectrum = json.load(response) return spectrum ## Abbreviation S = Spectrum() ## Obtaining data from file data_spec = segue.get_columns(filename, 'MJD', 'PLATE', 'FIBER') ## Initializing the array for the spectra Spectra_array = [] ### Extracts 10 Spectra for i in range(0, 10): Spectra_array.append( S.Spectrum_def( data_spec[ i ] ) ) ### Turning list into an array Spectra_array = np.array( Spectra_array ) ### INTERPOLATION cubic_func_array = [[] for x in xrange( Spectra_array.size ) ] ### Computes interpolation for the first wavelength
# option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-i", "--input"): filename = value except Usage, err: print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) print >> sys.stderr, "\t for help use --help" return 2 ## If no -i input set use the first argument as the fits filename if not filename and len(args)>0: filename = args[0] else: sys.exit(1) ## this should be improved ## Main Program Stats Here data = segue.get_columns(filename, "SPECTYPE_HAMMER", "SPECTYPE_SUBCLASS") for spectral_type in set(data["SPECTYPE_HAMMER"]): print spectral_type if __name__ == "__main__": sys.exit(main())
except Usage, err: print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) print >> sys.stderr, "\t for help use --help" return 2 ## If no -i input set use the first argument as the fits filename if not filename and len(args)>0: filename = args[0] else: print "Bad things happened" sys.exit(1) ## this should be improved ## Main Program Starts Here data = segue.get_columns(filename, "FEH_ADOP", "RV_ADOP", "DIST_ADOP", "L", "B") #code for histograms fig, axes = plt.subplots(3,1, figsize=(6,8)) axes[0].tick_params(labelsize=10) axes[0].hist(data["RV_ADOP"][np.isfinite(data["RV_ADOP"])], bins=30, label='Radial Velocity') axes[0].set_xlabel('Radial Velocity', fontsize=10) axes[0].set_ylabel('Number of Stars', fontsize=10) axes[0].legend(loc='best', prop={'size':10}) axes[0].tick_params(labelsize=10) axes[1].hist(data["FEH_ADOP"][np.isfinite(data["FEH_ADOP"])], bins=30, label='[Fe/H]') axes[1].set_xlabel('[Fe/H]', fontsize=10) axes[1].set_ylabel('Number of Stars', fontsize=10)