Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

seaduck.utils

NoneIn

NoneIn(lst)

See if there is a None in the iterable object. Return a Boolean.


chg_ref_lon

chg_ref_lon(x, ref_lon)

Change the definition of 0 longitude.

Return how much east one need to go from ref_lon to x This function aims to address the confusion caused by the discontinuity in longitude.


convert_time

convert_time(time)

Convert time into seconds after 1970-01-01.

time needs to be a string or a np.datetime64 object.


create_tree

create_tree(x, y, R=6371.0, leafsize=16)

Create a cKD tree object.

Parameters


easy_3d_cube

easy_3d_cube(lon, lat, dep, tim, print_total_number=False)

Create 4D coords for initializing Position/Particle.


find_cs_sn

find_cs_sn(thetaA, phiA, thetaB, phiB)

Find a spherical angle OAB.

theta is the angle between the meridian crossing point A and the geodesic connecting A and B.

this function return cos and sin of theta


find_ind

find_ind(array, value, peri=None, ascending=1, above=True)

Find the index of the nearest value to the given value.

Parameters


find_ind_h

find_ind_h(lons, lats, tree, h_shape)

Use ckd tree to find the horizontal indexes,.


find_px_py

find_px_py(XG, YG, tp, ind, cuvwg='G')

Find the nearest 4 corner points.

This is used in oceanparcel interpolation scheme.


find_rel

find_rel(value, array, darray=None, ascending=1, above=True, peri=None, dx_right=True)

Find the rel-coords of the 1D coords.

The backend for all find_rel functions

Parameters

Returns


find_rel_h_naive

find_rel_h_naive(lon, lat, some_x, some_y, some_dx, some_dy, CS, SN, tree)

Find the rel-coords in the horizontal.

very similar to find_rel_time/v rx,ry,dx,dy are defined the same way for example rx = “how much to the right of the node”/“size of the cell in left-right direction” dx = “size of the cell in left-right direction”.

cs,sn is just the cos and sin of the grid orientation. It will come in handy when we transfer vectors.


find_rel_h_oceanparcel

find_rel_h_oceanparcel(x, y, some_x, some_y, some_dx, some_dy, CS, SN, XG, YG, tree, tp)

Find the rel-coords using the rectilinear scheme.


find_rel_h_rectilinear

find_rel_h_rectilinear(x, y, lon, lat)

Find the rel-coords using the rectilinear scheme.


find_rel_nearest

find_rel_nearest(value, ts)

Find the rel-coords based on the find_ind_nearest method.


find_rel_periodic

find_rel_periodic(value, ts, peri)

Find the rel-coords based on the find_ind_periodic method.


find_rel_time

find_rel_time(time, ts)

Find the rel-coords of the temporal coords.

Parameters

Returns


find_rel_z

find_rel_z(depth, some_z, some_dz=None, dz_above_z=True)

Find the rel-coords of the vertical coords.

Parameters

Returns


find_rx_ry_naive

find_rx_ry_naive(x, y, bx, by, cs, sn, dx, dy)

Find the non-dimensional coords using the local cartesian scheme.


find_rx_ry_oceanparcel

find_rx_ry_oceanparcel(x, y, px, py)

Find the non-dimensional horizontal distance.

This is done using the oceanparcel scheme.


get_key_by_value

get_key_by_value(d, value)

Find one of the keys in a dictionary.

the key that correspond to the given value.

Parameters


local_to_latlon

local_to_latlon(u, v, cs, sn)

Convert local vector to north-east.


missing_cs_sn

missing_cs_sn(ds, return_xr=False)

Fill in the CS,SN of a dataset.


parallelpointinpolygon

parallelpointinpolygon(xs, ys, poly)

Check if xs,ys is in the polygon, return same size boolean array.

Parameters


pointinpolygon

pointinpolygon(x, y, poly)

Check if x,y is in the polygon.


process_ecco

process_ecco(ds)

Add more meat to ECCO dataset after the skeleton is downloaded.


rel2latlon

rel2latlon(rx, ry, cs, sn, dx, dy, bx, by)

Translate the spatial rel-coords into lat-lon-dep coords.


spherical2cartesian

spherical2cartesian(lat, lon, R=6371.0)

Convert spherical coordinates to cartesian.

Parameters

Returns


to_180

to_180(x, peri=360)

Convert any longitude scale to [-180,180).


weight_f_node

weight_f_node(rx, ry)

Assign weights to four corners.

assign weight based on the non-dimensional coords to the four corner points.