function [dolm,tetm] = geo2mag (dolg,tet)
% 11/12 bae from GGMRAW.for from UAM Matthias Foerster geo2mag convert from geog to mag
      ZPI=6.28318530718;
      FAKTOR=0.01745329252;
      CBG=11.4*FAKTOR;
      CI=COS(CBG);
      SI=SIN(CBG);
        XLM=DOLM;
        BM=90.-TETM;
        CBM=COS(BM*FAKTOR);
        SBM=SIN(BM*FAKTOR);
        CLM=COS(XLM*FAKTOR);
        SLM=SIN(XLM*FAKTOR);
        SBG=SBM*CI-CBM*CLM*SI;
        BG=ASIN(SBG);
        CBG=COS(BG);
        SLG=(CBM*SLM)/CBG;
        CLG=(SBM*SI+CBM*CLM*CI)/CBG;
        IF(CLG>1. | (1.-CLG)<1.E-10)
          CLG=1.;
        end
        IF(CLG<-1. | (1.+CLG).LT.1.E-10)
          CLG=-1.;
        end
        XLG=ACOS(CLG);
        IF(SLG<0.0) 
          XLG=ZPI-ACOS(CLG);
        end
        BG=BG/FAKTOR;
        XLG=XLG/FAKTOR;
        XLG=XLG-69.8;
        IF(XLG<0.0) 
          XLG=XLG+360.0;
        end
        TET=90.-BG;
        DOLG=XLG;
function [dolg,tet] = mag2geo (dolm,tetm)
% 11/12 bae from GGMRAW.for from UAM Matthias Foerster mag2geo convert from mag to geog
      ZPI=6.28318530718;
      FAKTOR=0.01745329252;
      CBG=11.4*FAKTOR;
      CI=COS(CBG);
      SI=SIN(CBG);
        BG=90.-TET;
        XLG=DOLG;
        YLG=XLG+69.8;
        CBG=COS(BG*FAKTOR);
        SBG=SIN(BG*FAKTOR);
        CLG=COS(YLG*FAKTOR);
        SLG=SIN(YLG*FAKTOR);
        SBM=SBG*CI+CBG*CLG*SI;
        BM=ASIN(SBM);
        CBM=COS(BM);
        SLM=(CBG*SLG)/CBM;
        CLM=(-SBG*SI+CBG*CLG*CI)/CBM;
        if(abs(clm)>1.)
          CLM=sign(CLM);
        end
        XLM=ACOS(CLM);
        IF(SLM<0.0) 
          XLM=ZPI-ACOS(CLM);
        end
        BM=BM/FAKTOR;
        XLM=XLM/FAKTOR;
        DOLM=XLM;
        IF(ABS(TET-180.)<1.E-3)
          DOLM=0.;
        end
        TETM=90.-BM;
