Compilations of Research Codes by James Wanliss

17/12/2002
6/5/2003

 
 
 
 
 
Listing

 Matlab Codes
C/C++ codes
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
I
I
J
J
K
K
L
L
M
M
N
N
O
O
P
P
Q
Q
R
R
S
S
T
T
U
U
V
V
W
W
X
X
Y
Y
Z
Z

 
 
 
 
 
 Code listing
coord_convert.m
Coord_latlon.m
dfa.m
dfa2.m
dfam.m
dfam2.m
loadmag.m
loadmsp.m
magplot.m
make_kappa.m
mapper2.m
photo.m
plotmag.m
plotmagv3.m
rs1.m
rs2.m
Rigidity.m
T87.m
yearmonthday.m
dfa.c
dfa2.c
mexT87.c
preparephoto.c
preparemag.c


 
 
  Back
 
 
 
 
 
 
 

MATLAB CODES

A


*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 

B




*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

C



* coord_convert.m
 
 

PURPOSE:  Convert between different coordinate systems
 
 

USAGE:

[out1,out2,out3,GST,SLONG,SRASN,SDEC,PSI,MLT]=coord_convert(initial,final,in1,in2,in3,control1,year,month,day,doy,control2,hour,minute,second)


OUTPUT: r,lat,lon or x,y,z in the chosen coordinate system
 
 

LOCATION: /home/wanliss/matlab/Coordinate_Conversion
 
 

NOTES:

% 
% [out1,out2,out3,GST,SLONG,SRASN,SDEC,PSI,MLT]=coord_convert(initial,final,in1,in2,in3,control1,year,month,day,doy,control2,hour,minute,second)
%
% Coordinate Systems Available: (use these numbers for 'initial' and 'final')
% 1 - AACGM
% 2 - GEI
% 3 - GEO
% 4 - GSE
% 5 - GSM
% 6 - MAG
% 7 - SM
%
% INPUTS:
% --------
%
% initial - integer value that corresponds to the input coordinate system
% final - integer value that corresponds to the desired output coordinate system
% in1 - input coordinate variable 1 - if input is in Cartesian, this is X in Earth Radii (Re)
% - if input is Spherical, this is height above ground in kilometers (km) (i.e. Radial Distance minus Earth Radius)
% in2 - input coordinate variable 2 - if input is in Cartesian, this is Y in Earth Radii (Re)
% - if input is Spherical, this is latitude in degrees (deg) the range is [-90 90]
% in3 - input coordinate variable 3 - if input is in Cartesian, this is Z in Earth Radii (Re)
% - if input is Spherical, this is longitude in degrees (deg) the range is (-inf inf)
% control1 - integer value that specifies the form for the input and output:
% switch (control1)
% case 1 - in and out are both Cartesian
% case 2 - in is Cartesian, out is Spherical
% case 3 - in is Spherical, out is Cartesian
% case 4 - in and out are both Spherical
% year,month,day,doy - year, month, day, and day of year for the coordinate conversion (integer values only)
% control2 - since (month + day) and (doy) specifies the same information, only one of the two needs to be specified
% control2 = 1 - use month and day, doy becomes a dummy variable and will not be used, input anything for doy
% control2 = 2 - use doy, month and day become dummy variables and will not be used, input anything for month and day
% hour,minute,second - specifies the time for the coordinate conversion (integer values only)
%
%
% OUTPUTS:
% ---------
%
% out1,out2,out3 - output coordinate variables
% - these are in the same format as in1, in2, and in3
%
% GST - Greenwich Mean Sidereal Time (hr)
% SLONG - Solar Longitude Along Ecliptic (deg)
% SRASN - Solar Right Ascension (hr)
% SDEC - Solar Declination (deg)
% PSI - Dipole Tilt Angle (deg)
% MLT - Magnetic Local Time (hr)
%
% Note: if AACGM is not selected as either input or output, then MLT will not be available
% if AACGM is selected as both input or output, then GST, SLONG, SRASN, SDEC, and PSI will not be available



* Coord_latlon.m
 
 

PURPOSE: CANOPUS station locations in various coordinate systems
 
 

USAGE: [lat,lon]=Coord_latlon('RANK110','PACE');
 
 

OUTPUT: lat,lon in the chosen coordinate system
 
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmpa
 
 

