Re: issue plotting Flux of a data set

From: David P. Huenemoerder <dph_at_email.domain.hidden>
Date: Thu, 11 Nov 2010 10:33:09 -0500
    Manfred> Mike wrote:
    >> Actually, you've found me right now programming up a simple script to
    >> rename the "gauss" function to the names of pre-specified lines
    >> (e.g., Ne9r, Ne9i, Nef), and then sort them into ascending wavelength
    >> order in your fit function.  (Manfred - I'm sure you'll tell me that
    >> you've already done this.)

    Manfred> Well, I have the "lines" model (which you, as you will remember, have 
    Manfred> already used!), which comes with some associated functions (like 


Continuing the off-topic thread...

Naming your models is actually a slightly risky thing to do (but it
can be convenient).  ISIS has had a user-named model for a long time
-- the aped plasma model whose name you assign with create_aped_fun().
It's great because it is very flexible (even the number of parameters
is somewhat arbitrary).  I also wrote a multi-gauss function for
someone else once - one name ("ngauss"), but more parameters (like
"ngauss(1).center_23"). 

Named models can, however, lead to incompatiblities between par files
and scripts if you are not careful.

The risk is that you have to run the script which defines the model
(name and parameters) before loading any par file.  (I don't think it
is possible in general to know what model function should be assigned
to any name from the par file itself, but maybe John has included some
support for that).  So you do need to think ahead if you want to have
easily reusable par files -- you need to write your model-definition
script carefully and load it before using your models.  If sharing
models via a par file, you also have to share code (and remember, you
usually have to share with your future self, when trying to re-run
something from a year or two ago and your code changed, but par files
didn't).

I typically work with ~100 lines, and am happy to have them named
gauss(n).  Usually n < 8, since I fit one "feature" (region of the
spectrum with interesting lines and their nuisance blends) at a time.

My solution for naming models was to write a manager which contains
the info about every region and which uses a database of line
mnemonics ("Ne9HeLar", "Fe19w13.42", etc) which can be used to
evaluate other properties (e.g., the plasma database ids, the
emissivity vs T).  So I do work with the mnemonics rather than knowing
which n in gauss(n) is what.

Fitting is idiosyncratic, but ISIS supports that by letting you define
and manage your own procedures, appropriate to your data and habits
(good and bad).  In my case, 1) named models didn't exist when I wrote
the scripts, and 2) there was extra information I wanted to handle.
Regarding 1 - today I still would not use the names for the models,
but that's my preference.

-- Dave

David Huenemoerder  617-253-4283 (o); -253-8084 (f); http://space.mit.edu/home/dph
MIT Kavli Institute for Astrophysics and Space Research
70 Vassar St., NE80-6065,
Cambridge, MA  02139
[Admin. Asst.: Elaine Tirrell, 617-253-7480, egt_at_email.domain.hidden

P.S.  example fit-manager data: (more than you want to know)

variable Feature_List = Assoc_Type[ Struct_Type ] ; 

variable Feature_Info = struct  {
      plot_xmin        % wmin, wmax for good visualization on plot.
    , plot_xmax        % 
    , plot_ymin        % ymin, ymax, for plot, or 0,0
    , plot_ymax        % 
    , ntc_xmin         % wmin, wmax for fit - need good contin.
    , ntc_xmax         % 
    , Line_List        % for line info/fit - Line_Info struct;
    , stat             % fit statistic
};
%%

variable Line_Info = struct {
      name
    , wave_pred
    , wave
    , area
    , sigma
    , wlo
    , whi
    , alo
    , ahi
    , slo
    , shi
    , wctype    % conf type, 0, 1, or 2
    , actype    % conf type, 0, 1, or 2
    , sctype    % conf type, 0, 1, or 2
    , next
} ; 

Example results table (par file data plus ancillary data):

%    Feature            Line    Wpred     Wfit      wlo      whi      Flux      Flow     Fhigh    Sigma    siglo    sighi wclev aclev sclev     stat
   Ne9HeLari      Fe20w13.38   13.385  13.3818  13.3804  13.3837 4.644e-05 4.08924e-05 5.22032e-05    0.002     NULL     NULL 0.68 0.68 NULL  4.92
   Ne9HeLari      Fe19w13.42   13.423   13.423     NULL     NULL 3.376e-05 2.79723e-05 3.97059e-05    0.002     NULL     NULL NULL 0.68 NULL  4.92
   Ne9HeLari        Ne9HeLar  13.4473  13.4504  13.4499  13.4507 3.517e-04 0.000334776 0.000364982    0.002     NULL     NULL 0.68 0.68 NULL  4.92
   Ne9HeLari      Fe19w13.46   13.462   13.462     NULL     NULL 1.259e-04 0.000114422 0.000141208    0.002     NULL     NULL NULL 0.68 NULL  4.92
   Ne9HeLari      Fe19w13.50   13.497  13.5089  13.5082  13.5096 2.006e-04 0.000186697 0.000215131    0.002     NULL     NULL 0.68 0.68 NULL  4.92
   Ne9HeLari      Fe19w13.52   13.518   13.527  13.5262  13.5279 1.783e-04 0.00016496 0.00019222    0.002     NULL     NULL 0.68 0.68 NULL  4.92
   Ne9HeLari        Ne9HeLai  13.5517  13.5578  13.5566  13.5588 1.019e-04 9.32271e-05 0.000110738    0.002     NULL     NULL 0.68 0.68 NULL  4.92

Example par file...

wabs(1) * ( fast_aped_contin(1)  + gauss(1) + gauss(2) + gauss(3) + gauss(4) + gauss(5) + gauss(6) + gauss(7) )
 idx  param                 tie-to  freeze         value         min         max
  1  wabs(1).nH                 0     1                0           0      100000  10^22
  2  fast_aped_contin(1).norm   0     1                1           0          10  
  3  gauss(1).area              0     0     4.643956e-05       1e-09         0.1  photons/s/cm^2
  4  gauss(1).center            0     0         13.38178    13.37153    13.39153  A
  5  gauss(1).sigma             0     1            0.002      0.0004        0.01  A
 ...
 20  gauss(6).sigma             5     1            0.002      0.0004        0.01  A
 21  gauss(7).area              0     0     0.0001019019       1e-09         0.1  photons/s/cm^2
 22  gauss(7).center            0     0         13.55779    13.54771    13.56771  A
 23  gauss(7).sigma             5     1            0.002      0.0004        0.01  A

----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
Received on Thu Nov 11 2010 - 10:33:19 EST

This archive was generated by hypermail 2.2.0 : Tue Nov 13 2012 - 08:45:43 EST