#!/net/python/bin/python from Header import * from Filter import * def GetFilterSet(label): """ label is one of 'SDSS' or 'SNLS' """ #this function refers to the global variable FILTER_SET #if the desired filter set is not yet defined, it #defines and returns it global FILTER_SET if label not in FILTER_SET: FILTER_SET[label] = FilterSet(label) return FILTER_SET[label] class FilterSet: def __init__(self,filterset=None): """ filterset is one of 'SDSS' or 'SNLS' """ self.keys = [] self.filters = {} for fname in FilterNames(filterset): self.keys.append(fname) self.filters[fname] = Filter(filterset,fname) def extincted(self,EBV,Rv=3.1): if EBV == 0: return self selfcopy = self.__class__() selfcopy.keys = [key for key in self] for key in selfcopy: selfcopy[key] = self[key].extincted(EBV,Rv) return selfcopy def copy(self): selfcopy = self.__class__() selfcopy.keys = [key for key in self] for key in selfcopy: selfcopy[key] = self[key].copy() return selfcopy def graph(self,linestyle='-',fill=True): for fname in self.keys: self.filters[fname].graph( style = linestyle+Colors[fname],\ fill=fill,fcolor = FColors[fname] ) #------------------------------------ def redshift(self,z): selfcopy = self.copy() for f in selfcopy: selfcopy[f] = selfcopy[f].redshift(z) return selfcopy def blueshift(self,z): selfcopy = self.copy() for f in selfcopy: selfcopy[f] = selfcopy[f].blueshift(z) return selfcopy def unredshift(self,z): return self.blueshift(z) def unblueshift(self,z): return self.redshift(z) #------------------------------------- def __iter__(self): return iter(self.keys) def __getitem__(self,key): return self.filters[key] def __setitem__(self,key,other): self.filters[key] = other def __delitem__(self,key): self.keys.remove(key) del self.filters[key] if __name__ == '__main__': FilterSet('SDSS').graph() p.show()