OCB Gridding

OCB gridding is performed by matching observations and OCBs in Universal Time (UT) and then normalising the AACGM magnetic coordinates of the observation to OCB coordinates. This is done by determining the observation’s location relative to the current OCB and placing it in the same location relative to a typical OCB that has a magnetic latitude of 74 degrees. Data matching is performed by ocbpy.ocboundary.match_data_ocb. Coordinate normalisation, as well as OCB loading and data cycling is done within ocbpy.ocboundary.OCBoundary. These classes and functions make up the ocbpy.ocbounary module.

For observations that depend on the cross polar cap potential, it is also important to scale the magnitude. This ensures that the magnitudes from different sized polar caps compare to the typical polar cap the OCB gridding produces. For vector data, the local polar north and east components may also change. Magnitude scaling is performed by ocbpy.ocb_scaling.normal_evar or ocbpy.ocb_scaling.normal_curl_evar. Vector scaling, re-orientation, and OCB coordinate normalisation are performed within the class VectorData. These classes and functions make up the ocbpy.ocb_scaling module.

OCBoundary

Hold, manipulate, and load the open-closed field line boundary data

Functions

retrieve_all_good_indices(ocb)
Retrieve all good boundary indices
match_data_ocb(ocb, dat_dtime, kwargs)
Match data with open-closed field line boundaries

Classes

OCBoundary Loads, holds, and cycles the open-closed field line boundary data.
Calculates magnetic coordinates relative to OCB (setting OCB at 74 degrees latitude) given an AACGM location.

Moduleauthor

Angeline G. Burrell (AGB), 15 April 2017, University of Texas, Dallas

References

Chisham, G. (2017), A new methodology for the development of high-latitude
ionospheric climatologies and empirical models, Journal of Geophysical Research: Space Physics, 122, doi:10.1002/2016JA023235.
class ocbpy.ocboundary.OCBoundary(filename='default', instrument='', hemisphere=1, boundary_lat=74.0, stime=None, etime=None, rfunc=None, rfunc_kwargs=None)[source]

Object containing open-closed field-line boundary (OCB) data

Attributes:
filename : (str or NoneType)

OCBoundary filename or None, if problem loading default

boundary_lat : (float)

Typical OCBoundary latitude in AACGM coordinates. Hemisphere will give this boundary the desired sign. (default=74.0)

hemisphere : (int)

Integer (+/- 1) denoting northern/southern hemisphere (default=1)

records : (int)

Number of OCB records (default=0)

rec_ind : (int)

Current OCB record index (default=0; initialised=-1)

dtime : (numpy.ndarray or NoneType)

Numpy array of OCB datetimes (default=None)

phi_cent : (numpy.ndarray or NoneType)

Numpy array of floats that give the angle from AACGM midnight of the OCB pole in degrees (default=None)

r_cent : (numpy.ndarray or NoneType)

Numpy array of floats that give the AACGM co-latitude of the OCB pole in degrees (default=None)

r : (numpy.ndarray or NoneType)

Numpy array of floats that give the radius of the OCBoundary in degrees (default=None)

rfunc : (numpy.ndarray, function, or NoneType)

Non-circular boundaries must be specified by a boundary function that alters r at a specified AACGM MLT (in hours). To allow the boundary shape to change with time, each temporal instance may have a different function. If a single function is provided, will recast as an array that specifies this function for all times (default=None)

rfunc_kwargs : (numpy.ndarray, dict, or NoneType)

Array of optional keyword arguements for rfunc. If None is specified, uses function defaults. If dict is specified, recasts as an array of this dict for all times (default=None)

(more) : (numpy.ndarray or NoneType)

Numpy array of floats that hold the remaining values in input file

Methods