NOTES:   Input a selected latitude and outputs that latitude
  and the correct PACE longitude

  station='RANK110','RANK230','GILL110','GILL230',
                'PINA110','PINA230','FSMI110','FSMI230'

  coord='GEOD','EDFL','AACGM','PACE'



  This code will output the correct latitude and longitude in the
  chosen coordinate system for the 1995 epoch.

  e.g. [lat,lon]=Coord_latlon('RANK110','PACE');

  James Wanliss
  November 2000

  Was preceeded by PACElon.m

 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

D



* dfa.m (superseded by dfa2.m)
 
 PURPOSE: Calculate Hurst exponent via detrended fluctuation analysis

  

USAGE: [x,y]=dfa(d,K,h,ii,l,MINBOX,u,MAXBOX,s,data)
 
 

OUTPUT: Slope of log(x) versus log(y) gives the Hurst exponent
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: Utilises dfa.c

%  -d K             detrend using a polynomial of degree K
%                    (default: K=1 -- linear detrending)
%  -h               print this usage summary
%  -i               input series is already integrated
%  -l MINBOX        smallest box width (default: 2K+2)
%  -u MAXBOX        largest box width (default: NPTS/4)
%  -s               sliding window DFA
% The standard input should contain one column of data in text format.
% The standard output is two columns: log(n) and log(F) [base 10 logarithms],
% where n is the box size and F is the root mean square fluctuation.
%
% fBm is by definition already integrated
% fGm must be integrated
%
% Use MINBOX>=16 because of poor stats for small n
%
% [x,y,dy]=dfa(1,1,0,1,1,16,0,0,0,fBm9);
% x=log10(rs);y=log10(mse);dy=d(log10(y))=delta_y/y/ln(10)
% errorbar(x,y,dy);
% [m,c,dm,dc]=lsqfitydy(x,y,dy)
%
% Wanliss 5/2003



* dfa2.m (supersedes dfa.m)
   

PURPOSE: Calculate Hurst exponent via detrended fluctuation analysis, now with error analysis
 
 

USAGE: [x,y,dy]=dfa2(nfit,iflag,minbox,maxbox,sw,err,data)
 

OUTPUT: Slope of log(x) versus log(y) gives the Hurst exponent; errorbar is dy./y if natural logs are used
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: Utilises dfa2.c
% Err is measuring uncertainty; e.g. 0.1 nT
%  -d K             detrend using a polynomial of degree K
%                    (default: K=1 -- linear detrending)
%  -h               print this usage summary
%  -i               input series is already integrated
%  -l MINBOX        smallest box width (default: 2K+2)
%  -u MAXBOX        largest box width (default: NPTS/4)
%  -s               sliding window DFA
% The standard input should contain one column of data in text format.
% The standard output is two columns: log(n) and log(F) [base 10 logarithms],
% where n is the box size and F is the root mean square fluctuation.
%
% fBm is by definition already integrated
% fGm must be integrated
%
% Use MINBOX>=16 because of poor stats for small n
%
%[x,y,dy]=dfa2(1,0,16,0,0,0.1,f);
% x=log10(rs);y=log10(mse);dy=d(log10(y))=delta_y/y/ln(10)
% errorbar(x,y,dy);
% [m,c,dm,dc]=lsqfitydy(x,y,dy)

% x=log10(rs);y=log10(mse);dy=d(log10(y))=delta_y/y/ln(10)
% errorbar(x,y,dy);
% [m,c,dm,dc]=lsqfitydy(x,y,dy)
 

* dfam.m (pure matlab version of dfa2.m)
   

PURPOSE: Calculate Hurst exponent via detrended fluctuation analysis, now with error analysis
 
 

USAGE: [x,y,dy]=dfam2(nfit,iflag,minbox,maxbox,sw,dely,data)

OUTPUT: Slope of log(x) versus log(y) gives the Hurst exponent; errorbar is dy./y if natural logs are used
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: Uses Peng algorithm
 



* dfam2.m (supersedes dfa.m)
   

PURPOSE: Calculate Hurst exponent via detrended fluctuation analysis, now with easier error analysis
 
 

USAGE: [x,y,dy]=dfam2(nfit,iflag,minbox,maxbox,sw,err,data)
 

OUTPUT: Slope of log(x) versus log(y) gives the Hurst exponent; errorbar is dy./y if natural logs are used
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: Most mature version of the dfa-series codes

% USAGE: [x,y,dy]=dfam2(nfit,iflag,minbox,maxbox,sw,data)

