Giter Club home page Giter Club logo

geopack's Introduction

The geopack and Tsyganenko models in Python

Author: Sheng Tian, Univ. of Minnesota, [email protected]

This python geopack has integrated two modules originally written in Fortran: the geopack and the Tsyganenko models (T89, T96, T01, and T04). The Fortran geopack05 is available at https://ccmc.gsfc.nasa.gov/modelweb/magnetos/data-based/Geopack_2005.html and geopack08 is available at http://geo.phys.spbu.ru/~tsyganenko/Geopack-2008.html. Their DLM in IDL is available at http://ampere.jhuapl.edu/code/idl_geopack.html. As a crucial complement to geopack05 and geopack08, the Tsyganenko models are available in Fortran at https://ccmc.gsfc.nasa.gov/models/modelinfo.php?model=Tsyganenko%20Magnetic%20Field.

Test results are attached in ./test_geopack1.md to demonstrate that the Python geopack returns the same outputs as the Fortran and IDL counterparts. However, invisible at the user-level, several improvements have been internally implemented:

  1. The latest IGRF coefficients are used, which cover the time range from 1900 to 2025. Years beyond this range are valid inputs and the corresponding IGRF coefficients will be extrapolated, whereas the Fortran and IDL versions do not extrapolate well if at all.

  2. The IGRF coefficients in the Python geopack are time series at a milli-second cadance, whereas the coefficients are daily in the Fortran geopack.

  3. igrf_gsm is changed to a wrapper of igrf_geo plus the proper coordinate transforms. There are many places in the Fortran version where pages of codes are copy-pasted. Though not aesthetically pleasing, I let them live in the python version, because it requires tremendous efforts to fix them all. However, the igrf_geo is the one place that is obvious and easy to fix, so I did it.

  4. All goto statements in the Fortran geopack and Tsyganenko models are eliminated.

  5. A gswgsm is added to support the new GSW coordinate introduced in geopack08.

Installation

The package requires Python pre-installed and depends on the numpy and scipy packages. I've only tested the Python geopack on Mac OS in Python 3.6. Performance on other platform and other versions of Python is unclear.

To install the Python geopack through pip, type > pip3 install geopack in the terminal.

To install the latest version, manually install on a Mac (and hopefully Linux):

  1. Download the latest package at https://github.com/tsssss/geopack/.
  2. Unzip it, open a terminal, and cd to the unzipped directory
  3. Install the package to Python by typing python3 setup.py install in the terminal

Notes on geopack08 and T07d

The Python version of geopack tries to be compatible with both Fortran geopack05 and geopack08. The major change of geopack08 is a new coordinate called GSW, which is similar to the widely used GSM but more suitable to study the tail physics. To be backward compatible with geopack05, the Python version still uses GSM as the major coordinate for vectors. However, to keep updated with geopack08, the Python version provides a new coordinate transform function GSWGSM, so that users can easily switch to their favorite coordinate. A new Tsyganenko T07d model has been released with a new algorithm. Support for T07d is under development.

Notes on the G and W parameters

There are two G parameters used as optional inputs to the T01 model. There definitions are in Tsyganenko (2001). Similarly, there are six W parameters used as optional inputs to the T04 model, defined in Tsyganenko (2005). The python version does not support the calculations of the G and W parameters. For users interested, here is the link for the Qin-Denton W and G parameters at https://rbsp-ect.newmexicoconsortium.org/data_pub/QinDenton/. Thanks for Dr Shawn Young for providing the references and relevant information.

Back in my mind, there are some potential ways to implement the G and W parameter. But please do understand that the package does not have any funding support. I usually do major updates during summer or winter break, when it's easier to find spare time. For users that are familiar with the G and W parameters, let me know if you have any suggestions or ideas on solutions to implement them in the package!

Example of getting the time tag

The model needs to be updated for each new time step. Time used is the unix timestamp, which is the seconds from 1970-01-01/00:00. Here are some examples in Python to get the time from intuitive inputs.

# Test for 2001-01-02/03:04:05 UT
import datetime
from dateutil import parser

# From date and time
t1 = datetime.datetime(2001,1,2,3,4,5)
t0 = datetime.datetime(1970,1,1)
ut = (t1-t0).total_seconds()
print(ut)
978404645.0

# From string, need the package dateutil
t1 = parser.parse('2001-01-02/03:04:05')
ut = (t1-t0).total_seconds()
print(ut)
978404645.0

Usage