inst_defaults() Get the information needed to load an OCB file using instrument specific formatting, and update the boundary latitude for a given instrument type.
load(hlines=0, ocb_cols=’year soy num_sectors phi_cent r_cent r a r_err’, datetime_fmt=’’, stime=None, etime=None) Load the data from the OCB file specified by self.filename
get_next_good_ocb_ind(min_sectors=7, rcent_dev=8.0, max_r=23.0, min_r=10.0) Cycle to the next good OCB index
normal_coord(aacgm_lat, aacgm_mlt) Calculate the OCB coordinates of an AACGM location
revert_coord(ocb_lat, ocb_mlt) Calculate the AACGM location of OCB coordinates for this OCB
get_aacgm_boundary_lat(aacgm_mlt, rec_ind=None, overwrite=False, set_lon=True)[source]

Get the OCB latitude in AACGM coordinates at specified longitudes

Parameters:
aacgm_mlt : (int, float, or array-like)

AACGM longitude location(s) (in degrees) for which the OCB latitude will be calculated.

rec_ind : (int, array-like, or NoneType)

Record index for which the OCB AACGM latitude will be calculated, or None to calculate all boundary locations (default=None).

overwrite : (boolean)

Overwrite previous boundary locations if this time already has calculated boundary latitudes for a different set of input longitudes (default=False).

set_lon : (boolean)

Calculate the AACGM longitude of the OCB alongside the MLT (default=True).

Notes

Updates OCBoundary object with list attributes. If no boundary value is calculated at a certain time, the list is padded with None. If a boundary latitude cannot be calculated at that time and longitude, that time and longitude is filled with NaN.

aacgm_boundary_lat contains the AACGM latitude location(s) of the OCB (in degrees) for each requested time.

aacgm_boundary_mlt holds the aacgm_mlt input for each requested time. The requested MLT may differ from time to time, to allow easy comparison with satellite passes.

aacgm_boundary_lon holds the aacgm_lon input for each requested time. This is calculated from aacgm_boundary_mlt by default.

get_next_good_ocb_ind(min_sectors=7, rcent_dev=8.0, max_r=23.0, min_r=10.0)[source]

read in the next usuable OCB record from the data file. Only uses the available parameters.

Parameters:
min_sectors : (int)

Minimum number of MLT sectors required for good OCB. (default=7)

rcent_dev : (float)

Maximum number of degrees between the new centre and the AACGM pole (default=8.0)

max_r : (float)

Maximum radius for open-closed field line boundary in degrees. (default=23.0)

min_r : (float)

Minimum radius for open-closed field line boundary in degrees (default=10.0)

Notes

Updates self.rec_ind to the index of next good OCB record or a value greater than self.records if there aren’t any more good records available after the starting point

inst_defaults()[source]

Get the information needed to load an OCB file using instrument specific formatting

Returns:
hlines : (int)

Number of header lines

ocb_cols : (str)

String containing the names for each data column

datetime_fmt : (str)

String containing the datetime format

Notes

Updates the min_fom attribute for AMPERE and DMSP-SSJ

load(hlines=0, ocb_cols='year soy num_sectors phi_cent r_cent r a r_err', datetime_fmt='', stime=None, etime=None)[source]

Load the data from the specified Open-Closed Boundary file

Parameters:
ocb_cols : (str)

String specifying format of OCB file. All but the first two columns must be included in the string, additional data values will be ignored. If ‘year soy’ aren’t used, expects ‘date time’ in ‘YYYY-MM-DD HH:MM:SS’ format. (default=’year soy num_sectors phi_cent r_cent r a r_err’)

hlines : (int)

Number of header lines preceeding data in the OCB file (default=0)

datetime_fmt : (str)

A string used to read in ‘date time’ data. Not used if ‘year soy’ is specified. (default=’’)

stime : (datetime or NoneType)

Time to start loading data or None to start at beginning of file. (default=None)

etime : (datetime or NoneType)

Time to stop loading data or None to end at the end of the file. (default=None)

normal_coord(lat, lt, coords='magnetic', height=350.0, method='ALLOWTRACE')[source]

converts position(s) to normalised co-ordinates relative to the OCB

Parameters:
lat : (float or array-like)

Input latitude (degrees), must be geographic, geodetic, or AACGMV2

lt : (float or array-like)

Input local time (hours), must be solar or AACGMV2 magnetic

coords : (str)

Input coordiate system. Accepts ‘magnetic’, ‘geocentric’, or ‘geodetic’ (default=’magnetic’)