% Slightly different algorithm than Peng et al., allows easier computation
% of uncertainty
%
%  nfit             detrend using a polynomial of degree nfit
%                    (default: nfit=1 -- linear detrending)
% iflag=1/0         integrate/don't
% minbox            smallest box width (default: 2nfit+2)
% maxbox            largest box width (default: NPTS/4)
% sw=0/1            sliding window DFA off/on
%
%[x,y,dy]=dfam2(1,0,16,0,0,f);
%[m,c,dm,dc]=lsqfitydy(log(x),log(y),dy./y)



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

E



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

F



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

G



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

H



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

I



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

J



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

K



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

L



* loadmag.m
 
 

PURPOSE: Load magnetometer data from CANOPUS (1990-2001) into memory
 
 

USAGE: date='950309';loadmag;
 
 

OUTPUT: Loads all photometer files for that date
 
 

LOCATION: ~/matlab/CANOPUS.dir/Plotmag/
 
 

NOTES: date='yymmdd'
 



* loadmsp.m
 
 

PURPOSE: Load Meridian scanning photometer data from CANOPUS (1990-2001) into memory
 
 

USAGE: date='950309';loadmsp;
 
 

OUTPUT: Loads all photometer files for that date
 
 

LOCATION: ~/matlab/CANOPUS.dir/Plotmpa/
 
 

NOTES: date='yymmdd'
 



*


 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

M



* magplot.m/plotmag.m
 
 

PURPOSE:
Plot CANOPUS magnetometer data 
 

USAGE: [x2,y2,z2,place,year2,day2,hour2,minute2,second2,interval2,totalvadjust]=plotmag(date,stationvec,[tinitial,tfinal],plottype,variable,readbefore)
 
 

OUTPUT:
  eg. plotmag('a95138',[0 0 0 1 0 0 0 0 0 0 0 0 1 0],'all',3,'y',0)
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmag/new
 
 

NOTES: 
date -- in the form yyddd  yy=two digit year  ddd=three digit day of year, then add 'a' in front of date (yyddd --> ayyddd)

stationvec -- logical station vector
                the station list is:
                [TALO RANK ESKI FCHU BACK GILL ISLL PINA CONT FSIM FSMI RABB MCMU DAWS]
                e.g. if stations FCHU and MCMU are desired, then the logical station vector should be [0 0 0 1 0 0 0 0 0 0 0 0 1 0]

tinitial -- start time for plot in hour of day eg. 1:35:45 == 1.5958333
tfinal -- end time for plot in hour of day     formula: hour+minute/60+second/3600
  If the user wishes to plot entire time interval, input "all" for [tinitial,tfinal]

plottype 1 -- plot data versus data position   (avaliable only for individual stations)
            2 -- plot data versus time in seconds of day (standard)   (avaliable only for individual stations)
            3 -- plot data versus time in minutes of day (standard)
            4 -- plot data versus time in hours of day (standard)
           be careful when choosing plottype 1 because data position #1, doesn't automatically mean time=0:00

 variable 'x' -- plot x dimensional data
           'y' -- plot y dimensional data
           'z' -- plot z dimensional data

readbefore -- if the user wishes to plot data from the same file then the data does not need to be read in twice;
                if this is the case, then set readbefore=1; otherwise readbefore=0;
                when readbefore=1, then the user should add the output arguments:
                x2,y2,z2,place,year2,day2,hour2,minute2,second2,interval2
                to the end of the 6 input arguments

 



* make_kappa.m
 
 

PURPOSE: Find kappa values K^2=R/rc where R=radius of curvature, rc=gyroradius
 
 

USAGE: [ki,ke]=kappa(x,y,z,Wi,We,model,variables)
 
 

OUTPUT: Proton (ki) and electron (ke) kappa values for given 'model' and particle energies (eV) at a given position
 
 

LOCATION: /home/wanliss/matlab/
 
 

NOTES: function [ki,ke]=kappa(x,y,z,Wi,We,model,variables)

% Find kappa parameter
%
% [ki,ke]=kappa(x,y,z,Wi,We,model)
%
% K = sqrt(Rc/r)
%
% Rc is the radius of curvature of the magnetic field
%
% Rc = Bz/(dBx/dz) at y=0
%
% vec{Rc}/Rc^2=-(vec{B} dot grad)vec{B}/B^2
%
% r is gyroradius = mv/q Bz
% W in eV
%
% 26/3/1998 - working version
% Modified 2/2003 Wanliss


 