Here is a short example on how to import the package and call functions. A detailed explanation of all functions is listed in the next section.

from geopack import geopack, t89

ut = 100    # 1970-01-01/00:01:40 UT.
xgsm,ygsm,zgsm = [1,2,3]
ps = geopack.recalc(ut)
b0xgsm,b0ygsm,b0zgsm = geopack.dip(xgsm,ygsm,zgsm)    		# calc dipole B in GSM.
dbxgsm,dbygsm,dbzgsm = t89.t89(2, ps, xgsm,ygsm,zgsm)       # calc T89 dB in GSM.
bxgsm,bygsm,bzgsm = [b0xgsm+dbxgsm,b0ygsm+dbygsm,b0zgsm+dbzgsm]
print(bxgsm,bygsm,bzgsm)
-539.5083883330017 -569.5906371610358 -338.8680547453352

And here is another way to import the package and refer to the functions.

import geopack

ut = 100    # 1970-01-01/00:01:40 UT.
xgsm,ygsm,zgsm = [1,2,3]
ps = geopack.geopack.recalc(ut)
b0xgsm,b0ygsm,b0zgsm = geopack.geopack.dip(xgsm,ygsm,zgsm)
dbxgsm,dbygsm,dbzgsm = geopack.t89.t89(2, ps, xgsm,ygsm,zgsm)
print(b0xgsm,b0ygsm,b0zgsm)
-544.425907831383 -565.7731166717405 -321.43413443108597

Another way to import the package.

import geopack.geopack as gp

ut = 100    # 1970-01-01/00:01:40 UT.
xgsm,ygsm,zgsm = [2,1,100]
ps = gp.recalc(ut)
xgsm,ygsm,zgsm = gp.geogsm(2,1,100, 1)
print(xgsm,ygsm,zgsm)
(-41.00700906453125, -19.962123759781406, 89.0221254665413)

To use the feature in geopack08, users can supply the solar wind magnetic field in GSE and express vectors in GSW

from geopack import geopack

ut = 100    # 1970-01-01/00:01:40 UT.
xgsm,ygsm,zgsm = [1,2,3]
vgse = [-400,0,10]                                       # solar wind velocity in GSE.
ps = geopack.recalc(ut, *vgse)                           # init with time & SW velocity.
# or use ps = geopack.recalc(ut, vgse[0],vgse[1],vgse[2])
xgsw,ygsw,zgsw = gswgsm(xgsm,ygsm,zgsm, -1)              # convert position to GSW.
b0xgsw,b0ygsw,b0zgsw = geopack.dip_gsw(xgsw,ygsw,zgsw)   # calc dipole B in GSW.
print(b0xgsw,b0ygsw,b0zgsw)
-540.5392569443875 -560.7296994901754 -336.47913346240205
print((geopack.gswgsm(b0xgsw,b0ygsw,b0zgsw, 1)))         # dipole B in GSM.
(-544.4259078313833, -565.7731166717405, -321.4341344310859)

Package Interface