height : (float or array-like)

Height (km) at which AACGMV2 coordinates will be calculated, if geographic coordinates are provided (default=350.0)

method : (str)

String denoting which type(s) of conversion to perform, if geographic coordinates are provided. Expects either ‘TRACE’ or ‘ALLOWTRACE’. See AACGMV2 for details. (default=’ALLOWTRACE’)

Returns:
ocb_lat : (float or array-like)

Magnetic latitude relative to OCB (degrees)

ocb_mlt : (float or array-like)

Magnetic local time relative to OCB (hours)

r_corr : (float or array-like)

Radius correction to OCB (degrees)

revert_coord(ocb_lat, ocb_mlt, r_corr=0.0, coords='magnetic', height=350.0, method='ALLOWTRACE')[source]

Converts the position of a measurement in normalised co-ordinates relative to the OCB into AACGM co-ordinates

Parameters:
ocb_lat : (float or array-like)

Input OCB latitude in degrees

ocb_mlt : (float or array-like)

Input OCB local time in hours

r_corr : (float or array-like)

Input OCB radial correction in degrees, may be a function of AACGM MLT (default=0.0)

coords : (str)

Output coordiate system. Accepts ‘magnetic’, ‘geocentric’, or ‘geodetic’ (default=’magnetic’)

height : (float or array-like)

Geocentric height above sea level (km) at which AACGMV2 coordinates will be calculated, if geographic coordinates are desired (default=350.0)

method : (str)

String denoting which type(s) of conversion to perform, if geographic coordinates are provided. Expects either ‘TRACE’ or ‘ALLOWTRACE’. See AACGMV2 for details. (default=’ALLOWTRACE’)

Returns:
lat : (float or array-like)

latitude (degrees)

lt : (float or array-like)

local time (hours)

ocbpy.ocboundary.match_data_ocb(ocb, dat_dtime, idat=0, max_tol=600, min_sectors=7, rcent_dev=8.0, max_r=23.0, min_r=10.0)[source]

Matches data records with OCB records, locating the closest values within a specified tolerance

Parameters:
ocb : (OCBoundary)

Class containing the open-close field line boundary data

dat_dtime : (list or numpy array of datetime objects)

Times where data exists

idat : (int)

Current data index (default=0)

max_tol : (int)

maximum seconds between OCB and data record in sec (default=600)

min_sectors : (int)

Minimum number of MLT sectors required for good OCB. (default=7)

rcent_dev : (float)

Maximum number of degrees between the new centre and the AACGM pole (default=8.0)

max_r : (float)

Maximum radius for open-closed field line boundary in degrees (default=23.0)

min_r : (float)

Minimum radius for open-closed field line boundary in degrees (default=10.0)

Returns:
idat : (int or NoneType)

Data index for match value, None if all of the data have been searched

Notes

Updates OCBoundary.rec_ind for matched value. None if all of the boundaries have been searched.

ocbpy.ocboundary.retrieve_all_good_indices(ocb)[source]

Retrieve all good indices from the ocb structure

Parameters:
ocb : (OCBoundary)

Class containing the open-close field line boundary data

Returns:
good_ind : (list)

List of indices containing good OCBs

OCB Scaling

Scale data affected by magnetic field direction or electric field

Routines

normal_evar(evar, unscaled_r, scaled_r)
Normalise a variable proportaional to the electric field (such as velocity)
normal_curl_evar(curl_evar, unscaled_r, scaled_r)
Normalise a variable proportional to the curl of the electric field (such as vorticity)

Classes

VectorData(object)
Holds vector data in AACGM N-E-Z coordinates along with location information. Converts vector from AACGM to OCB coordinates.

Moduleauthor

Angeline G. Burrell (AGB), 12 May 2017, University of Texas, Dallas

References

Chisham, G. (2017), A new methodology for the development of high-latitude ionospheric climatologies and empirical models, Journal of Geophysical Research: Space Physics, 122, doi:10.1002/2016JA023235.