* mapper2.m
 
 

PURPOSE: Find streamlines (usually from equator) that end in the ionosphere
 
 

USAGE: [x2,y2,z2,lat,lon]=mapper2(x1,y1,z1,model,variables)
 
 

OUTPUT: Positions, latitude, longitude of field lines
 
 

LOCATION: /home/wanliss/matlab
 
 

NOTES:function [x2,y2,z2,lat,lon]=mapper2(x1,y1,z1,model,variables)

% Calculating magnetic field lines (streamlines)
% Can start anywhere and goes to the ionosphere
% [x2,y2,z2,lat,lon]=mapper2(x1,y1,z1,model,thick)
% e.g. [x,y,z]=mapper2(-15,0,0,@T87,[3,-29]);
% e.g. [x,y,z]=mapper2(-15,0,0,@M1,3);
%
% Wanliss
% Modified March 28/2002
% Modified 2/2003 Wanliss
%


 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:


 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:





O



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

P



* photo.m
 
 

PURPOSE: Plot CANOPUS photometer data
 
 

USAGE: photo
 
 

OUTPUT:
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmpa
 

NOTES: Uses plotmpa.m

 1.  How to run the GUI
  -----------------------

  At the command line type:

  >> photo

  This starts the GUI.  Now proceed to the GUI.



  2.  Data
  ---------

  The GUI can load data from files by pressing the "Load Data" button.  This
  will employ the loadmpa GUI.  Select the file that needs to be loaded and
  press "Load".  Once loaded, the data is stored in variables which are
  visible in the box labelled "Current Available Variables."  The user may
  also load the data using the Matlab command window.  Press "Update Current
  Variables" to show all the currently available variables.  To select the
  data to plot, just double click on the varaible.  The variable will appear
  in the "Selected Data" text box.  The user may also directly edit this
  box to change the data to plot.

  The format of the data files that are loaded has a slight variation from
  the original files that one can obtain from CANOPUS (ASCII files of photometer
  data).  The first line of these files gives information about the station,
  date, start time, and interval.  This line must be commented out by placing a
  percentage sign (%) at the beginning of this line.  If this is not done, then
  the file will not load properly in Matlab.



  3.  Station
  ------------

  The photometer station name and altitude of where the data is taken must
  be specified in the Station section.  The stations to choose from are:
  FCHU, FSIM, FSMI, GILL, ISLL, PINA, and RANK.  The avaliable altitudes
  are: 110 and 230.



  4.  Options
  ------------

  When the program starts, all the options are defaulted.  To edit the
  options, the "default everything" checkbox must be clicked off.

  a. Time
  --------
  The time interval to plot needs to be specified.  The units are in minutes
  ranging from 1 min to 1440 min.  Setting to "full range" will
  automatically select a range from 1 min to 1440 min.  Selecting "manual"
  allows the user to select more specific choices.  The time range of the
  data might not span the entire interval from 1 min to 1440 min.  In this
  case, the user must specify a valid range in which data is avaliable.

  b. CLim
  --------
  This is the color coding range limits for the plot.  "Auto" will
  automatically set the range.  Selecting "manual" allows the choice of user
  selected ranges.

  c. Scale
  ---------
  The scale of the color coding can be in linear ("linear") or base 10
  logarithmic ("log10") form.  Usually, the activity levels within a graph
  varies by many orders of magnitude so using "log10" is recommended.

  d. Type
  --------
  This defines the type of 2D interpolation for the photometer data.  Here
  are the options:
     "nearest" - nearest neighbor interpolation
     "linear"  - bilinear interpolation
     "cubic"   - bicubic interpolation
     "spline"  - spline interpolation
  The default type is "cubic."  Note that the output is not the raw data.

  e. Advanced
  ------------
  The advanced option is the implementation of border detection with the
  plotting.  If "Use Border Detect" is checked, then the program will enter
  border detection mode when "Render" is clicked.  (See Plotting)



  5. Plotting
  ------------
  After the data, station, and options have been correctly selected, click
  the "Render" button to create the photometer plot.  If "Use Border Detect"
  is unchecked, then a photometer plot will be generated.  If this advanced
  option is checked, then the user must interact with the command window to
  employ the border detection with Matlab filters.

  Using the border detection feature:

  CAUTION: Do not use this option unless the meanings of the various filters
  are understood.  The filters can be looked up in Matlab help.

  Once "Render" is pressed, 3 figures will be created.
  The user is prompted in the command window to "Input edge threshold
  parameter:"  Usually 1 or 0.9 are fair values for this.  Next, the user is
  prompted for the filter type.  The available types are: sobel, prewitt,
  roberts, log, zerocross, and canny.  The default filter type is canny.  If
  the user wishes to use canny, then just press enter.  The user does not
  need to explicitly specify "canny."  After the filter type is chosen, the
  border plots are created in black and white.  The user is then prompted to
  see if he or she is satisfied with the filtered results.  The default is
  "y" for yes, and just pressing enter will mean yes.  Input "n" to reselect
  the filter threshold and filter type.

  The two filtered black and white plots indicate the border location.  BW1
  differs from BW2 in that BW2 has reduced noise due to an iterative process
  being applied to it.  The user is then prompted to choose if he/she wants
  to use BW1 data or BW2 data for the border detection.  BW1 is recommended
  and is the default choice.  Zoom in to a region of interest before
  selecting BW1 or BW2.  Once selected, a crosshair will appear on one of
  the graphs and two input points are expected to be chosen.  These two
  points should be the start and end of a continuous border.  The detected
  border will appear in red circles.

  The user is then prompted to "Try a different fit interval (y/n/r):"
  "y" means accept the detected border and continue to detect more borders
      for the same plot.
  "n" means accept the detected border and finish the boarder detect
      process.
  "r" means reject the detected border and continue to detect more borders
      for the same plot.

  When border detection is completed, the values for the borders are stored
  in the variables "l1" and "t1."  The variables "data" contains the
  interpolated data, and the variables "BW1" and "BW2" contains the data for
  the black and white border plots.



  5. Other
  ---------

  The help button at the top right corner of the GUI brings up this help
  text.




