@@ -40,35 +40,31 @@ def createOptionParser():
4040 parser .add_option ('-V' , '--version' , action = "version" ,
4141 help = "Show program version and exit." )
4242 parser .version = __version__
43- parser .add_option ('-a' , '--apply' , action = "store_false" , dest = "refine" ,
44- help = "Apply manipulations but do not refine." )
45- parser .add_option ('-x' , '--exclude' , action = "append" , dest = "exclude" ,
46- metavar = "MANIP" ,
47- help = """Exclude a manipulation from refinement by name. This can
48- appear multiple times.""" )
49- parser .add_option ('-n' , '--noplot' , action = "store_false" , dest = "plot" ,
50- help = "Do not show the plot." )
5143 parser .add_option ('-s' , '--save' , metavar = "FILE" , dest = "savefile" ,
5244 help = "Save manipulated PDF from FILE1 to FILE." )
5345 parser .add_option ('--rmin' , type = "float" ,
5446 help = "Minimum r-value to use for PDF comparisons." )
5547 parser .add_option ('--rmax' , type = "float" ,
5648 help = "Maximum r-value to use for PDF comparisons." )
57- parser .add_option ('--pmin' , type = "float" ,
58- help = "Minimum r-value to plot. Defaults to rmin." )
59- parser .add_option ('--pmax' , type = "float" ,
60- help = "Maximum r-value to plot. Defaults to rmax." )
6149 parser .add_option ('--pearson' , action = "store_true" , dest = "pearson" ,
6250 help = "Maximize agreement in the Pearson function. Note that this is insensitive to scale." )
6351 parser .add_option ('--addpearson' , action = "store_true" , dest = "addpearson" ,
64- help = "Maximize agreement in the Pearson function as well as the residual." )
52+ help = """Maximize agreement in the Pearson function as well as
53+ minimizing the residual.""" )
54+
6555
6656 # Manipulations
6757 group = optparse .OptionGroup (parser , "Manipulations" ,
6858 """These options select the manipulations that are to be applied to
6959the PDF from FILE1. The passed values will be refined unless specifically
7060excluded with the -a or -x options.""" )
7161 parser .add_option_group (group )
62+ group .add_option ('-a' , '--apply' , action = "store_false" , dest = "refine" ,
63+ help = "Apply manipulations but do not refine." )
64+ group .add_option ('-x' , '--exclude' , action = "append" , dest = "exclude" ,
65+ metavar = "MANIP" ,
66+ help = """Exclude a manipulation from refinement by name. This can
67+ appear multiple times.""" )
7268 group .add_option ('--scale' , type = "float" , metavar = "SCALE" ,
7369 help = "Apply scale factor SCALE." )
7470 group .add_option ('--smear' , type = "float" , metavar = "SMEAR" ,
@@ -79,27 +75,37 @@ def createOptionParser():
7975 help = """Slope of the baseline. This is used when applying the smear
8076factor. It will be estimated if not provided.""" )
8177 group .add_option ('--qdamp' , type = "float" , metavar = "QDAMP" ,
82- help = "Dampen PDF by a factor QDAMP." )
78+ help = "Dampen PDF by a factor QDAMP. (See PDFGui manual.) " )
8379 group .add_option ('--radius' , type = "float" , metavar = "RADIUS" ,
84- help = "Apply characteristic function of sphere with radius RADIUS." )
85- group .add_option ('--eradius' , type = "float" , metavar = "ERADIUS" ,
86- help = """Apply characteristic function of spheroid with equatorial
87- radius ERADIUS and polar radius PRADIUS. If only one of these is given, then
88- use a sphere instead.""" )
80+ help = """Apply characteristic function of sphere with radius RADIUS.
81+ If PRADIUS is also specified, instead apply characteristic function of spheroid with equatorial radius RADIUS and polar radius PRADIUS.""" )
8982 group .add_option ('--pradius' , type = "float" , metavar = "PRADIUS" ,
9083 help = """Apply characteristic function of spheroid with equatorial
91- radius ERADIUS and polar radius PRADIUS. If only one of these is given, then
92- use a sphere instead.""" )
93- group .add_option ('--vshift' , type = "float" , metavar = "VSHIFT" ,
94- help = "Shift the objective vertically by VSHIFT." )
95- group .add_option ('--hshift' , type = "float" , metavar = "HSHIFT" ,
96- help = "Shift the objective horizontally by HSHIFT." )
84+ radius RADIUS and polar radius PRADIUS. If only PRADIUS is specified, instead apply characteristic function of sphere with radius PRADIUS.""" )
85+
86+
87+ # Plot Options
88+ group = optparse .OptionGroup (parser , "Plot Options" ,
89+ """These options control plotting.""" )
90+ parser .add_option_group (group )
91+ group .add_option ('-n' , '--noplot' , action = "store_false" , dest = "plot" ,
92+ help = "Do not show the plot." )
93+ group .add_option ('--pmin' , type = "float" ,
94+ help = "Minimum r-value to plot. Defaults to RMIN." )
95+ group .add_option ('--pmax' , type = "float" ,
96+ help = "Maximum r-value to plot. Defaults to RMAX." )
97+ group .add_option ('--maglim' , type = "float" ,
98+ help = "Magnify plot curves beyond MAGLIM by MAG." )
99+ group .add_option ('--mag' , type = "float" ,
100+ help = "Magnify plot curves beyond MAGLIM by MAG." )
101+
97102
98103 # Defaults
99104 parser .set_defaults (plot = True )
100105 parser .set_defaults (refine = True )
101106 parser .set_defaults (pearson = False )
102107 parser .set_defaults (addpearson = False )
108+ parser .set_defaults (mag = 5 )
103109
104110 return parser
105111
@@ -115,20 +121,12 @@ def main():
115121 xref , yref = getPDFFromFile (pargs [1 ])
116122
117123 # Get configuration values
118- pars = []
119- for klass in morphs .morphs :
120- pars .extend (klass .parnames )
121- pars = set (pars )
122- keys = [p for p in pars if hasattr (opts , p )]
123- vals = [getattr (opts , k ) for k in keys ]
124- items = [(k , v ) for k , v in zip (keys , vals ) if v is not None ]
125- config = dict (items )
126- # We'll need these as well
124+ config = {}
127125 config .setdefault ("rmin" , None )
128126 config .setdefault ("rmax" , None )
129127 config .setdefault ("rstep" , None )
130- if config [ " rmin" ] is not None and config [ " rmax" ] is not None and \
131- config [ " rmax" ] <= config [ " rmin" ] :
128+ if opts . rmin is not None and opts . rmax is not None and \
129+ opts . rmax <= opts . rmin :
132130 e = "rmin must be less than rmax"
133131 parser .error (e )
134132
@@ -137,46 +135,47 @@ def main():
137135 # Add the r-range morph, we will remove it when saving and plotting
138136 chain .append ( morphs .MorphRGrid () )
139137 refpars = []
140- if "scale" in config :
138+
139+ ## Scale
140+ if opts .scale is not None :
141141 chain .append ( morphs .MorphScale () )
142+ config ["scale" ] = opts .scale
142143 refpars .append ("scale" )
143- if "stretch" in config :
144+ ## Stretch
145+ if opts .stretch is not None :
144146 chain .append ( morphs .MorphStretch () )
147+ config ["stretch" ] = opts .stretch
145148 refpars .append ("stretch" )
146- if "smear" in config :
149+ ## Smear
150+ if opts .smear is not None :
147151 chain .append ( morphs .MorphXtalPDFtoRDF () )
148152 chain .append ( morphs .MorphSmear () )
149153 chain .append ( morphs .MorphXtalRDFtoPDF () )
150154 refpars .append ("smear" )
151- refpars .append ("baselineslope" )
152- config .setdefault ("baselineslope" , - 0.5 )
153- # We need exactly one of "radius", "eradius" or "pradius"
154- radii = [config .get ("eradius" ), config .get ("pradius" )]
155- rad = None
156- if "radius" in config :
157- rad = config ["radius" ]
158- elif radii .count (None ) == 1 :
155+ config ["smear" ] = opts .smear
156+ config ["baselineslope" ] = opts .baselineslope
157+ if opts .baselineslope is None :
158+ refpars .append ("baselineslope" )
159+ config ["baselineslope" ] = - 0.5
160+ ## Size
161+ radii = [opts .radius , opts .pradius ]
162+ nrad = 2 - radii .count (None )
163+ if nrad == 1 :
159164 radii .remove (None )
160- rad = radii [0 ]
161- if rad is not None :
162- config ["radius" ] = rad
165+ config ["radius" ] = radii [0 ]
163166 chain .append ( morphs .MorphSphere () )
164167 refpars .append ("radius" )
165- elif radii .count (None ) == 0 :
166- chain .append ( morphs .MorphSpheroid () )
167- refpars .append ("eradius" )
168+ elif nrad == 2 :
169+ config ["radius" ] = radii [0 ]
170+ refpars .append ("radius" )
171+ config ["pradius" ] = radii [0 ]
168172 refpars .append ("pradius" )
169- if "qdamp" in config :
173+ chain .append ( morphs .MorphSpheroid () )
174+ ## Resolution
175+ if opts .qdamp is not None :
170176 chain .append ( morphs .MorphResolutionDamping () )
171177 refpars .append ("qdamp" )
172- if "vshift" in config or "hshift" in config :
173- if "vshift" in config :
174- refpars .append ("vshift" )
175- if "hshift" in config :
176- refpars .append ("hshift" )
177- config .setdefault ("hshift" , 0 )
178- config .setdefault ("vshift" , 0 )
179- chain .append ( morphs .MorphShift () )
178+ config ["qdamp" ] = opts .qdamp
180179
181180 # Now remove non-refinable parameters
182181 if opts .exclude is not None :
@@ -241,7 +240,10 @@ def main():
241240 # Plot extent defaults to calculation extent
242241 pmin = opts .pmin if opts .pmin is not None else opts .rmin
243242 pmax = opts .pmax if opts .pmax is not None else opts .rmax
244- pdfplot .comparePDFs (pairlist , labels , rmin = pmin , rmax = pmax )
243+ maglim = opts .maglim
244+ mag = opts .mag
245+ pdfplot .comparePDFs (pairlist , labels , rmin = pmin , rmax = pmax , maglim
246+ = maglim , mag = mag )
245247
246248 return
247249
0 commit comments