The Python geopack follows the Python way: function parameters are all input parameters and the outputs are returned. (This is very different from the Fortran and IDL geopack.)

  • When changing to a new time of interest

    • recalc. Re-calculate the dipole tilt angle (and other internal parameters) for a given time.

      Example
      ps = recalc(ut)
      ps = recalc(ut, vxgse,vygse,vzgse)
      
      Input
      ut: The given time in the universal time in second.
      vxgse,vygse,vzgse: The solar wind velocity in GSE. If they are omitted, a default value of [-400,0,0] is used so that GSM and GSW are the same.
      
      Return
      ps: Dipole tilt angle in radian (defined in GSM, not GSW).
      
  • Get the internal model magnetic fields

    • dip. Calculate the internal magnetic field from the dipole model for a given position and time (The time dependence is taken care of by recalc), in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = dip(xgsm,ygsm,zgsm)
      
      Input
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      
      Return
      bxgsm,bygsm,bzgsm: Cartesian GSM components of the internal magnetic field in nT.
      
    • dip_gsw. Calculate the internal magnetic field from the dipole model for a given position and time (The time dependence is taken care of by recalc), in the GSW coordinate.

      Example
      bxgsw,bygsw,bzgsw = dip_gsw(xgsw,ygsw,zgsw)
      
      Input
      xgsw,ygsw,zgsw: The given position in cartesian GSW coordinate in Re (earth radii, 1 Re = 6371.2 km).
      
      Return
      bxgsw,bygsw,bzgsw: Cartesian GSW components of the internal magnetic field in nT.
      
    • igrf_gsm. Calculate the internal magnetic field from the IGRF model (http://www.ngdc.noaa.gov/iaga/vmod/igrf.html) for a given position and time, in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = igrf_gsm(xgsm,ygsm,zgsm)
      
      Input
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      
      Return
      bxgsm,bygsm,bzgsm: Cartesian GSM components of the internal magnetic field in nT.
      
    • igrf_gsw. Calculate the internal magnetic field from the IGRF model (http://www.ngdc.noaa.gov/iaga/vmod/igrf.html) for a given position and time, in the GSW coordinate.

      Example
      bxgsw,bygsw,bzgsw = igrf_gsw(xgsw,ygsw,zgsw)
      
      Input
      xgsw,ygsw,zgsw: The given position in cartesian GSW coordinate in Re (earth radii, 1 Re = 6371.2 km).
      
      Return
      bxgsw,bygsw,bzgsw: Cartesian GSW components of the internal magnetic field in nT.
      
    • igrf_geo. Calculate the internal magnetic field from the IGRF model (http://www.ngdc.noaa.gov/iaga/vmod/igrf.html) for a given position and time, in the GEO coordinate.

      Example
      br,btheta,bphi = igrf_gsm(r,theta,phi)
      
      Input
      r,theta,phi: The given position in spherical GEO coordinate. r is the radia distance in Re; theta is the co-latitude in radian; phi is the longitude in radian.
      
      Return
      br,btheta,bphi: Spherical GSM components of the internal magnetic field in nT. br is outward; btheta is southward; bphi is eastward.
      
  • Get the external model magntic fields

    Four models (T89, T96, T01, and T04) developed by Dr. Tsyganenko are implemented in the package.

    • t89. Calculate the external magnetic field from the T89 model for a given position and time, in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = t89(par, ps, xgsm,ygsm,zgsm)
      
      Input
      par: A model parameter. It is an integer (1-7) maps to the Kp index
      | par |  1   |    2    |    3    |    4    |    5    |    6    |  7   |
      | Kp  | 0,0+ | 1-,1,1+ | 2-,2,2+ | 3-,3,3+ | 4-,4,4+ | 5-,5,5+ | > 6- |
      ps: Dipole tilt angle in radian.
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      
    • t96. Calculate the external magnetic field from the T96 model for a given position and time, in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = t96(par, ps, xgsm,ygsm,zgsm)
      
      Input
      ps: Dipole tilt angle in radian.
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      par: A model paramter. It is a 10-element array, whose elements are (1-10)
      | par |  1   |  2  |     3-4     |   5-10   |
      | Var | Pdyn | Dst | ByIMF,BzIMF | not used |
      where Pdyn is the solar wind dynamic pressure in nPa; Dst is the Dst index in nT; ByImf,BzImf are the y and z components of the IMF (interplanetary magnetif field) in GSM.
      
    • t01. Calculate the external magnetic field from the T01 model for a given position and time, in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = t01(par, ps, xgsm,ygsm,zgsm)
      
      Input
      ps: Dipole tilt angle in radian.
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      par: A model paramter. It is a 10-element array, whose elements are (1-10)
      | par |  1   |  2  |     3-4     |  5-6  |   7-10   |
      | Var | Pdyn | Dst | ByIMF,BzIMF | G1,G2 | not used |
      where Pdyn is the solar wind dynamic pressure in nPa; Dst is the Dst index in nT; ByImf,BzImf are the y and z components of the IMF (interplanetary magnetif field) in GSM; G1,G2 are two indices defined in Tsyganenko (2001).
      
      N. A. Tsyganenko, A new data-based model of the near magnetosphere magnetic field: 1. Mathematical structure. 2. Parameterization and fitting to observations (submitted to JGR, July 2001)
      
    • t04. Calculate the external magnetic field from the T04 model for a given position and time, in the GSM coordinate.

      Example
      bxgsm,bygsm,bzgsm = t04(par, ps, xgsm,ygsm,zgsm)
      
      Input
      ps: Dipole tilt angle in radian.
      xgsm,ygsm,zgsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
      par: A model paramter. It is a 10-element array, whose elements are (1-10)
      | par |  1   |  2  |     3-4     |   5-10   |
      | Var | Pdyn | Dst | ByIMF,BzIMF | W1 to W6 |
      where Pdyn is the solar wind dynamic pressure in nPa; Dst is the Dst index in nT; ByImf,BzImf are the y and z components of the IMF (interplanetary magnetif field) in GSM; W1,W2,...,W6 are six indices defined in Tsyganenko (2005).
      
      N. A. Tsyganenko and M. I. Sitnov, Modeling the dynamics of the inner magnetosphere during strong geomagnetic storms, J. Geophys. Res., v. 110 (A3), A03208, doi: 10.1029/2004JA010798, 2005.
      

    Note: All 4 models share the same interface, but the meanings of par are very different.

  • Convert a cartesian vector among coordinates

    The supported coordinates are: GEO, GEI, MAG, GSM, GSE, and SM. They are defined in Hapgood (1992). And GSW, defined in Hones+(1986) is added in geopack_08. The functions for the coordinate transform are: geomag, geigeo, magsm, gsmgse, smgsm, geogsm,gswgsm. They share the same interface, so they are explained together.

    Usage
    b1,b2,b3 = geomag(h1,h2,h3, flag)
    
    Example
    xmag,ymag,zmag = geomag(xgeo,ygeo,zgeo,  1)
    xgeo,ygeo,zgeo = geomag(xmag,ymag,zmag, -1)
    ...
    
    Input and Return
    h1,h2,h3: Cartesian components of a vector in "coord1"
    b1,b2,b3: Cartesian components of the vector in "coord2"
    flag: flag > 0 -- coord1 to coord2; flag < 0 -- coord2 to coord1
    

    In addition geodgeo converts a position between altitude (in km)/geodetic latitude (in rad) and geocentric distance (in km)/colatitude (in rad).

    Usage
    b1,b2 = geodgeo(h1,h2, flag)
    
    Example
    rgeo,thetageo = geodgeo(hgeod,xmugeod,  1)
    hgeod,xmugeod = geodgeo(rgeo,thetageo, -1)
    
    Input and Return
    h1,h2: Components of a vector in "coord1"
    b1,b2: Components of a vector in "coord2"
    flag: flag > 0 -- coord1 to coord2; flag < 0 -- coord2 to coord1
    
  • Trace along model magnetic fields: trace

    Example
    x1gsm,y1gsm,z1gsm = trace(x0gsm,y0gsm,z0gsm, dir, rlim, r0, par, exname, inname)
    
    Input
    x0gsm,y0gsm,z0gsm: The given position in cartesian GSM coordinate in Re (earth radii, 1 Re = 6371.2 km).
    dir: Direction of tracing. dir = -1 for parallel; dir = 1 for anti-parallel.
    rlim: Maximum tracing radius in Re. Default value is 10 Re.
    r0: Minimum tracing radius in Re. Default value is 1 Re.
    inname: A string specifies the internal model, one of 'dipole','igrf'. The default value is 'igrf'.
    exname: A string specifies the external model, one of 't89','t96','t01','t04'. The default value is 't89' and its par is default to be 2.
    par: The model parameter. Its dimension and the meaning depend on the external model. Please check the interface of the models for details.
    

Functions do not appear in the above list are considered as internal functions. For usages of them, advanced users can check the source code of the Python geopack.

References

Hapgood, M. A. (1992). Space physics coordinate transformations: A user guide. Planetary and Space Science, 40(5), 711–717. http://doi.org/10.1016/0032-0633(92)90012-D

N. A. Tsyganenko, A new data-based model of the near magnetosphere magnetic field: 1. Mathematical structure. 2. Parameterization and fitting to observations (submitted to JGR, July 2001)

N. A. Tsyganenko and M. I. Sitnov, Modeling the dynamics of the inner magnetosphere during strong geomagnetic storms, J. Geophys. Res., v. 110 (A3), A03208, doi: 10.1029/2004JA010798, 2005.

geopack's People

Contributors

jameswilburlewis avatar joulecai avatar tsssss avatar w2naf avatar w2ruf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geopack's Issues

scipy and M1 arm64

My install of geopack failed on a M1 mac because the scipy install failed.

I was able to get it to work using

pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy

This isn't really a bug report but rather a comment to help others that may run into this issue.

In my code that uses geopack, I've added

import platform
import magnetovis as mvs

platform_str = platform.platform()
if platform_str.endswith('arm64-arm-64bit'):
    try:
        from geopack import geopack
    except:
        msg = 'pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy'
        msg = '\n\nThis function uses a library that depends on scipy. On Mac M1, you need to install scipy using: \n\n   ' + msg + '\n'
        raise ImportError(msg)

One thing to consider is the only place scipy is used is in t96.py. There, only scipy.special is used for Bessel functions. The scipy dependency adds 40 MB to the required packages and so one may want to consider using https://libraries.io/pypi/special-functions, which is only 2 MB and has no external dependencies.

some errors in t96.py

Maybe there are some errors in t96.py?
one error with BIRK1TOT_02 fuction in t96.py, should change c2[54]=29.2043 to c2[54]=-29.2043;
one error with condip1(xi) fuction in t96.py,should change if (i == 2) | (i == 4) | (i == 6): to if (i == 2) | (i == 4) | (i == 5):

Feature Request: Evaluate models at multiple points

It would be great to have the ability to evaluate the Tsyganenko models at multiple points using vectorized processing. For example, evaluating B for every point on a grid. Some scientific use cases:

  1. Model comparison in the global perspective
  2. Evaluating the models on a grid, and then plugging the result into other code that uses gridded output

This should be possible if operations are all done in a way that supports arrays in addition to individual points. Right now, I can iterate on every point in the grid, but it's very slow to do it this way because the Python interpreter is doing a lot of unnecessary work.

inconsistent comparison results

Hi

I'm testing this python geopack package with the IDL routine.

I first tested with the parameters used in the test_geopack1.md as following:
Time/dipole tilt: 2001-01-01/02:03:04 UT/ps = -0.533585131 rad
Position: (xgsm,ygsm,zgsm) = (-5.1,0.3,2.8)
Model parameter:
T89: iopt = 2
T96, T01, and T04: par = [2., -87., 2., -5., 0., 0., ps, xgsm,ygsm,zgsm].

t89 | idl | 20.772 | -0.647 | -15.072
  | python | 20.772 | -0.647 | -15.072
t96 | idl | 61.179 | -1.461 | -40.451
  | python | 61.179 | -1.461 | -40.451
t01 | idl | 46.973 | 1.544 | -31.355
  | python | 46.354 | 1.440 | -32.000
t04 | idl | -8.080 | -1.512 | -0.722
  | python | 12.010 | -2.635 | -11.964

This result is similar to what is in test_geopack1.md except t04 for IDL routine.

I then tested for one of the MMS data, and the results are much different
datetime | 2016-01-01/12:13:20
iopt / kp | 3 / 2
(xgsm,ygsm,zgsm) = | 6.96, 0.49, -0.66
parmod | 0.976, -50.20, 6.59, -5.512, 0., 0., tilt, x,y,z

t89 | idl | -3.657066785 | 1.085712758 | 13.86057416
  | python | -2.37842015 | 1.038191716 | 14.38198039

t96 | idl | 22.97810632 | -1.106448782 | -4.147864164
  | python | 50.00624944 | 6.397909797 | -147.0215389

t01 | idl | 5.001211425 | 0.02607965332 | 3.264103442
  | python | 6.230733691 | 4.283414418 | -2.58591528

t04 | idl | -15.25291193 | -8.650237035 | -10.97633666
  | python | 7.905332371 | -1.161844446 | -7.933264503

Could you help me with it?

Thanks

geopack on conda-forge?

Would it be possible to make geopack available on conda-forge? We would like to be able to use pyspedas on heliocloud, and it's a requirement that our package and all dependencies be available in conda.

I hear it's possible to add packages to conda-forge, even if you're not the package owner -- I am willing to try adding it myself, but only if that's OK with you.

How to reference?

Do you have any preferences on how this implementation of geopack should be referenced?

Releasing new version to PyPI?

Hello!

I ran into some differences with T96 while comparing the results to IDL; to fix the problems, I updated to the GitHub release with:

pip install https://github.com/tsssss/geopack/archive/master.zip

instead of using:

pip install geopack

So I think the last T96 bug fix hasn't made it to a release on PyPI yet.

Are there plans to do a new release soon?

Thanks in advance!

Bug report on t96.py

Hello! I found that the func t96 of geopack python version has very different results with the IDL version at some places, such as dayside magnetosphere. But at other places, they get exactly the same results. I began to doubt some parts of the codes have some problems.

After long time of debugging, I found two bugs:

  1. t96.py: func r2_birk: line 1410: "r2outer" should be "r2sheet".
  2. t96.py: func birk1tot_02: line 844: "[x1,y1,z1,ps]" should be "[x2,y2,z2,ps]".

The IDL version of geopack is directly compiled from the original FORTRAN77 codes, so I think its results are correct.
I diecrtly compared the FORTRAN77 codes with the python codes, and found the two bugs above.

Geopack says it has no attribute called geogsm, igrf_geo, etc.

Hi I'm having some problems using some of the functions in geopack, for example

import geopack as gp

xgsm, ygsm, zgsm = gp.geogsm(x,y,100,1)
print(xgsm,ygsm,zgsm)

returns module 'geopack' has no attribute 'geogsm' as well as other functions such as igrf_geo similarly saying that geopack doesn't have an attribute
I used python3 -m pip install geopack to install it, is there anything else I need to install for geopack to work.

thanks in advance.

Geopack.trace not providing vector of output values

Hi,

I am trying to do a field line trace and get the points for the entire field line. However, I am only getting a single set of coordinates even though the documentation for the function says it should also output a vector of coordinates. Could you please help?

Example Code:
geopack.trace(1,0,.5, 1,10,1,2,'t89','igrf')

Output:
(0.9921003911113675, 0.00048052726154043516, 0.1254269006978363)

Thank you!

Difference in output of t96 and t01 model between IDL and Python geopacks!

Hello,
I am testing and comparing the outputs of this geopack for two different models with those of IDL and I am getting very different results.

I have attached the figures which I plotted for this purpose. For each panel in the figure I have plotted the difference between the output from IDL and Python (b_out_idl - b_out_py). Difference from T96 are plotted in the first row whereas the difference between T01 model are plotted in the second row. The value of x_gsm is at the top left position whereas the value of DST used for the code is at top right

For both T96 and T01 model far from the earth, into the tail, the difference between two outputs is minimal, almost always less than 2nT, and thus can be ignored in most cases (Figure 1, for x_gsm = 9.98 R_E).

However, there seem to be significant difference in output when we move close to the Earth or when we are on the dayside. Though the difference is smaller for T01 outputs compared to those of T96, they are still significant, specially far from the Earth on the dayside (Figure 2).

I wonder if anyone else have had similar issues.

The parameters I used for the codes are as follows:

time = 2015-01-01 00:00:00 GMT
par = [5, 0, 1, 1, 0, 0, 0, 0, 0, 0]
x_gsm = np.linspace(-15.1, 15, 61)
y_gsm = np.linspace(-15.1, 15, 61)
z_gsm = np.linspace(-15.1, 15, 61)

I can provide the full python and IDL codes if that will help with the reproduction of these differences.

Figure 1
Figure_3

Figure 2
Figure_2

Figure 3
Figure_1

T01 IDL vs Python differences

The IDL and Python outputs from the T01 model are differing by a few nanotesla for a large part of the 2007-03-23 THEMIS-A ephemeris which I'm testing with. The differences are occurring in regions with low field strength (sometimes 16x the reference field value), so I think this is more than just roundoff error.

See the attached plot: top two panels are the IDL and Python T01 field outputs; third panel is the difference, bottom panel shows the GSM positions in RE used as model inputs. The other parameters were: pdyn = 2.0, dsti = -30.0, yimf = 0.0, zimf = -5.0, g1 = 6.0, g2 = 10.0.

t01_diffs

Antiparallel tracing for geopack.trace source code error

Hi, I am trying to use the geopack.trace function to calculate the limiting field line position antiparallel to my point (dir=1). However whenever I use dir=1 I get the following error:

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-121-b09879ee0d08> in <module>
      1 parmod = [data['Pdyn'][k],data['SYMH'][k],data['BYGSM'][k],data['BZGSM'][k],data['W1'][k],data['W2'][k],data['W3'][k], \
      2           data['W4'][k],data['W5'][k],data['W6'][k]]
----> 3 a,b,c,_,_,_ = geopack.trace(xgsm,ygsm,zgsm,dir=1)
      4 a1,b1,c1 = geopack.geogsm(a,b,c,-1)
      5 print(a1,b1,c1)

~/.conda/envs/rtenv36/lib/python3.6/site-packages/geopack/geopack.py in trace(xi, yi, zi, dir, rlim, r0, parmod, exname, inname, maxloop)
   1165             # find the footpoint position by interpolating between the current and previous field line points:
   1166             r1=(r0-r)/(rr-r)
-> 1167             x=x-(x-xr)*r1
   1168             y=y-(y-yr)*r1
   1169             z=z-(z-zr)*r1

UnboundLocalError: local variable 'xr' referenced before assignment

When I look at the source code, I see that xr, yr, zr are all never defined but are referenced before their assignment. Has part of the source code been omitted?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.