* plotmag.m
 
 

PURPOSE:
Plot CANOPUS magnetometer data 
 

USAGE: [x2,y2,z2,place,year2,day2,hour2,minute2,second2,interval2,totalvadjust]=plotmag(date,stationvec,[tinitial,tfinal],plottype,variable,readbefore)
 
 

OUTPUT:
  eg. plotmag('a95138',[0 0 0 1 0 0 0 0 0 0 0 0 1 0],'all',3,'y',0)
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmag/new
 
 

NOTES: 
date -- in the form yyddd  yy=two digit year  ddd=three digit day of year, then add 'a' in front of date (yyddd --> ayyddd)

stationvec -- logical station vector
                the station list is:
                [TALO RANK ESKI FCHU BACK GILL ISLL PINA CONT FSIM FSMI RABB MCMU DAWS]
                e.g. if stations FCHU and MCMU are desired, then the logical station vector should be [0 0 0 1 0 0 0 0 0 0 0 0 1 0]

tinitial -- start time for plot in hour of day eg. 1:35:45 == 1.5958333
tfinal -- end time for plot in hour of day     formula: hour+minute/60+second/3600
  If the user wishes to plot entire time interval, input "all" for [tinitial,tfinal]

plottype 1 -- plot data versus data position   (avaliable only for individual stations)
            2 -- plot data versus time in seconds of day (standard)   (avaliable only for individual stations)
            3 -- plot data versus time in minutes of day (standard)
            4 -- plot data versus time in hours of day (standard)
           be careful when choosing plottype 1 because data position #1, doesn't automatically mean time=0:00

 variable 'x' -- plot x dimensional data
           'y' -- plot y dimensional data
           'z' -- plot z dimensional data

readbefore -- if the user wishes to plot data from the same file then the data does not need to be read in twice;
                if this is the case, then set readbefore=1; otherwise readbefore=0;
                when readbefore=1, then the user should add the output arguments:
                x2,y2,z2,place,year2,day2,hour2,minute2,second2,interval2
                to the end of the 6 input arguments



* plotmagv3.m
 
 PURPOSE:

Plot CANOPUS magnetometer data 
 

USAGE: [x2,y2,z2,place,year2,day2,hour2,minute2,second2,interval2,totalvadjust]=plotmagv3(date,stationvec,[tinitial,tfinal],plottype,variable,readbefore)
 
 

OUTPUT:   eg. plotmag('950113',[0 0 0 1 0 0 0 0 0 0 0 0 1 0],'all',3,'y',0)
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmag/
 

