@@ -233,7 +233,7 @@ def plot(self, fig=None, axes=None):
233233 ax .set_ylabel ("$\log(" + self .file_type + ")\ \mathrm{[W\cdot cm^3]}$" )
234234
235235
236- def read_filter_response (filepath , adas_format = True , plot = False ):
236+ def read_filter_response (filepath , adas_format = True , plot = False , ax = None ):
237237 """Read a filter response function over energy.
238238
239239 This function attempts to read the data checking for the following formats (in this order):
@@ -274,22 +274,9 @@ def read_filter_response(filepath, adas_format=True, plot=False):
274274 response += [float (t ) for t in line .split ()]
275275
276276 # energy and response function are written in natural logs
277- E_eV = np .concatenate (
278- (
279- [
280- 0.0 ,
281- ],
282- np .array (np .exp (E_eV )),
283- )
284- )
285- response = np .concatenate (
286- (
287- [
288- 0.0 ,
289- ],
290- np .array (np .exp (response )),
291- )
292- )
277+ E_eV = np .r_ [0 ,np .exp (E_eV )]
278+ response = np .r_ [0 , np .exp (response )]
279+
293280 except ValueError :
294281 try :
295282 # Attempt to read CXRO format
@@ -300,31 +287,17 @@ def read_filter_response(filepath, adas_format=True, plot=False):
300287 tmp = line .strip ().split ()
301288 E_eV .append (float (tmp [0 ]))
302289 response .append (float (tmp [1 ]))
303- E_eV = np .concatenate (
304- (
305- [
306- 0.0 ,
307- ],
308- np .array (E_eV ),
309- )
310- )
311- response = np .concatenate (
312- (
313- [
314- 0.0 ,
315- ],
316- np .array (response ),
317- )
318- )
290+ E_eV = np .r_ [0 , E_eV ]
291+ response = np .r_ [0 , response ]
319292 except ValueError :
320293 raise ValueError ("Unrecognized filter function format..." )
321294
322295 if plot :
323- fig , ax = plt .subplots ()
296+ if ax is None :
297+ fig , ax = plt .subplots ()
324298 ax .semilogx (E_eV , response )
325299 ax .set_xlabel ("Photon energy [eV]" )
326300 ax .set_ylabel ("Detector response efficiency" )
327- plt .tight_layout ()
328301
329302 return E_eV , response
330303
0 commit comments