MaglibWarpper.hh 2.82 KB
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   MaglibWarper.hh
 * Author: hacene
 *
 * Created on July 21, 2020, 1:16 PM
 */

#ifndef MAGLIBWARPER_HH
#define MAGLIBWARPER_HH

#include "maglib.hh"

namespace AMDA {
    namespace Parameters {
        namespace maglib {

            class maglibWarpper {
            public:

                static void getPosmag(int iyear, int imonth, int iday, int ihour, int imin, int isec, float& rrmag, float& thetr, float& phir,
                        int& isatex, int& magout, float& xgsm, float& ygsm, float& zgsm, float& xgse, float& ygse, float& zgse, float& tgl,
                        float& flg, float& xlambr, float& tglc, float& hsl, float& clatgmr, float& clongmr, std::vector<int>& iposmg, int& ifail) {
                    /**
                     * 
                     * @param iyear enre 2000 et 2015 
                     * @param imonth
                     * @param iday
                     * @param ihour
                     * @param imin
                     * @param isec
                     * @param rrmag   distance radiale geocentrique (rayons terrestres)
                     * @param thetr     colatitude geocentrique (radians)
                     * @param phir      longitude geocentrique (radians)
                     * @param  isatex       : 0 = satellite proche      (apogee < 8. r. terre.)
i                *              isatex     : 1 = satellite excentrique (apogee > 8. r. terre.)
                     */
                    // declaration 
                    int iposmg_size =15;
                    int iposmg_o [iposmg_size];
                    memset(iposmg_o, 0, iposmg_size * sizeof (int));

                    float rig[3][3], rgi[3][3], rgsm[3][3], rsmg[3][3], rggsm[3][3], rgsmg[3][3], rgse[3][3], rseg[3][3];
                    float rgdip[3][3], rdipg[3][3], rigsm[3][3], rgsmi[3][3];
                    float alfag, alfas, deltas, tilt, tetdip, phidip, year;

                    valfix_(&ifail);
                    inigeom_(&iyear, &imonth, &iday, &ihour, &imin, &isec, year, &alfag, &tetdip, &phidip, &alfas, &deltas, rig, rgi, rgdip, rdipg, rgsm,
                            rsmg, &tilt, rggsm, rgsmg, rgse, rseg, rigsm, rgsmi, &ifail);

                    posmag_(&magout, &isatex, &year, &rrmag, &thetr, &phir, &alfag, &alfas, &deltas, &tilt, rgsm, rggsm, rgsmg, rgdip, rgse, &tetdip,
                            &phidip, &xgsm, &ygsm, &zgsm, &xgse, &ygse, &zgse, &tgl, &flg, &xlambr, &tglc, &hsl, &clatgmr, &clongmr, iposmg_o, &ifail);

                    for (int i = 0; i < iposmg_size; i++)
                        iposmg[i] = iposmg_o[i];
                }
            };

        }
    }
}
#endif /* MAGLIBWARPER_HH */