def do_mag_map(date, lon_0=0, alt=0, file="", mod="cals10k",resolution='low'):
    """
    returns lists of declination, inclination and intensities for lat/lon grid for
    desired model and date.

    Parameters:
    _________________
    date = Required date in decimal years (Common Era, negative for Before Common Era)

    Optional Parameters:
    ______________
    mod  = model to use ('arch3k','cals3k','pfm9k','hfm10k','cals10k.2','shadif14k','cals10k.1b','custom')
    file = l m g h formatted filefor custom model
    lon_0 : central longitude for Hammer projection
    alt  = altitude
    resolution = ['low','high'] default is low

    Returns:
    ______________
    Bdec=list of declinations
    Binc=list of inclinations
    B = list of total field intensities in nT
    Br = list of radial field intensities
    lons = list of longitudes evaluated
    lats = list of latitudes evaluated

    """
    if resolution=='low':
        incr = 10  # we can vary to the resolution of the model
    elif resolution=='high':
        incr = 2  # we can vary to the resolution of the model
    if lon_0 == 180:
        lon_0 = 179.99
    if lon_0 > 180:
        lon_0 = lon_0-360.
    # get some parameters for our arrays of lat/lon
    lonmax = (lon_0 + 180.) % 360 + incr
    lonmin = (lon_0 - 180.)
    latmax = 90 + incr
    # make a 1D array of longitudes (like elons)
    lons = np.arange(lonmin, lonmax, incr)
    # make a 1D array of longitudes (like elats)
    lats = np.arange(-90, latmax, incr)
    # set up some containers for the field elements
    B = np.zeros((len(lats), len(lons)))
    Binc = np.zeros((len(lats), len(lons)))
    Bdec = np.zeros((len(lats), len(lons)))
    Brad = np.zeros((len(lats), len(lons)))
    if mod == 'custom' and file != '':
        gh = []
        lmgh = np.loadtxt(file).transpose()
        gh.append(lmgh[2][0])
        for i in range(1, lmgh.shape[1]):
            gh.append(lmgh[2][i])
            if lmgh[1][i] != 0:
                gh.append(lmgh[3][i])
    for j in range(len(lats)):  # step through the latitudes
        for i in range(len(lons)):  # and the longitudes
            # get the field elements
            if mod == 'custom':
                x, y, z, f = docustom(lons[i], lats[j], alt, gh)
            else:
                x, y, z, f = doigrf(
                    lons[i], lats[j], alt, date, mod=mod, file=file)
            # turn them into polar coordinates
            Dec, Inc, Int = cart2dir([x, y, z])
            if mod != 'custom':
                # convert the string to microtesla (from nT)
                B[j][i] = Int * 1e-3
            else:
                B[j][i] = Int  # convert the string to microtesla (from nT)
            Binc[j][i] = Inc  # store the inclination value
            if Dec > 180:
                Dec = Dec-360.
            Bdec[j][i] = Dec  # store the declination value
            if mod != 'custom':
                Brad[j][i] = z*1e-3
            else:
                Brad[j][i] = z
    return Bdec, Binc, B, Brad, lons, lats
def do_mag_map ( date , lon_0 = 0 , alt = 0 , file = "" , mod = "cals10k" , resolution = 'low' ) : if resolution == 'low' : incr = 10 elif resolution == 'high' : incr = 2 if lon_0 == 180 : lon_0 = 179.99 if lon_0 > 180 : lon_0 = lon_0 - 360. lonmax = ( lon_0 + 180. ) % 360 + incr lonmin = ( lon_0 - 180. ) latmax = 90 + incr lons = np . arange ( lonmin , lonmax , incr ) lats = np . arange ( - 90 , latmax , incr ) B = np . zeros ( ( len ( lats ) , len ( lons ) ) ) Binc = np . zeros ( ( len ( lats ) , len ( lons ) ) ) Bdec = np . zeros ( ( len ( lats ) , len ( lons ) ) ) Brad = np . zeros ( ( len ( lats ) , len ( lons ) ) ) if mod == 'custom' and file != '' : gh = [ ] lmgh = np . loadtxt ( file ) . transpose ( ) gh . append ( lmgh [ 2 ] [ 0 ] ) for i in range ( 1 , lmgh . shape [ 1 ] ) : gh . append ( lmgh [ 2 ] [ i ] ) if lmgh [ 1 ] [ i ] != 0 : gh . append ( lmgh [ 3 ] [ i ] ) for j in range ( len ( lats ) ) : for i in range ( len ( lons ) ) : if mod == 'custom' : x , y , z , f = docustom ( lons [ i ] , lats [ j ] , alt , gh ) else : x , y , z , f = doigrf ( lons [ i ] , lats [ j ] , alt , date , mod = mod , file = file ) Dec , Inc , Int = cart2dir ( [ x , y , z ] ) if mod != 'custom' : B [ j ] [ i ] = Int * 1e-3 else : B [ j ] [ i ] = Int Binc [ j ] [ i ] = Inc if Dec > 180 : Dec = Dec - 360. Bdec [ j ] [ i ] = Dec if mod != 'custom' : Brad [ j ] [ i ] = z * 1e-3 else : Brad [ j ] [ i ] = z return Bdec , Binc , B , Brad , lons , lats
returns lists of declination, inclination and intensities for lat/lon grid for
    desired model and date.

    Parameters:
    _________________
    date = Required date in decimal years (Common Era, negative for Before Common Era)

    Optional Parameters:
    ______________
    mod  = model to use ('arch3k','cals3k','pfm9k','hfm10k','cals10k.2','shadif14k','cals10k.1b','custom')
    file = l m g h formatted filefor custom model
    lon_0 : central longitude for Hammer projection
    alt  = altitude
    resolution = ['low','high'] default is low

    Returns:
    ______________
    Bdec=list of declinations
    Binc=list of inclinations
    B = list of total field intensities in nT
    Br = list of radial field intensities
    lons = list of longitudes evaluated
    lats = list of latitudes evaluated