graspfile.grid¶
This is the module for manipulating grid files containing one or more field cuts from TICRA Tools, GRASP and CHAMP
Classes
GraspField() |
Object holding a single dataset from a Grasp field on grid output file (*.grd) |
GraspGrid() |
Object holding the data in contained in a general Grasp grid field output |
-
class
graspfile.grid.GraspField[source]¶ Bases:
objectObject holding a single dataset from a Grasp field on grid output file (
*.grd)The field is held in a complex numpy array of shape
(grid_n_x, grid_n_y, field_components)wheregrid_n_xandgrid_n_yset the number of points in the grid andfield_componentsis the number of field components-
beam_center= None¶ Beam center in [x,y] form
Type: list
-
field= None¶ the array of complex field components. the field object is numpy array of shape
(grid_n_x, grid_n_y, field_components)Type: numpy.ndarray
-
field_components= None¶ Number of field components in grid.
Equivalent to the GRASP Grid file’s
ncomp.2for far fields,3for near fields.
-
get_value(xv, yv)[source]¶ Return the value of the field at the nearest point to xv, yv
Parameters: - xv – float containing the x coordinate of the point to get.
- yv – float containing the y coordinate of the point to get.
Returns: ndarray – containing self.field_components values of the field at xv, yv
-
grid_max_x= None¶ Maximum extent of grid in 1st dimension
Type: float
-
grid_max_y= None¶ Maximum extent of grid in 2nd dimension
Type: float
-
grid_min_x= None¶ Minimum extent of grid in 1st dimension
Type: float
-
grid_min_y= None¶ Minimum extent of grid in 2nd dimension
Type: float
-
grid_n_x= None¶ Number of points in grid in 1st dimension
Type: int
-
grid_n_y= None¶ Number of points in grid in 2nd dimension
Type: int
-
grid_step_x= None¶ step size of grid in 1st dimension
Type: float
-
grid_step_y= None¶ step size of grid in 2nd dimension
Type: float
-
index_radial_dist(i, j)[source]¶ Return radial distance from the beam center to an element of the field.
Useful for calculating the integrated power in a beam within a certain radius.
-
k_limit= None¶ defines whether grid is filled or sparse * 0: filled * 1: sparse
Type: int
-
positions¶ Return meshed grids of the x and y positions of each point in the field
-
positions_1d¶ Return numpy arrays of the x and y positions used in the field
-
radius_grid(center=None)[source]¶ Return an array holding the radii of each point from the beam centre.
Parameters: center – tuple holding coordinates of the center to calculate the radius from Returns: numpy.ndarray – numpy array with same shape as the field grid holding the radii.
-
read(fi, field_components)[source]¶ Reads the Grasp dataset from the file object passed in. This assumes that it is being called from the graspGrid classes read(fi) method, so that the file object is already at the start of the record
-
rotate_polarization(angle=45.0)[source]¶ Rotate the basis of the polarization by <angle>. Will only work on linear polarization types
*TODO: Implement checks for polarization type*
Parameters: angle – angle in degrees to rotate the polarization basis by. Returns: nothing.
-
-
class
graspfile.grid.GraspGrid[source]¶ Bases:
objectObject holding the data in contained in a general Grasp grid field output
Create empty variables or lists of attributes for holding data for each dataset
-
beam_centers= None¶ list of beam centers for individual fields in the file.
Type: list
-
combine_fields(coherent=False, scale=True)[source]¶ Sum fields within the grid object.
Assumes that all fields have the same positions, size, etc.
Parameters: - coherent (bool) – If True, add complex values of fields directly, rather than adding powers.
- scale (bool) – Scale the output by the number of fields to be added, so that a mean field is calculated. Scales by number of fields for coherent summation and by sqrt(number of fields) for incoherent summation.
-
field_components= None¶ number of field components.
Equivalent to the GRASP Grid file’s
ncomp.2for far fields,3for near fields.Type: int
-
fields= None¶ List of individual fields in file,
Type: list of ( GraspField)
-
freq_unit= None¶ The unit that the frequencies are given in.
Type: str
-
freqs= None¶ List of frequencies in units of
freq_unitType: list
-
header= None¶ List of lines in the header section of the file
Type: list of str
-
igrid= None¶ grid type.
Type of field grid. * 1 : uv-grid: (X; Y ) = (u; v) where u and v are the two first coordinates of the unit vector to the field
point. Hence, r^ = u; v; p = √(1 − u² − v²) where u and v are related to the spherical angles by u = sin θ cos φ; v = sin θ sin φ.- 4 : Elevation over azimuth: (X; Y )=(Az,El), where Az and El define the direction to the field point by
- r^ = − sin Az cos El; sin El; cos Az cos El.
- 5 : Elevation and azimuth: (X; Y )=(Az,El), where Az and El define the direction to the field point through
- the relations Az = -θ cos φ; El = θ sin φ to the spherical angles θ and φ.
- 6 : Azimuth over elevation: (X; Y )= (Az, El), where Az and El define the direction to the field point by
- r^ = − sin Az; cos Az sin El; cos Az cos El.
- 7 : θφ-grid: (X; Y ) = (φ; θ), where θ and φ are the spherical angles of the direction to the field point.
- 9 : Azimuth over elevation, EDX definition: (X; Y )=(Az,El), where Az and El define the direction to the
- field point by r^ = sin Az cos El; sin El; cos Az cos El.
- 10 : Elevation over azimuth, EDX definition: (X; Y )= (Az, El), where Az and El define the direction to the
- field point by r^ = sin Az; cos Az sin El; cos Az cos El.
Type: int
-
ktype= None¶ type of file format.
Always
1for TICRA Tools files.Type: int
-
nset= None¶ number of grids in file.
Type: int
-
parse_header(header)[source]¶ Parse the header of a grid file for useful information
Parameters: header – list of lines in the header text.
-
polarization= None¶ type of field components.
Equivalent to the GRASP Grid file’s
icomp.- Values signify the following polarization definitions
- 1: Linear E_theta and E_phi.
- 2: Right hand and left hand circular (Erhc and Elhc).
- 3: Linear Eco and Ecx (Ludwig’s third definition).
- 4: Linear along major and minor axes of the polarisation ellipse, Emaj and Emin.
- 5: XPD fields: E_theta/E_phi and E_phi/E_theta.
- 6: XPD fields: Erhc/Elhc and Elhc/Erhc.
- 7: XPD fields: Eco/Ecx and Ecx/Eco.
- 8: XPD fields: Emaj/Emin and Emin/Emaj.
- 9: Total power |E| and Erhc=Elhc.
Type: int
-
read(fi)[source]¶ Reads GRASP output grid files from file object and fills a number of variables and numpy arrays with the data
-
rotate_polarization(angle=45.0)[source]¶ Rotate the polarization basis for each field in the GraspGrid
-