class ocbpy.ocb_scaling.VectorData(dat_ind, ocb_ind, aacgm_lat, aacgm_mlt, ocb_lat=nan, ocb_mlt=nan, r_corr=nan, aacgm_n=0.0, aacgm_e=0.0, aacgm_z=0.0, aacgm_mag=nan, dat_name=None, dat_units=None, scale_func=None)[source]

Object containing a vector data point

Parameters:
dat_ind : (int or array-like)

Data index (zero offset)

ocb_ind : (int or array-like)

OCBoundary record index matched to this data index (zero offset)

aacgm_lat : (float or array-like)

Vector AACGM latitude (degrees)

aacgm_mlt : (float or array-like)

Vector AACGM MLT (hours)

ocb_lat : (float or array-like)

Vector OCB latitude (degrees) (default=np.nan)

ocb_mlt : (float or array-like)

Vector OCB MLT (hours) (default=np.nan)

aacgm_n : (float or array-like)

AACGM North pointing vector (positive towards North) (default=0.0)

aacgm_e : (float or array-like)

AACGM East pointing vector (completes right-handed coordinate system (default = 0.0)

aacgm_z : (float or array-like)

AACGM Vertical pointing vector (positive down) (default=0.0)

aacgm_mag : (float or array-like)

Vector magnitude (default=np.nan)

scale_func : (function)

Function for scaling AACGM magnitude with arguements: [measurement value, mesurement AACGM latitude (degrees), mesurement OCB latitude (degrees)] (default=None)

dat_name : (str)

Data name (default=None)

dat_units : (str)

Data units (default=None)

Notes

May only handle one data type, so scale_func cannot be an array

Attributes:
dat_name : (str or NoneType)

Name of data

dat_units : (str or NoneType)

Units of data

dat_ind : (int or array-like)

Vector data index in external data array

ocb_ind : (int or array-like)

OCBoundary rec_ind value(s) that matches dat_ind or a single rec_ind value for all dat_ind

unscaled_r : (float or array-like)

Radius of polar cap in degrees

scaled_r : (float or array-like)

Radius of normalised OCB polar cap in degrees

aacgm_n : (float or array-like)

AACGM north component of data vector (default=0.0)

aacgm_e : (float or array-like)

AACGM east component of data vector (default=0.0)

aacgm_z : (float or array-like)

AACGM vertical component of data vector (default=0.0)

aacgm_mag : (float or array-like)

Magnitude of data vector in AACGM coordinates (default=np.nan)

aacgm_lat : (float or array-like)

AACGM latitude of data vector in degrees

aacgm_mlt : (float or array-like)

AACGM MLT of data vector in hours

ocb_n : (float or array-like)

OCB north component of data vector (default=np.nan)

ocb_e : (float or array-like)

OCB east component of data vector (default=np.nan)

ocb_z : (float or array-like)

OCB vertical component of data vector (default=np.nan)

ocb_mag : (float or array-like)

OCB magnitude of data vector (default=np.nan)

ocb_lat : (float or array-like)

OCB latitude of data vector in degrees (default=np.nan)

ocb_mlt : (float or array-like)

OCB MLT of data vector in hours (default=np.nan)

ocb_quad : (int or array-like)

AACGM quadrant of OCB pole (default=0)

vec_quad : (int or array-like)

AACGM quadrant of Vector (default=0)

pole_angle : (float or array-like)

Angle at vector location appended by AACGM and OCB poles in degrees (default=np.nan)

aacgm_naz : (float or array-like)

AACGM north azimuth of data vector in degrees (default=np.nan)

ocb_aacgm_lat : (float or array-like)

AACGM latitude of OCB pole in degrees (default=np.nan)

ocb_aacgm_mlt : (float or array-like)

AACGM MLT of OCB pole in hours (default=np.nan)

scale_func : (function or NoneType)

Funciton that scales the magnitude of the data vector from AACGM polar cap coverage to OCB polar cap coverage

Methods

set_ocb(ocb, scale_func=None) Set the ocb coordinates and vector values
calc_ocb_polar_angle()[source]

Calculate the OCB north azimuth angle

Returns:
ocb_naz : (float or array-like)

Angle between measurement vector and OCB pole in degrees

Raises:
ValueError

If the required input is undefined

calc_ocb_vec_sign(north=False, east=False, quads={})[source]

Get the sign of the North and East components

Parameters:
north : (boolean)

Get the sign of the north component(s) (default=False)

east : (boolean)

Get the sign of the east component(s) (default=False)

quads : (dictionary)

Dictionary of boolean values or arrays of boolean values for OCB and Vector quadrants. (default=dict())

Returns:
vsigns : (dict)

Dictionary with keys ‘north’ and ‘east’ containing the desired signs

Raises:
ValueError

If the required input is undefined

calc_vec_pole_angle()[source]

Calculate the angle between the AACGM pole, a measurement, and the OCB pole using spherical triginometry

Raises:
ValueError

If the input is undefined or inappropriately sized arrays

define_quadrants()[source]

Find the MLT quadrants (in AACGM coordinates) for the OCB pole and data vector

Raises:
ValueError

If the required input is undefined

Notes

North (N) and East (E) are defined by the AACGM directions centred on the data vector location, assuming vertical is positive downwards Quadrants: 1 [N, E]; 2 [N, W]; 3 [S, W]; 4 [S, E]

scale_vector()[source]

Normalise a variable proportional to the curl of the electric field.

Raises:
ValueError

If the required input is not defined

set_ocb(ocb, scale_func=None)[source]

Set the OCBoundary values for this data point

Parameters:
ocb : (OCBoundary)

Open Closed Boundary class object

scale_func : (function)

Function for scaling AACGM magnitude with arguements: [measurement value, mesurement AACGM latitude (degrees), mesurement OCB latitude (degrees)] Not necessary if defined earlier or no scaling is needed. (default=None)

ocbpy.ocb_scaling.archav(hav)[source]

Formula for the inverse haversine

Parameters:
hav : (float or array-like)

Haversine of an angle

Returns:
alpha : (float or array-like)

Angle in radians

Notes

The input must be positive. However, any number with a magnitude below 10-16 will be rounded to zero. More negative numbers will return NaN.

ocbpy.ocb_scaling.hav(alpha)[source]

Formula for haversine

Parameters:
alpha : (float or array-like)

Angle in radians

Returns:
hav_alpha : (float or array-like)

Haversine of alpha, equal to the square of the sine of half-alpha

ocbpy.ocb_scaling.normal_curl_evar(curl_evar, unscaled_r, scaled_r)[source]

Normalise a variable proportional to the curl of the electric field

Parameters:
curl_evar : (float or array)

Variable related to electric field (e.g. vorticity)

unscaled_r : (float or array)

Radius of polar cap in degrees

scaled_r : (float or array)

Radius of normalised OCB polar cap in degrees

Returns:
nvar : (float or array)

Normalised variable

Notes

Assumes that the cross polar cap potential is fixed across the polar cap regardless of the radius of the Open Closed field line Boundary. This is commonly assumed when looking at statistical patterns that control the IMF (which accounts for dayside reconnection) and assume that the nightside reconnection influence is averaged out over the averaged period.

References

Chisham, G. (2017), A new methodology for the development of high‐latitude ionospheric climatologies and empirical models, Journal of Geophysical Research: Space Physics, doi:10.1002/2016JA023235.

ocbpy.ocb_scaling.normal_evar(evar, unscaled_r, scaled_r)[source]

Normalise a variable proportional to the electric field

Parameters:
evar : (float or array)

Variable related to electric field (e.g. velocity)

unscaled_r : (float or array)

Radius of polar cap in degrees

scaled_r : (float or array)

Radius of normalised OCB polar cap in degrees

Returns:
nvar : (float or array)

Normalised variable

Notes

Assumes that the cross polar cap potential is fixed across the polar cap regardless of the radius of the Open Closed field line Boundary. This is commonly assumed when looking at statistical patterns that control the IMF (which accounts for dayside reconnection) and assume that the nightside reconnection influence is averaged out over the averaged period.

References

Chisham, G. (2017), A new methodology for the development of high‐latitude ionospheric climatologies and empirical models, Journal of Geophysical Research: Space Physics, doi:10.1002/2016JA023235.