Location functions¶
Some generally helpful location control functions for base QC.
- marine_qc.location_control.fill_missing_vals(q11, q12, q21, q22)[source]
Fill missing values.
For a group of four neighbouring grid boxes which form a square, with values q11, q12, q21, q22, fill gaps using means of neighbours.
- marine_qc.location_control.filler(value_to_fill, neighbour1, neighbour2, opposite)[source]
Fill invalid values.
If the value_to_fill is invalid it is replaced with the mean of the neighbours and if it is still invalid then it is replaced with the value from the opposite member.
- marine_qc.location_control.get_four_surrounding_points(lat, lon, res, max90=True)[source]
Get the four surrounding points of a specified latitude and longitude point.
- Parameters:
- Return type:
- Returns:
tupleoffloats– A tuple of floats representing the longitudes of the leftmost and rightmost pairs of points, and the latitudes of the topmost and bottommost pairs of points.
- marine_qc.location_control.lat_to_yindex(lat, res)[source]
For a given latitude return the y index in a 1x1x5-day global grid.
- Parameters:
- Return type:
- Returns:
int– Grid box index.
Notes
The routine assumes that the structure of the SST array is a grid that is 360 x 180 x 73 i.e. one year of 1degree lat x 1degree lon data split up into pentads. The west-most box is at 180degrees with index 0 and the northernmost box also has index zero. Inputs on the border between grid cells are pushed south.
In previous versions,
reshad the default value 1.0.
- marine_qc.location_control.lon_to_xindex(lon, res)[source]
For a given longitude return the x index in a 1x1x5-day global grid.
- Parameters:
- Return type:
- Returns:
int– Grid box index.
Notes
The routine assumes that the structure of the SST array is a grid that is 360 x 180 x 73 i.e. one year of 1degree lat x 1degree lon data split up into pentads. The west-most box is at 180degrees W with index 0 and the northernmost box also has index zero. Inputs on the border between grid cells are pushed east.
In previous versions,
reshad the default value 1.0.
- marine_qc.location_control.mds_lat_to_yindex(lat, res)[source]
For a given latitude return the y-index as it was in MDS2/3 in a 1x1 global grid.
- Parameters:
- Return type:
- Returns:
int– Grid box index.
Notes
In the northern hemisphere, borderline latitudes which fall on grid boundaries are pushed north, except 90 which goes south. In the southern hemisphere, they are pushed south, except -90 which goes north. At 0 degrees they are pushed south.
Expects that latitudes run from 90N to 90S
In previous versions,
reshad the default value 1.0.
- marine_qc.location_control.mds_lat_to_yindex_fast(lat, res)[source]
For a given latitude return the y-index as it was in MDS2/3 in a 1x1 global grid.
- Parameters:
lat (
np.ndarray) – Latitude(s) of observation in degrees.res (
float) – Resolution of grid in degrees.
- Return type:
- Returns:
np.ndarray– Grid box indexes.
Notes
In the northern hemisphere, borderline latitudes which fall on grid boundaries are pushed north, except 90 which goes south. In the southern hemisphere, they are pushed south, except -90 which goes north. At 0 degrees they are pushed south.
Expects that latitudes run from 90N to 90S
In previous versions,
reshad the default value 1.0.
- marine_qc.location_control.mds_lon_to_xindex(lon, res)[source]
For a given longitude return the x-index as it was in MDS2/3 in a 1x1 global grid.
- Parameters:
- Return type:
- Returns:
int– Grid box index.
Notes
In the western hemisphere, borderline longitudes which fall on grid boundaries are pushed west, except -180 which goes east. In the eastern hemisphere, they are pushed east, except 180 which goes west. At 0 degrees they are pushed west.
In previous versions,
reshad the default value 1.0.
- marine_qc.location_control.mds_lon_to_xindex_fast(lon, res)[source]
For a given longitude return the x-index as it was in MDS2/3 in a 1x1 global grid.
- Parameters:
lon (
np.ndarray) – Longitude(s) of observation in degrees.res (
float) – Resolution of grid in degrees.
- Return type:
- Returns:
np.ndarray– Grid box indexes.
Notes
In the western hemisphere, borderline longitudes which fall on grid boundaries are pushed west, except -180 which goes east. In the eastern hemisphere, they are pushed east, except 180 which goes west. At 0 degrees they are pushed west.
In previous versions,
reshad the default value 1.0.