NOTES:  Supersedes plotmag.m; date is in the form yymmdd




* plotmpa.m
 
 

PURPOSE: Plot CANOPUS photometer data

 

USAGE: plotmpa(data,time,STATION,type,CLIM,scale);


OUTPUT:
Graph
 
 

LOCATION: /home/wanliss/matlab/CANOPUS.dir/Plotmpa
 
 

NOTES:


Uses: Coord_latlon.m

 Plot the Photometer data
  STATION=GILL,RANK,ISLL,PINA,FCHU,FSMI,FSIM
  type='nearest','bilinear','cubic','spline'

  CLIM= [CLOW CHIGH] can specify the scaling.
  scale='linear' or 'log10'

  e.g.
  plotmpa(data,time,STATION,type,CLIM,scale);
  plotmpa(X95033000_r_6300,[160 230],'RANK230',[],[1 3]);
  plotmpa(X95033000_r_6300,[160 230],'RANK230','cubic',[1 3],'linear');

  This code can also be used to plot merged data
  e.g.

  After running merge.m you will have output data 'lat' and 'mpa'.
  The variation is now to include this calculated merge latitude
  as the seventh input variable
  i.e.
   plotmpa(mpa,[1 240],[],[],[0 50],'linear',lat)

  James Wanliss
  November 2000

 %%%%%%%%%%%%%%% MODIFICATION
  February 2001
  Put a third option in the time vector;

  time(3)=val    => Gives the threshold for borders
  Otherwise simply leave time(3) empty

 %%%%%%%%%%%%%%% MODIFICATION
  March 5, 2001
  Modified so that one can select which border to follow after
  clicking with a mouse.  The start and end of the region to fit should be chosen.

  E.g. Using data from 950223, 486.1 nm

  [t1,l1,data,BW1,BW2]=plotmpa(gi_b, [320 372 0], 'GILL110', [],[],'linear');

  BW1 is the filtered data following the use of bidirectional Sobel filter
  BW2 is the filtered data following a morph and spur removal from BW1

  After plotting three graphs, the program gives the user the option of
  zooming in on the region of interest.  Pressing any key in the command
  window then brings up crosshairs, and requires start/end point selection via
  the mouse.
 %%%%%%%%%%%%%%% MODIFICATION
  March 19, 2001
  Modified so that one can select many borders

  Option 'r' added
  e.g.  Try a different fit interval (y/n/r): r

  'r' means reject the latest fitted border interval and try again.



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

Q



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

R



* Rigidity.m
 
 

PURPOSE: Find model particle rigidity for comparison with satellite data.
 
 

USAGE: [x,L,Rigidite,Rigiditi]=Rigidity(kappa,model,variables)
 
 

OUTPUT: x=positions where rigidity is calculated; L=corresponding L-shell position; Rigidite=value for electrons for the chosen value of Kappa, etc.
 
 

LOCATION: /home/wanliss/matlab
 
 

NOTES: function [x,L,Rigidite,Rigiditi]=Rigidity(kappa,model,variables)

% Calculate particle rigidity for T87
% cf. Popielawska and Zwolakowska, 1991, GRL, 18, 1489-1492
%
% Rigidity=G=B*gyroradius=sqrt(2*m*Ecrit/q)
%
% [x,L,Re,Ri]=Rigidity(sqrt(8),@T87,[4,0]); (units: nt m)
% Wanliss 1/2003
% x10^6 for their units
  



* rs1.m
 
 

PURPOSE: For calculating the Hurst coefficient for a time series (slope of log-log graph gives H).
 
 

USAGE: [n, rs, drs]=rs1(y)
 
 

OUTPUT: n=index; rs=rescaled range; drs=error in rs
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES:
% For calculating the Hurst coefficient for a time series.  The
% method used is from "Complexification," John L. Casti, HarperCollins,
% New York, New York, 1994, ISBN 0-06-016888-9, pp 253, or "Chaos and
% Order in the Capital Markets," Edgar E. Peters, John Wiley & Sons, New
% York, New York, 1991, ISBN 0-471-53372-6, pp 63, or "Fractals, Chaos,
% Power Laws," Manfred Schroeder, W. H. Freeman and Company, New York,
% New York, 1991, ISBN 0-7167-2136-8, pp 129, or "Applied Chaos Theory:
% A Paradigm for Complexity," A. B. Cambel.  Academic Press, San Diego,
% California, 1993, ISBN 0-12-155940-8, pp 172.  The time series is
% broken into variable length intervals, which are assumed to be
% independent of each other, and the R/S value is computed for each
% interval based on the deviation from the average over the
% interval. These R/S values are then averaged for all of the intervals.



