This package contains the FORTRAN files for the various disambiguation methods described in Crouch (Solar Physics, 282, 107, 2013, DOI: 10.1007/s11207-012-0149-8) included in this package as ms.pdf, namely the global minimisation methods and the hybrid method.

COMPILING

This code has been developed using the Intel FORTRAN compiler, ifort. It is written in standard FORTRAN f77 and it should compile using other compilers but this has not been tested. To compile the code type on the command line:

make ambig.x86_64.ifort

RUNNING THE CODE

Type on the command line:

./ambig.x86_64.ifort

THE PARAMETER EDS

The definition of the quantity to be minimised is controlled by the parameter eds in the file include_file.eds.f. If the parameter eds is changed, the code must be recompiled. This is because there are many if and case statements involving eds and the code will run faster if eds is hard-coded rather than used as an input parameter. The correspondence between the value of the parameter eds and the definition of the quantity to be minimised are as follows (for details see Crouch (Solar Physics, 282, 107, 2013))

c eds=1 div(B) see equation (7) of Crouch (2013)
c eds=2 div(B)+lambda*Jz see equation (8) of Crouch (2013)
c eds=6 div(B)+lambda*J see equation (9) of Crouch (2013)
c eds=7 div(B)+lambda2*(smoothness constraint) see equations (10) and (11) of Crouch (2013)

OTHER INPUT PARAMETERS

The subroutine read_inputs reads the file me.in which contains several input parameters. By default the file me.in lives in the same directory where code is run. The input parameters are:

c iseed an integer controlling the seed for the random number generator, also used to label the output files (see output.f)
c
c lambda the weighting factor for the additional constraints based on the current density (eds=2 and eds=6)
c
c lambda2 the weighting factor for the additional constraint based on the smoothness of the magnetic field (eds=7)
c
c Btmin the threshold for the magnitude of the transverse component of the field below which pixels are revisited by the smoothing
c       algorithm (see post2.f)
c
c iverb an integer controlling the degree of verbosity of printed output
c
c tfac0 scales the initial temperature used by the simulated annealing algorithm (see minimise_energy.f)
c
c tfactr is the cooling rate used by the simulated annealing algorithm (see minimise_energy.f)
c
c neq controls the number of reconfigurations that are attempted at each temperature setting used by the simulated annealing
c     algorithm (see minimise_energy.f)
c
c nxa,nya,nxb,nyb control the boundaries of the regions to be disambiguated. If the inputs are zero or negative then the field of
c                 view values are used.
c                 nxa (nya) is the x (y) index of the bottom left pixel. nxb (nyb) is the x (y) index of the top right pixel.
c                 The region to be disambiguated is rectangular unless the value of mask is not one (see setup_mask.f), which is not
c                 implemented here.

INPUT/OUTPUT

By default the input files containing the magnetic field information need to be in the directory temp/mgram2. To change this see include_file.two_heights_files.f. The input files are:

mgram.dat which contains pixel size information, position information and the size of the field of view. The parameters are:

dxi the pixel size in the image x direction

nx the size of the field of view in the image x direction

dyi the pixel size in the image y direction (in the same units as dxi)

ny the size of the field of view in the image y direction

theta is the central meridian angle of the center of the field of view

phi is the latitude of the center of the field of view

dz the separation between the two heights in the line-of-sight direction (in the same units as dxi and dyi)

b is the solar b-angle

p is the solar p-angle 

For the first observation height, the magnetic field files are Bx_in.dat, By_in.dat, and Bz_in.dat, which respectively contain the components of the magnetic field in the x, y, and z image directions (where the z image direction is the line-of-sight direction). For the second height, the files are Bx_in_h1.dat, By_in_h1.dat, and Bz_in_h1.dat. For the expected format of these files see setup_gen2.f.

This package is shipped with a simple example contained in temp/mgram2. For a sensible choice of input parameters the code should retrieve the correct azimuthal angle in all pixels (the correct configuration of azimuthal angles corresponds to the field provided in temp/mgram2).

The output to file of the final disambiguated solution at each height is controlled by the subroutine in output.f. The x-image and y-image components of the field at each height, in the arrays Bx and By (for the first height) and Bx2 and By2 (for the second height), are output. For details of formatting and the file name convention see output.f.

If you have any questions please contact me at ash@cora.nwra.com
