def read_options(): default_values = Parset.value_dict attrs = Parset.attr_dict desc = """Questions and suggestions: [email protected]""" OP = MyOptParse.MyOptParse(usage='Usage: %prog [parset file] <options>', version='%prog version ' + report_version(), description=desc, defaults=default_values, attributes=attrs) # create options based on contents of parset for section in Parset.sections: values = default_values[section] # "_Help" value in each section is its documentation string OP.OptionGroup(values.get("_Help", section), section) for name, value in default_values[section].iteritems(): if not attrs[section][name].get("no_cmdline"): OP.add_option(name, value) OP.Finalise() OP.ReadInput() # #optcomplete.autocomplete(opt) # options, arguments = opt.parse_args() MyPickle.Save(OP, SaveFile) return OP
def __init__(self, ImageName, ImShape, Cell, radec, Freqs=None, KeepCasa=False, Stokes=["I"], header_dict=None, history=None): """ Create internal data structures, then call CreateScratch to make the image itself. header_dict is a dict of FITS keywords to add. history is a list of strings to put in the history """ if KeepCasa: raise RuntimeError('KeepCasa = True is not implemented!') self.Cell = Cell self.radec = radec self.KeepCasa = KeepCasa self.Freqs = Freqs self.Stokes = [ClassStokes.FitsStokesTypes[sid] for sid in Stokes] self.sorted_stokes = [s for s in self.Stokes] self.sorted_stokes.sort() self.header_dict = header_dict #work out the FITS spacing between stokes parameters if len(self.sorted_stokes) > 1: self.delta_stokes = self.sorted_stokes[1] - self.sorted_stokes[0] else: self.delta_stokes = 1 for si in range(len(self.sorted_stokes) - 1): if self.sorted_stokes[ si + 1] - self.sorted_stokes[si] != self.delta_stokes: raise RuntimeError( "Your selection of Stokes parameters cannot " "be stored in a FITS file. The selection must be linearly spaced." "See FITS standard 3.0 (A&A 524 A42) Table 28 for the indices of the stokes " "parameters you want to image.") self.ImShape = ImShape self.nch, self.npol, self.Npix, _ = ImShape self.ImageName = ImageName #print "image refpix:",rad2hmsdms.rad2hmsdms(radec[0],Type="ra").replace(" ",":"),", ",rad2hmsdms.rad2hmsdms(radec[1],Type="dec").replace(" ",".") self.imageFlipped = False self.createScratch() # Fill in some standard keywords self.header['ORIGIN'] = 'DDFacet ' + report_version() self.header['BTYPE'] = 'Intensity' self.header['BUNIT'] = 'Jy/beam' self.header['SPECSYS'] = 'TOPOCENT' if header_dict is not None: for k in header_dict: self.header[k] = header_dict[k] if history is not None: if isinstance(history, str): history = [history] for h in history: self.header['HISTORY'] = h
# import warnings # warnings.filterwarnings('error') # #with warnings.catch_warnings(): # # warnings.filterwarnings('error') # # ############################## ''' The defaults for all the user commandline arguments are stored in a parset configuration file called DefaultParset.cfg. When you add a new option you must specify meaningful defaults in there. These options can be overridden by specifying a subset of the parset options in a user parset file passed as the first commandline argument. These options will override the corresponding defaults. ''' import DDFacet print("DDFacet version is",report_version()) print("Using python package located at: " + os.path.dirname(DDFacet.__file__)) print("Using driver file located at: " + __file__) global Parset Parset = ReadCFG.Parset("%s/DefaultParset.cfg" % os.path.dirname(DDFacet.Parset.__file__)) def read_options(): default_values = Parset.value_dict attrs = Parset.attr_dict desc = """Questions and suggestions: [email protected]""" OP = MyOptParse.MyOptParse(usage='Usage: %prog [parset file] <options>', version='%prog version '+report_version(), description=desc, defaults=default_values, attributes=attrs)