* rs2.m

 

PURPOSE: For calculating the Hurst coefficient for a time series (slope of log-log graph gives H).
 
 

USAGE: [n, rs, drs]=rs1(y)
 
 

OUTPUT: n=index; rs=rescaled range; drs=error in rs
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: Fast version based on power two math.
 % Range Scaling Analysis (Fractal Analysis)
% This program calculates the rescaled range of a time series

% Input: the time series with equal time increments
% Output: the rescaled range

% For more detail see Peters, E.E. 1994, Fractal Market Analysis, John Wiley and
 Sons, New York



*

 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*


 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*


 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*

 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

S



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

T



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



* T87.m
 
 

PURPOSE: Calculate Tsyganenko (1987) model magnetospheric field
 
 

USAGE: b=T87([x,y,z,kp,dtilt]
 

OUTPUT: Magnetic field vector (nT) in GSM coordinates
 
 

LOCATION: /home/wanliss/matlab/MODELS.dir/T87
 
 

NOTES:
function b=T87(var)

% Function T87(var)
% var=[x,y,z,kp,dtilt,l]
% Outputs magnetic field in nT
% Wanliss 1/2003
%

U



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

V



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:

W



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




X


*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




Y


* yearmonthday.m
 
 

PURPOSE:  Calculate the doy given other parameters, or calculate other
% parameters, given doy
%
%    direction = -1     DOY -> MONTH-DAY
%    direction = 1      MONTH-DAY -> DOY


 
 USAGE: [doy,m,d]=yearmonthday(yyyy,mm,dd,doy,direction);

 
 

OUTPUT: Date
 
 

LOCATION: ~/matlab
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 





Z


*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 




 




 



 
 

C/C++ CODES



 


D

* dfa.c
 
 

PURPOSE: Detrended fluctuation analysis (Peng et al. version)
 
 

USAGE: ./dfa [OPTIONS ...]
 
 

OUTPUT: Outputs to stdio matrix with 2 columns.  Column 1 is log10(n), Column 2 is log10(mse)
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES:  OPTIONS may include:
 -d K             detrend using a polynomial of degree K
                   (default: K=1 -- linear detrending)
 -h               print this usage summary
 -i               input series is already integrated
 -l MINBOX        smallest box width (default: 2K+2)
 -s               sliding window DFA
 -u MAXBOX        largest box width (default: NPTS/4)
The standard input should contain one column of data in text format.
The standard output is two columns: log(n) and log(F) [base 10 logarithms],
where n is the box size and F is the root mean square fluctuation.
 



* dfa2.c
 
 

PURPOSE: Detrended fluctuation analysis (Peng et al. version) with error calculation
 
 

USAGE: ./dfa [OPTIONS ...]
 
 

OUTPUT: Outputs to stdio matrix with 2 columns.  Column 1 is log10(n), Column 2 is log10(mse), Column 3 is the error
 
 

LOCATION: /home/wanliss/matlab/Chaos.dir
 
 

NOTES: OPTIONS may include:
 -d K             detrend using a polynomial of degree K
                   (default: K=1 -- linear detrending)
-e dy           dy is the uncertainty in the input data
 -h               print this usage summary
 -i               input series is already integrated
 -l MINBOX        smallest box width (default: 2K+2)
 -s               sliding window DFA
 -u MAXBOX        largest box width (default: NPTS/4)
The standard input should contain one column of data in text format.
The standard output is two columns: log(n) and log(F) [base 10 logarithms],
where n is the box size and F is the root mean square fluctuation.
 
 
 


P

* preparephoto.c
 
 

PURPOSE:

Put raw CANOPUS photometer data into a format compatible with Matlab and plotmpa.m
 
 

USAGE: preparephoto filename
 
 

OUTPUT: filename
 
 

LOCATION: ~/bin
 
 

NOTES: The output filename is idnetical to the input filename, but a % has been put into the first line, which is the comment sign for Matlab,


*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES:
 



*
 
 

PURPOSE:
 
 

USAGE:
 
 

OUTPUT:
 
 

LOCATION:
 
 

NOTES: