id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
7,600
mmp2/megaman
megaman/datasets/datasets.py
generate_megaman_data
def generate_megaman_data(sampling=2): """Generate 2D point data of the megaman image""" data = get_megaman_image() x = np.arange(sampling * data.shape[1]) / float(sampling) y = np.arange(sampling * data.shape[0]) / float(sampling) X, Y = map(np.ravel, np.meshgrid(x, y)) C = data[np.floor(Y.max(...
python
def generate_megaman_data(sampling=2): """Generate 2D point data of the megaman image""" data = get_megaman_image() x = np.arange(sampling * data.shape[1]) / float(sampling) y = np.arange(sampling * data.shape[0]) / float(sampling) X, Y = map(np.ravel, np.meshgrid(x, y)) C = data[np.floor(Y.max(...
[ "def", "generate_megaman_data", "(", "sampling", "=", "2", ")", ":", "data", "=", "get_megaman_image", "(", ")", "x", "=", "np", ".", "arange", "(", "sampling", "*", "data", ".", "shape", "[", "1", "]", ")", "/", "float", "(", "sampling", ")", "y", ...
Generate 2D point data of the megaman image
[ "Generate", "2D", "point", "data", "of", "the", "megaman", "image" ]
faccaf267aad0a8b18ec8a705735fd9dd838ca1e
https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/datasets/datasets.py#L21-L29
7,601
mmp2/megaman
megaman/datasets/datasets.py
_make_S_curve
def _make_S_curve(x, range=(-0.75, 0.75)): """Make a 2D S-curve from a 1D vector""" assert x.ndim == 1 x = x - x.min() theta = 2 * np.pi * (range[0] + (range[1] - range[0]) * x / x.max()) X = np.empty((x.shape[0], 2), dtype=float) X[:, 0] = np.sign(theta) * (1 - np.cos(theta)) X[:, 1] = np.s...
python
def _make_S_curve(x, range=(-0.75, 0.75)): """Make a 2D S-curve from a 1D vector""" assert x.ndim == 1 x = x - x.min() theta = 2 * np.pi * (range[0] + (range[1] - range[0]) * x / x.max()) X = np.empty((x.shape[0], 2), dtype=float) X[:, 0] = np.sign(theta) * (1 - np.cos(theta)) X[:, 1] = np.s...
[ "def", "_make_S_curve", "(", "x", ",", "range", "=", "(", "-", "0.75", ",", "0.75", ")", ")", ":", "assert", "x", ".", "ndim", "==", "1", "x", "=", "x", "-", "x", ".", "min", "(", ")", "theta", "=", "2", "*", "np", ".", "pi", "*", "(", "r...
Make a 2D S-curve from a 1D vector
[ "Make", "a", "2D", "S", "-", "curve", "from", "a", "1D", "vector" ]
faccaf267aad0a8b18ec8a705735fd9dd838ca1e
https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/datasets/datasets.py#L32-L41
7,602
mmp2/megaman
megaman/datasets/datasets.py
generate_megaman_manifold
def generate_megaman_manifold(sampling=2, nfolds=2, rotate=True, random_state=None): """Generate a manifold of the megaman data""" X, c = generate_megaman_data(sampling) for i in range(nfolds): X = np.hstack([_make_S_curve(x) for x in X.T]) if rotate: rand ...
python
def generate_megaman_manifold(sampling=2, nfolds=2, rotate=True, random_state=None): """Generate a manifold of the megaman data""" X, c = generate_megaman_data(sampling) for i in range(nfolds): X = np.hstack([_make_S_curve(x) for x in X.T]) if rotate: rand ...
[ "def", "generate_megaman_manifold", "(", "sampling", "=", "2", ",", "nfolds", "=", "2", ",", "rotate", "=", "True", ",", "random_state", "=", "None", ")", ":", "X", ",", "c", "=", "generate_megaman_data", "(", "sampling", ")", "for", "i", "in", "range", ...
Generate a manifold of the megaman data
[ "Generate", "a", "manifold", "of", "the", "megaman", "data" ]
faccaf267aad0a8b18ec8a705735fd9dd838ca1e
https://github.com/mmp2/megaman/blob/faccaf267aad0a8b18ec8a705735fd9dd838ca1e/megaman/datasets/datasets.py#L44-L57
7,603
presslabs/z3
z3/ssh_sync.py
snapshots_to_send
def snapshots_to_send(source_snaps, dest_snaps): """return pair of snapshots""" if len(source_snaps) == 0: raise AssertionError("No snapshots exist locally!") if len(dest_snaps) == 0: # nothing on the remote side, send everything return None, source_snaps[-1] last_remote = dest_s...
python
def snapshots_to_send(source_snaps, dest_snaps): """return pair of snapshots""" if len(source_snaps) == 0: raise AssertionError("No snapshots exist locally!") if len(dest_snaps) == 0: # nothing on the remote side, send everything return None, source_snaps[-1] last_remote = dest_s...
[ "def", "snapshots_to_send", "(", "source_snaps", ",", "dest_snaps", ")", ":", "if", "len", "(", "source_snaps", ")", "==", "0", ":", "raise", "AssertionError", "(", "\"No snapshots exist locally!\"", ")", "if", "len", "(", "dest_snaps", ")", "==", "0", ":", ...
return pair of snapshots
[ "return", "pair", "of", "snapshots" ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/ssh_sync.py#L25-L38
7,604
presslabs/z3
z3/pput.py
StreamHandler.get_chunk
def get_chunk(self): """Return complete chunks or None if EOF reached""" while not self._eof_reached: read = self.input_stream.read(self.chunk_size - len(self._partial_chunk)) if len(read) == 0: self._eof_reached = True self._partial_chunk += read ...
python
def get_chunk(self): """Return complete chunks or None if EOF reached""" while not self._eof_reached: read = self.input_stream.read(self.chunk_size - len(self._partial_chunk)) if len(read) == 0: self._eof_reached = True self._partial_chunk += read ...
[ "def", "get_chunk", "(", "self", ")", ":", "while", "not", "self", ".", "_eof_reached", ":", "read", "=", "self", ".", "input_stream", ".", "read", "(", "self", ".", "chunk_size", "-", "len", "(", "self", ".", "_partial_chunk", ")", ")", "if", "len", ...
Return complete chunks or None if EOF reached
[ "Return", "complete", "chunks", "or", "None", "if", "EOF", "reached" ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/pput.py#L76-L86
7,605
presslabs/z3
z3/pput.py
UploadSupervisor._handle_result
def _handle_result(self): """Process one result. Block untill one is available """ result = self.inbox.get() if result.success: if self._verbosity >= VERB_PROGRESS: sys.stderr.write("\nuploaded chunk {} \n".format(result.index)) self.results.append...
python
def _handle_result(self): """Process one result. Block untill one is available """ result = self.inbox.get() if result.success: if self._verbosity >= VERB_PROGRESS: sys.stderr.write("\nuploaded chunk {} \n".format(result.index)) self.results.append...
[ "def", "_handle_result", "(", "self", ")", ":", "result", "=", "self", ".", "inbox", ".", "get", "(", ")", "if", "result", ".", "success", ":", "if", "self", ".", "_verbosity", ">=", "VERB_PROGRESS", ":", "sys", ".", "stderr", ".", "write", "(", "\"\...
Process one result. Block untill one is available
[ "Process", "one", "result", ".", "Block", "untill", "one", "is", "available" ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/pput.py#L201-L211
7,606
presslabs/z3
z3/pput.py
UploadSupervisor._send_chunk
def _send_chunk(self, index, chunk): """Send the current chunk to the workers for processing. Called when the _partial_chunk is complete. Blocks when the outbox is full. """ self._pending_chunks += 1 self.outbox.put((index, chunk))
python
def _send_chunk(self, index, chunk): """Send the current chunk to the workers for processing. Called when the _partial_chunk is complete. Blocks when the outbox is full. """ self._pending_chunks += 1 self.outbox.put((index, chunk))
[ "def", "_send_chunk", "(", "self", ",", "index", ",", "chunk", ")", ":", "self", ".", "_pending_chunks", "+=", "1", "self", ".", "outbox", ".", "put", "(", "(", "index", ",", "chunk", ")", ")" ]
Send the current chunk to the workers for processing. Called when the _partial_chunk is complete. Blocks when the outbox is full.
[ "Send", "the", "current", "chunk", "to", "the", "workers", "for", "processing", ".", "Called", "when", "the", "_partial_chunk", "is", "complete", "." ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/pput.py#L220-L227
7,607
presslabs/z3
z3/config.py
OnionDict._get
def _get(self, key, section=None, default=_onion_dict_guard): """Try to get the key from each dict in turn. If you specify the optional section it looks there first. """ if section is not None: section_dict = self.__sections.get(section, {}) if key in section_dict...
python
def _get(self, key, section=None, default=_onion_dict_guard): """Try to get the key from each dict in turn. If you specify the optional section it looks there first. """ if section is not None: section_dict = self.__sections.get(section, {}) if key in section_dict...
[ "def", "_get", "(", "self", ",", "key", ",", "section", "=", "None", ",", "default", "=", "_onion_dict_guard", ")", ":", "if", "section", "is", "not", "None", ":", "section_dict", "=", "self", ".", "__sections", ".", "get", "(", "section", ",", "{", ...
Try to get the key from each dict in turn. If you specify the optional section it looks there first.
[ "Try", "to", "get", "the", "key", "from", "each", "dict", "in", "turn", ".", "If", "you", "specify", "the", "optional", "section", "it", "looks", "there", "first", "." ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/config.py#L21-L35
7,608
presslabs/z3
z3/snap.py
ZFSSnapshotManager._parse_snapshots
def _parse_snapshots(self): """Returns all snapshots grouped by filesystem, a dict of OrderedDict's The order of snapshots matters when determining parents for incremental send, so it's preserved. Data is indexed by filesystem then for each filesystem we have an OrderedDict of sn...
python
def _parse_snapshots(self): """Returns all snapshots grouped by filesystem, a dict of OrderedDict's The order of snapshots matters when determining parents for incremental send, so it's preserved. Data is indexed by filesystem then for each filesystem we have an OrderedDict of sn...
[ "def", "_parse_snapshots", "(", "self", ")", ":", "try", ":", "snap", "=", "self", ".", "_list_snapshots", "(", ")", "except", "OSError", "as", "err", ":", "logging", ".", "error", "(", "\"unable to list local snapshots!\"", ")", "return", "{", "}", "vols", ...
Returns all snapshots grouped by filesystem, a dict of OrderedDict's The order of snapshots matters when determining parents for incremental send, so it's preserved. Data is indexed by filesystem then for each filesystem we have an OrderedDict of snapshots.
[ "Returns", "all", "snapshots", "grouped", "by", "filesystem", "a", "dict", "of", "OrderedDict", "s", "The", "order", "of", "snapshots", "matters", "when", "determining", "parents", "for", "incremental", "send", "so", "it", "s", "preserved", ".", "Data", "is", ...
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/snap.py#L176-L202
7,609
presslabs/z3
z3/snap.py
PairManager._compress
def _compress(self, cmd): """Adds the appropriate command to compress the zfs stream""" compressor = COMPRESSORS.get(self.compressor) if compressor is None: return cmd compress_cmd = compressor['compress'] return "{} | {}".format(compress_cmd, cmd)
python
def _compress(self, cmd): """Adds the appropriate command to compress the zfs stream""" compressor = COMPRESSORS.get(self.compressor) if compressor is None: return cmd compress_cmd = compressor['compress'] return "{} | {}".format(compress_cmd, cmd)
[ "def", "_compress", "(", "self", ",", "cmd", ")", ":", "compressor", "=", "COMPRESSORS", ".", "get", "(", "self", ".", "compressor", ")", "if", "compressor", "is", "None", ":", "return", "cmd", "compress_cmd", "=", "compressor", "[", "'compress'", "]", "...
Adds the appropriate command to compress the zfs stream
[ "Adds", "the", "appropriate", "command", "to", "compress", "the", "zfs", "stream" ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/snap.py#L311-L317
7,610
presslabs/z3
z3/snap.py
PairManager._decompress
def _decompress(self, cmd, s3_snap): """Adds the appropriate command to decompress the zfs stream This is determined from the metadata of the s3_snap. """ compressor = COMPRESSORS.get(s3_snap.compressor) if compressor is None: return cmd decompress_cmd = compr...
python
def _decompress(self, cmd, s3_snap): """Adds the appropriate command to decompress the zfs stream This is determined from the metadata of the s3_snap. """ compressor = COMPRESSORS.get(s3_snap.compressor) if compressor is None: return cmd decompress_cmd = compr...
[ "def", "_decompress", "(", "self", ",", "cmd", ",", "s3_snap", ")", ":", "compressor", "=", "COMPRESSORS", ".", "get", "(", "s3_snap", ".", "compressor", ")", "if", "compressor", "is", "None", ":", "return", "cmd", "decompress_cmd", "=", "compressor", "[",...
Adds the appropriate command to decompress the zfs stream This is determined from the metadata of the s3_snap.
[ "Adds", "the", "appropriate", "command", "to", "decompress", "the", "zfs", "stream", "This", "is", "determined", "from", "the", "metadata", "of", "the", "s3_snap", "." ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/snap.py#L319-L327
7,611
presslabs/z3
z3/snap.py
PairManager.backup_full
def backup_full(self, snap_name=None, dry_run=False): """Do a full backup of a snapshot. By default latest local snapshot""" z_snap = self._snapshot_to_backup(snap_name) estimated_size = self._parse_estimated_size( self._cmd.shell( "zfs send -nvP '{}'".format(z_snap.n...
python
def backup_full(self, snap_name=None, dry_run=False): """Do a full backup of a snapshot. By default latest local snapshot""" z_snap = self._snapshot_to_backup(snap_name) estimated_size = self._parse_estimated_size( self._cmd.shell( "zfs send -nvP '{}'".format(z_snap.n...
[ "def", "backup_full", "(", "self", ",", "snap_name", "=", "None", ",", "dry_run", "=", "False", ")", ":", "z_snap", "=", "self", ".", "_snapshot_to_backup", "(", "snap_name", ")", "estimated_size", "=", "self", ".", "_parse_estimated_size", "(", "self", ".",...
Do a full backup of a snapshot. By default latest local snapshot
[ "Do", "a", "full", "backup", "of", "a", "snapshot", ".", "By", "default", "latest", "local", "snapshot" ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/snap.py#L341-L359
7,612
presslabs/z3
z3/snap.py
PairManager.backup_incremental
def backup_incremental(self, snap_name=None, dry_run=False): """Uploads named snapshot or latest, along with any other snapshots required for an incremental backup. """ z_snap = self._snapshot_to_backup(snap_name) to_upload = [] current = z_snap uploaded_meta = []...
python
def backup_incremental(self, snap_name=None, dry_run=False): """Uploads named snapshot or latest, along with any other snapshots required for an incremental backup. """ z_snap = self._snapshot_to_backup(snap_name) to_upload = [] current = z_snap uploaded_meta = []...
[ "def", "backup_incremental", "(", "self", ",", "snap_name", "=", "None", ",", "dry_run", "=", "False", ")", ":", "z_snap", "=", "self", ".", "_snapshot_to_backup", "(", "snap_name", ")", "to_upload", "=", "[", "]", "current", "=", "z_snap", "uploaded_meta", ...
Uploads named snapshot or latest, along with any other snapshots required for an incremental backup.
[ "Uploads", "named", "snapshot", "or", "latest", "along", "with", "any", "other", "snapshots", "required", "for", "an", "incremental", "backup", "." ]
965898cccddd351ce4c56402a215c3bda9f37b5e
https://github.com/presslabs/z3/blob/965898cccddd351ce4c56402a215c3bda9f37b5e/z3/snap.py#L361-L403
7,613
pyannote/pyannote-metrics
pyannote/metrics/utils.py
UEMSupportMixin.extrude
def extrude(self, uem, reference, collar=0.0, skip_overlap=False): """Extrude reference boundary collars from uem reference |----| |--------------| |-------------| uem |---------------------| |-------------------------------| extruded |--| |--| |---| |-----| |...
python
def extrude(self, uem, reference, collar=0.0, skip_overlap=False): """Extrude reference boundary collars from uem reference |----| |--------------| |-------------| uem |---------------------| |-------------------------------| extruded |--| |--| |---| |-----| |...
[ "def", "extrude", "(", "self", ",", "uem", ",", "reference", ",", "collar", "=", "0.0", ",", "skip_overlap", "=", "False", ")", ":", "if", "collar", "==", "0.", "and", "not", "skip_overlap", ":", "return", "uem", "collars", ",", "overlap_regions", "=", ...
Extrude reference boundary collars from uem reference |----| |--------------| |-------------| uem |---------------------| |-------------------------------| extruded |--| |--| |---| |-----| |-| |-----| |-----------| |-----| Parameters ---------- ...
[ "Extrude", "reference", "boundary", "collars", "from", "uem" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/utils.py#L38-L93
7,614
pyannote/pyannote-metrics
pyannote/metrics/utils.py
UEMSupportMixin.common_timeline
def common_timeline(self, reference, hypothesis): """Return timeline common to both reference and hypothesis reference |--------| |------------| |---------| |----| hypothesis |--------------| |------| |----------------| timeline |--|-----|----|---|-|------| |...
python
def common_timeline(self, reference, hypothesis): """Return timeline common to both reference and hypothesis reference |--------| |------------| |---------| |----| hypothesis |--------------| |------| |----------------| timeline |--|-----|----|---|-|------| |...
[ "def", "common_timeline", "(", "self", ",", "reference", ",", "hypothesis", ")", ":", "timeline", "=", "reference", ".", "get_timeline", "(", "copy", "=", "True", ")", "timeline", ".", "update", "(", "hypothesis", ".", "get_timeline", "(", "copy", "=", "Fa...
Return timeline common to both reference and hypothesis reference |--------| |------------| |---------| |----| hypothesis |--------------| |------| |----------------| timeline |--|-----|----|---|-|------| |-|---------|----| |----| Parameters -----...
[ "Return", "timeline", "common", "to", "both", "reference", "and", "hypothesis" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/utils.py#L95-L113
7,615
pyannote/pyannote-metrics
pyannote/metrics/utils.py
UEMSupportMixin.project
def project(self, annotation, timeline): """Project annotation onto timeline segments reference |__A__| |__B__| |____C____| timeline |---|---|---| |---| projection |_A_|_A_|_C_| |_B_| |_C_| Parameters ---...
python
def project(self, annotation, timeline): """Project annotation onto timeline segments reference |__A__| |__B__| |____C____| timeline |---|---|---| |---| projection |_A_|_A_|_C_| |_B_| |_C_| Parameters ---...
[ "def", "project", "(", "self", ",", "annotation", ",", "timeline", ")", ":", "projection", "=", "annotation", ".", "empty", "(", ")", "timeline_", "=", "annotation", ".", "get_timeline", "(", "copy", "=", "False", ")", "for", "segment_", ",", "segment", ...
Project annotation onto timeline segments reference |__A__| |__B__| |____C____| timeline |---|---|---| |---| projection |_A_|_A_|_C_| |_B_| |_C_| Parameters ---------- annotation : Annotation time...
[ "Project", "annotation", "onto", "timeline", "segments" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/utils.py#L115-L141
7,616
pyannote/pyannote-metrics
pyannote/metrics/utils.py
UEMSupportMixin.uemify
def uemify(self, reference, hypothesis, uem=None, collar=0., skip_overlap=False, returns_uem=False, returns_timeline=False): """Crop 'reference' and 'hypothesis' to 'uem' support Parameters ---------- reference, hypothesis : Annotation Reference and hypothesis...
python
def uemify(self, reference, hypothesis, uem=None, collar=0., skip_overlap=False, returns_uem=False, returns_timeline=False): """Crop 'reference' and 'hypothesis' to 'uem' support Parameters ---------- reference, hypothesis : Annotation Reference and hypothesis...
[ "def", "uemify", "(", "self", ",", "reference", ",", "hypothesis", ",", "uem", "=", "None", ",", "collar", "=", "0.", ",", "skip_overlap", "=", "False", ",", "returns_uem", "=", "False", ",", "returns_timeline", "=", "False", ")", ":", "# when uem is not p...
Crop 'reference' and 'hypothesis' to 'uem' support Parameters ---------- reference, hypothesis : Annotation Reference and hypothesis annotations. uem : Timeline, optional Evaluation map. collar : float, optional When provided, set the duration...
[ "Crop", "reference", "and", "hypothesis", "to", "uem", "support" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/utils.py#L143-L210
7,617
pyannote/pyannote-metrics
scripts/pyannote-metrics.py
get_hypothesis
def get_hypothesis(hypotheses, current_file): """Get hypothesis for given file Parameters ---------- hypotheses : `dict` Speaker diarization hypothesis provided by `load_rttm`. current_file : `dict` File description as given by pyannote.database protocols. Returns ------- ...
python
def get_hypothesis(hypotheses, current_file): """Get hypothesis for given file Parameters ---------- hypotheses : `dict` Speaker diarization hypothesis provided by `load_rttm`. current_file : `dict` File description as given by pyannote.database protocols. Returns ------- ...
[ "def", "get_hypothesis", "(", "hypotheses", ",", "current_file", ")", ":", "uri", "=", "current_file", "[", "'uri'", "]", "if", "uri", "in", "hypotheses", ":", "return", "hypotheses", "[", "uri", "]", "# if the exact 'uri' is not available in hypothesis,", "# look f...
Get hypothesis for given file Parameters ---------- hypotheses : `dict` Speaker diarization hypothesis provided by `load_rttm`. current_file : `dict` File description as given by pyannote.database protocols. Returns ------- hypothesis : `pyannote.core.Annotation` Hy...
[ "Get", "hypothesis", "for", "given", "file" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/scripts/pyannote-metrics.py#L142-L181
7,618
pyannote/pyannote-metrics
scripts/pyannote-metrics.py
reindex
def reindex(report): """Reindex report so that 'TOTAL' is the last row""" index = list(report.index) i = index.index('TOTAL') return report.reindex(index[:i] + index[i+1:] + ['TOTAL'])
python
def reindex(report): """Reindex report so that 'TOTAL' is the last row""" index = list(report.index) i = index.index('TOTAL') return report.reindex(index[:i] + index[i+1:] + ['TOTAL'])
[ "def", "reindex", "(", "report", ")", ":", "index", "=", "list", "(", "report", ".", "index", ")", "i", "=", "index", ".", "index", "(", "'TOTAL'", ")", "return", "report", ".", "reindex", "(", "index", "[", ":", "i", "]", "+", "index", "[", "i",...
Reindex report so that 'TOTAL' is the last row
[ "Reindex", "report", "so", "that", "TOTAL", "is", "the", "last", "row" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/scripts/pyannote-metrics.py#L219-L223
7,619
pyannote/pyannote-metrics
pyannote/metrics/binary_classification.py
precision_recall_curve
def precision_recall_curve(y_true, scores, distances=False): """Precision-recall curve Parameters ---------- y_true : (n_samples, ) array-like Boolean reference. scores : (n_samples, ) array-like Predicted score. distances : boolean, optional When True, indicate that `sc...
python
def precision_recall_curve(y_true, scores, distances=False): """Precision-recall curve Parameters ---------- y_true : (n_samples, ) array-like Boolean reference. scores : (n_samples, ) array-like Predicted score. distances : boolean, optional When True, indicate that `sc...
[ "def", "precision_recall_curve", "(", "y_true", ",", "scores", ",", "distances", "=", "False", ")", ":", "if", "distances", ":", "scores", "=", "-", "scores", "precision", ",", "recall", ",", "thresholds", "=", "sklearn", ".", "metrics", ".", "precision_reca...
Precision-recall curve Parameters ---------- y_true : (n_samples, ) array-like Boolean reference. scores : (n_samples, ) array-like Predicted score. distances : boolean, optional When True, indicate that `scores` are actually `distances` Returns ------- precisio...
[ "Precision", "-", "recall", "curve" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/binary_classification.py#L81-L117
7,620
pyannote/pyannote-metrics
pyannote/metrics/errors/identification.py
IdentificationErrorAnalysis.difference
def difference(self, reference, hypothesis, uem=None, uemified=False): """Get error analysis as `Annotation` Labels are (status, reference_label, hypothesis_label) tuples. `status` is either 'correct', 'confusion', 'missed detection' or 'false alarm'. `reference_label` is None i...
python
def difference(self, reference, hypothesis, uem=None, uemified=False): """Get error analysis as `Annotation` Labels are (status, reference_label, hypothesis_label) tuples. `status` is either 'correct', 'confusion', 'missed detection' or 'false alarm'. `reference_label` is None i...
[ "def", "difference", "(", "self", ",", "reference", ",", "hypothesis", ",", "uem", "=", "None", ",", "uemified", "=", "False", ")", ":", "R", ",", "H", ",", "common_timeline", "=", "self", ".", "uemify", "(", "reference", ",", "hypothesis", ",", "uem",...
Get error analysis as `Annotation` Labels are (status, reference_label, hypothesis_label) tuples. `status` is either 'correct', 'confusion', 'missed detection' or 'false alarm'. `reference_label` is None in case of 'false alarm'. `hypothesis_label` is None in case of 'missed det...
[ "Get", "error", "analysis", "as", "Annotation" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/errors/identification.py#L75-L134
7,621
pyannote/pyannote-metrics
pyannote/metrics/base.py
BaseMetric.reset
def reset(self): """Reset accumulated components and metric values""" if self.parallel: from pyannote.metrics import manager_ self.accumulated_ = manager_.dict() self.results_ = manager_.list() self.uris_ = manager_.dict() else: self.ac...
python
def reset(self): """Reset accumulated components and metric values""" if self.parallel: from pyannote.metrics import manager_ self.accumulated_ = manager_.dict() self.results_ = manager_.list() self.uris_ = manager_.dict() else: self.ac...
[ "def", "reset", "(", "self", ")", ":", "if", "self", ".", "parallel", ":", "from", "pyannote", ".", "metrics", "import", "manager_", "self", ".", "accumulated_", "=", "manager_", ".", "dict", "(", ")", "self", ".", "results_", "=", "manager_", ".", "li...
Reset accumulated components and metric values
[ "Reset", "accumulated", "components", "and", "metric", "values" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L76-L88
7,622
pyannote/pyannote-metrics
pyannote/metrics/base.py
BaseMetric.confidence_interval
def confidence_interval(self, alpha=0.9): """Compute confidence interval on accumulated metric values Parameters ---------- alpha : float, optional Probability that the returned confidence interval contains the true metric value. Returns ------- ...
python
def confidence_interval(self, alpha=0.9): """Compute confidence interval on accumulated metric values Parameters ---------- alpha : float, optional Probability that the returned confidence interval contains the true metric value. Returns ------- ...
[ "def", "confidence_interval", "(", "self", ",", "alpha", "=", "0.9", ")", ":", "m", ",", "_", ",", "_", "=", "scipy", ".", "stats", ".", "bayes_mvs", "(", "[", "r", "[", "self", ".", "metric_name_", "]", "for", "_", ",", "r", "in", "self", ".", ...
Compute confidence interval on accumulated metric values Parameters ---------- alpha : float, optional Probability that the returned confidence interval contains the true metric value. Returns ------- (center, (lower, upper)) with cen...
[ "Compute", "confidence", "interval", "on", "accumulated", "metric", "values" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L296-L319
7,623
pyannote/pyannote-metrics
pyannote/metrics/base.py
Precision.compute_metric
def compute_metric(self, components): """Compute precision from `components`""" numerator = components[PRECISION_RELEVANT_RETRIEVED] denominator = components[PRECISION_RETRIEVED] if denominator == 0.: if numerator == 0: return 1. else: ...
python
def compute_metric(self, components): """Compute precision from `components`""" numerator = components[PRECISION_RELEVANT_RETRIEVED] denominator = components[PRECISION_RETRIEVED] if denominator == 0.: if numerator == 0: return 1. else: ...
[ "def", "compute_metric", "(", "self", ",", "components", ")", ":", "numerator", "=", "components", "[", "PRECISION_RELEVANT_RETRIEVED", "]", "denominator", "=", "components", "[", "PRECISION_RETRIEVED", "]", "if", "denominator", "==", "0.", ":", "if", "numerator",...
Compute precision from `components`
[ "Compute", "precision", "from", "components" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L347-L357
7,624
pyannote/pyannote-metrics
pyannote/metrics/base.py
Recall.compute_metric
def compute_metric(self, components): """Compute recall from `components`""" numerator = components[RECALL_RELEVANT_RETRIEVED] denominator = components[RECALL_RELEVANT] if denominator == 0.: if numerator == 0: return 1. else: raise ...
python
def compute_metric(self, components): """Compute recall from `components`""" numerator = components[RECALL_RELEVANT_RETRIEVED] denominator = components[RECALL_RELEVANT] if denominator == 0.: if numerator == 0: return 1. else: raise ...
[ "def", "compute_metric", "(", "self", ",", "components", ")", ":", "numerator", "=", "components", "[", "RECALL_RELEVANT_RETRIEVED", "]", "denominator", "=", "components", "[", "RECALL_RELEVANT", "]", "if", "denominator", "==", "0.", ":", "if", "numerator", "=="...
Compute recall from `components`
[ "Compute", "recall", "from", "components" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/base.py#L384-L394
7,625
pyannote/pyannote-metrics
pyannote/metrics/diarization.py
DiarizationErrorRate.optimal_mapping
def optimal_mapping(self, reference, hypothesis, uem=None): """Optimal label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns -...
python
def optimal_mapping(self, reference, hypothesis, uem=None): """Optimal label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns -...
[ "def", "optimal_mapping", "(", "self", ",", "reference", ",", "hypothesis", ",", "uem", "=", "None", ")", ":", "# NOTE that this 'uemification' will not be called when", "# 'optimal_mapping' is called from 'compute_components' as it", "# has already been done in 'compute_components'"...
Optimal label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns ------- mapping : dict Mapping between hypothesis (k...
[ "Optimal", "label", "mapping" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/diarization.py#L106-L131
7,626
pyannote/pyannote-metrics
pyannote/metrics/diarization.py
GreedyDiarizationErrorRate.greedy_mapping
def greedy_mapping(self, reference, hypothesis, uem=None): """Greedy label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns ---...
python
def greedy_mapping(self, reference, hypothesis, uem=None): """Greedy label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns ---...
[ "def", "greedy_mapping", "(", "self", ",", "reference", ",", "hypothesis", ",", "uem", "=", "None", ")", ":", "if", "uem", ":", "reference", ",", "hypothesis", "=", "self", ".", "uemify", "(", "reference", ",", "hypothesis", ",", "uem", "=", "uem", ")"...
Greedy label mapping Parameters ---------- reference : Annotation hypothesis : Annotation Reference and hypothesis diarization uem : Timeline Evaluation map Returns ------- mapping : dict Mapping between hypothesis (ke...
[ "Greedy", "label", "mapping" ]
b433fec3bd37ca36fe026a428cd72483d646871a
https://github.com/pyannote/pyannote-metrics/blob/b433fec3bd37ca36fe026a428cd72483d646871a/pyannote/metrics/diarization.py#L223-L241
7,627
brian-rose/climlab
climlab/radiation/radiation.py
default_absorbers
def default_absorbers(Tatm, ozone_file = 'apeozone_cam3_5_54.nc', verbose = True,): '''Initialize a dictionary of well-mixed radiatively active gases All values are volumetric mixing ratios. Ozone is set to a climatology. All other gases are assumed well-mixed: ...
python
def default_absorbers(Tatm, ozone_file = 'apeozone_cam3_5_54.nc', verbose = True,): '''Initialize a dictionary of well-mixed radiatively active gases All values are volumetric mixing ratios. Ozone is set to a climatology. All other gases are assumed well-mixed: ...
[ "def", "default_absorbers", "(", "Tatm", ",", "ozone_file", "=", "'apeozone_cam3_5_54.nc'", ",", "verbose", "=", "True", ",", ")", ":", "absorber_vmr", "=", "{", "}", "absorber_vmr", "[", "'CO2'", "]", "=", "348.", "/", "1E6", "absorber_vmr", "[", "'CH4'", ...
Initialize a dictionary of well-mixed radiatively active gases All values are volumetric mixing ratios. Ozone is set to a climatology. All other gases are assumed well-mixed: - CO2 - CH4 - N2O - O2 - CFC11 - CFC12 - CFC22 - CCL4 Specifi...
[ "Initialize", "a", "dictionary", "of", "well", "-", "mixed", "radiatively", "active", "gases", "All", "values", "are", "volumetric", "mixing", "ratios", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/radiation.py#L98-L166
7,628
brian-rose/climlab
climlab/radiation/radiation.py
init_interface
def init_interface(field): '''Return a Field object defined at the vertical interfaces of the input Field object.''' interface_shape = np.array(field.shape); interface_shape[-1] += 1 interfaces = np.tile(False,len(interface_shape)); interfaces[-1] = True interface_zero = Field(np.zeros(interface_shape),...
python
def init_interface(field): '''Return a Field object defined at the vertical interfaces of the input Field object.''' interface_shape = np.array(field.shape); interface_shape[-1] += 1 interfaces = np.tile(False,len(interface_shape)); interfaces[-1] = True interface_zero = Field(np.zeros(interface_shape),...
[ "def", "init_interface", "(", "field", ")", ":", "interface_shape", "=", "np", ".", "array", "(", "field", ".", "shape", ")", "interface_shape", "[", "-", "1", "]", "+=", "1", "interfaces", "=", "np", ".", "tile", "(", "False", ",", "len", "(", "inte...
Return a Field object defined at the vertical interfaces of the input Field object.
[ "Return", "a", "Field", "object", "defined", "at", "the", "vertical", "interfaces", "of", "the", "input", "Field", "object", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/radiation.py#L168-L173
7,629
brian-rose/climlab
climlab/convection/akmaev_adjustment.py
convective_adjustment_direct
def convective_adjustment_direct(p, T, c, lapserate=6.5): """Convective Adjustment to a specified lapse rate. Input argument lapserate gives the lapse rate expressed in degrees K per km (positive means temperature increasing downward). Default lapse rate is 6.5 K / km. Returns the adjusted Column...
python
def convective_adjustment_direct(p, T, c, lapserate=6.5): """Convective Adjustment to a specified lapse rate. Input argument lapserate gives the lapse rate expressed in degrees K per km (positive means temperature increasing downward). Default lapse rate is 6.5 K / km. Returns the adjusted Column...
[ "def", "convective_adjustment_direct", "(", "p", ",", "T", ",", "c", ",", "lapserate", "=", "6.5", ")", ":", "# largely follows notation and algorithm in Akmaev (1991) MWR", "alpha", "=", "const", ".", "Rd", "/", "const", ".", "g", "*", "lapserate", "/", "1.E3",...
Convective Adjustment to a specified lapse rate. Input argument lapserate gives the lapse rate expressed in degrees K per km (positive means temperature increasing downward). Default lapse rate is 6.5 K / km. Returns the adjusted Column temperature. inputs: p is pressure in hPa T is tempe...
[ "Convective", "Adjustment", "to", "a", "specified", "lapse", "rate", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/convection/akmaev_adjustment.py#L7-L39
7,630
brian-rose/climlab
climlab/convection/akmaev_adjustment.py
Akmaev_adjustment
def Akmaev_adjustment(theta, q, beta, n_k, theta_k, s_k, t_k): '''Single column only.''' L = q.size # number of vertical levels # Akmaev step 1 k = 1 n_k[k-1] = 1 theta_k[k-1] = theta[k-1] l = 2 while True: # Akmaev step 2 n = 1 thistheta = theta[l-1] whi...
python
def Akmaev_adjustment(theta, q, beta, n_k, theta_k, s_k, t_k): '''Single column only.''' L = q.size # number of vertical levels # Akmaev step 1 k = 1 n_k[k-1] = 1 theta_k[k-1] = theta[k-1] l = 2 while True: # Akmaev step 2 n = 1 thistheta = theta[l-1] whi...
[ "def", "Akmaev_adjustment", "(", "theta", ",", "q", ",", "beta", ",", "n_k", ",", "theta_k", ",", "s_k", ",", "t_k", ")", ":", "L", "=", "q", ".", "size", "# number of vertical levels", "# Akmaev step 1", "k", "=", "1", "n_k", "[", "k", "-", "1", "]"...
Single column only.
[ "Single", "column", "only", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/convection/akmaev_adjustment.py#L58-L129
7,631
brian-rose/climlab
climlab/model/column.py
GreyRadiationModel.do_diagnostics
def do_diagnostics(self): '''Set all the diagnostics from long and shortwave radiation.''' self.OLR = self.subprocess['LW'].flux_to_space self.LW_down_sfc = self.subprocess['LW'].flux_to_sfc self.LW_up_sfc = self.subprocess['LW'].flux_from_sfc self.LW_absorbed_sfc = self.LW_down_...
python
def do_diagnostics(self): '''Set all the diagnostics from long and shortwave radiation.''' self.OLR = self.subprocess['LW'].flux_to_space self.LW_down_sfc = self.subprocess['LW'].flux_to_sfc self.LW_up_sfc = self.subprocess['LW'].flux_from_sfc self.LW_absorbed_sfc = self.LW_down_...
[ "def", "do_diagnostics", "(", "self", ")", ":", "self", ".", "OLR", "=", "self", ".", "subprocess", "[", "'LW'", "]", ".", "flux_to_space", "self", ".", "LW_down_sfc", "=", "self", ".", "subprocess", "[", "'LW'", "]", ".", "flux_to_sfc", "self", ".", "...
Set all the diagnostics from long and shortwave radiation.
[ "Set", "all", "the", "diagnostics", "from", "long", "and", "shortwave", "radiation", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/model/column.py#L119-L141
7,632
brian-rose/climlab
climlab/utils/thermo.py
clausius_clapeyron
def clausius_clapeyron(T): """Compute saturation vapor pressure as function of temperature T. Input: T is temperature in Kelvin Output: saturation vapor pressure in mb or hPa Formula from Rogers and Yau "A Short Course in Cloud Physics" (Pergammon Press), p. 16 claimed to be accurate to within 0.1...
python
def clausius_clapeyron(T): """Compute saturation vapor pressure as function of temperature T. Input: T is temperature in Kelvin Output: saturation vapor pressure in mb or hPa Formula from Rogers and Yau "A Short Course in Cloud Physics" (Pergammon Press), p. 16 claimed to be accurate to within 0.1...
[ "def", "clausius_clapeyron", "(", "T", ")", ":", "Tcel", "=", "T", "-", "tempCtoK", "es", "=", "6.112", "*", "exp", "(", "17.67", "*", "Tcel", "/", "(", "Tcel", "+", "243.5", ")", ")", "return", "es" ]
Compute saturation vapor pressure as function of temperature T. Input: T is temperature in Kelvin Output: saturation vapor pressure in mb or hPa Formula from Rogers and Yau "A Short Course in Cloud Physics" (Pergammon Press), p. 16 claimed to be accurate to within 0.1% between -30degC and 35 degC ...
[ "Compute", "saturation", "vapor", "pressure", "as", "function", "of", "temperature", "T", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/thermo.py#L41-L54
7,633
brian-rose/climlab
climlab/utils/thermo.py
qsat
def qsat(T,p): """Compute saturation specific humidity as function of temperature and pressure. Input: T is temperature in Kelvin p is pressure in hPa or mb Output: saturation specific humidity (dimensionless). """ es = clausius_clapeyron(T) q = eps * es / (p - (1 - eps) * es ) ...
python
def qsat(T,p): """Compute saturation specific humidity as function of temperature and pressure. Input: T is temperature in Kelvin p is pressure in hPa or mb Output: saturation specific humidity (dimensionless). """ es = clausius_clapeyron(T) q = eps * es / (p - (1 - eps) * es ) ...
[ "def", "qsat", "(", "T", ",", "p", ")", ":", "es", "=", "clausius_clapeyron", "(", "T", ")", "q", "=", "eps", "*", "es", "/", "(", "p", "-", "(", "1", "-", "eps", ")", "*", "es", ")", "return", "q" ]
Compute saturation specific humidity as function of temperature and pressure. Input: T is temperature in Kelvin p is pressure in hPa or mb Output: saturation specific humidity (dimensionless).
[ "Compute", "saturation", "specific", "humidity", "as", "function", "of", "temperature", "and", "pressure", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/thermo.py#L56-L66
7,634
brian-rose/climlab
climlab/utils/thermo.py
pseudoadiabat
def pseudoadiabat(T,p): """Compute the local slope of the pseudoadiabat at given temperature and pressure Inputs: p is pressure in hPa or mb T is local temperature in Kelvin Output: dT/dp, the rate of temperature change for pseudoadiabatic ascent in units of K / hPa T...
python
def pseudoadiabat(T,p): """Compute the local slope of the pseudoadiabat at given temperature and pressure Inputs: p is pressure in hPa or mb T is local temperature in Kelvin Output: dT/dp, the rate of temperature change for pseudoadiabatic ascent in units of K / hPa T...
[ "def", "pseudoadiabat", "(", "T", ",", "p", ")", ":", "esoverp", "=", "clausius_clapeyron", "(", "T", ")", "/", "p", "Tcel", "=", "T", "-", "tempCtoK", "L", "=", "(", "2.501", "-", "0.00237", "*", "Tcel", ")", "*", "1.E6", "# Accurate form of latent he...
Compute the local slope of the pseudoadiabat at given temperature and pressure Inputs: p is pressure in hPa or mb T is local temperature in Kelvin Output: dT/dp, the rate of temperature change for pseudoadiabatic ascent in units of K / hPa The pseudoadiabat describes chan...
[ "Compute", "the", "local", "slope", "of", "the", "pseudoadiabat", "at", "given", "temperature", "and", "pressure" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/thermo.py#L101-L124
7,635
brian-rose/climlab
climlab/dynamics/diffusion.py
_solve_implicit_banded
def _solve_implicit_banded(current, banded_matrix): """Uses a banded solver for matrix inversion of a tridiagonal matrix. Converts the complete listed tridiagonal matrix *(nxn)* into a three row matrix *(3xn)* and calls :py:func:`scipy.linalg.solve_banded()`. :param array current: the curren...
python
def _solve_implicit_banded(current, banded_matrix): """Uses a banded solver for matrix inversion of a tridiagonal matrix. Converts the complete listed tridiagonal matrix *(nxn)* into a three row matrix *(3xn)* and calls :py:func:`scipy.linalg.solve_banded()`. :param array current: the curren...
[ "def", "_solve_implicit_banded", "(", "current", ",", "banded_matrix", ")", ":", "# can improve performance by storing the banded form once and not", "# recalculating it...", "# but whatever", "J", "=", "banded_matrix", ".", "shape", "[", "0", "]", "diag", "=", "np", "...
Uses a banded solver for matrix inversion of a tridiagonal matrix. Converts the complete listed tridiagonal matrix *(nxn)* into a three row matrix *(3xn)* and calls :py:func:`scipy.linalg.solve_banded()`. :param array current: the current state of the variable for which ...
[ "Uses", "a", "banded", "solver", "for", "matrix", "inversion", "of", "a", "tridiagonal", "matrix", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L360-L381
7,636
brian-rose/climlab
climlab/dynamics/diffusion.py
_guess_diffusion_axis
def _guess_diffusion_axis(process_or_domain): """Scans given process, domain or dictionary of domains for a diffusion axis and returns appropriate name. In case only one axis with length > 1 in the process or set of domains exists, the name of that axis is returned. Otherwise an error is raised. :...
python
def _guess_diffusion_axis(process_or_domain): """Scans given process, domain or dictionary of domains for a diffusion axis and returns appropriate name. In case only one axis with length > 1 in the process or set of domains exists, the name of that axis is returned. Otherwise an error is raised. :...
[ "def", "_guess_diffusion_axis", "(", "process_or_domain", ")", ":", "axes", "=", "get_axes", "(", "process_or_domain", ")", "diff_ax", "=", "{", "}", "for", "axname", ",", "ax", "in", "axes", ".", "items", "(", ")", ":", "if", "ax", ".", "num_points", ">...
Scans given process, domain or dictionary of domains for a diffusion axis and returns appropriate name. In case only one axis with length > 1 in the process or set of domains exists, the name of that axis is returned. Otherwise an error is raised. :param process_or_domain: input from where diffusion...
[ "Scans", "given", "process", "domain", "or", "dictionary", "of", "domains", "for", "a", "diffusion", "axis", "and", "returns", "appropriate", "name", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L384-L408
7,637
brian-rose/climlab
climlab/dynamics/diffusion.py
Diffusion._implicit_solver
def _implicit_solver(self): """Invertes and solves the matrix problem for diffusion matrix and temperature T. The method is called by the :func:`~climlab.process.implicit.ImplicitProcess._compute()` function of the :class:`~climlab.process.implicit.ImplicitProcess` class and ...
python
def _implicit_solver(self): """Invertes and solves the matrix problem for diffusion matrix and temperature T. The method is called by the :func:`~climlab.process.implicit.ImplicitProcess._compute()` function of the :class:`~climlab.process.implicit.ImplicitProcess` class and ...
[ "def", "_implicit_solver", "(", "self", ")", ":", "#if self.update_diffusivity:", "# Time-stepping the diffusion is just inverting this matrix problem:", "newstate", "=", "{", "}", "for", "varname", ",", "value", "in", "self", ".", "state", ".", "items", "(", ")", ":"...
Invertes and solves the matrix problem for diffusion matrix and temperature T. The method is called by the :func:`~climlab.process.implicit.ImplicitProcess._compute()` function of the :class:`~climlab.process.implicit.ImplicitProcess` class and solves the matrix problem ...
[ "Invertes", "and", "solves", "the", "matrix", "problem", "for", "diffusion", "matrix", "and", "temperature", "T", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L143-L192
7,638
brian-rose/climlab
climlab/surface/albedo.py
P2Albedo._compute_fixed
def _compute_fixed(self): '''Recompute any fixed quantities after a change in parameters''' try: lon, lat = np.meshgrid(self.lon, self.lat) except: lat = self.lat phi = np.deg2rad(lat) try: albedo = self.a0 + self.a2 * P2(np.sin(phi)) e...
python
def _compute_fixed(self): '''Recompute any fixed quantities after a change in parameters''' try: lon, lat = np.meshgrid(self.lon, self.lat) except: lat = self.lat phi = np.deg2rad(lat) try: albedo = self.a0 + self.a2 * P2(np.sin(phi)) e...
[ "def", "_compute_fixed", "(", "self", ")", ":", "try", ":", "lon", ",", "lat", "=", "np", ".", "meshgrid", "(", "self", ".", "lon", ",", "self", ".", "lat", ")", "except", ":", "lat", "=", "self", ".", "lat", "phi", "=", "np", ".", "deg2rad", "...
Recompute any fixed quantities after a change in parameters
[ "Recompute", "any", "fixed", "quantities", "after", "a", "change", "in", "parameters" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/surface/albedo.py#L179-L194
7,639
brian-rose/climlab
climlab/surface/albedo.py
Iceline.find_icelines
def find_icelines(self): """Finds iceline according to the surface temperature. This method is called by the private function :func:`~climlab.surface.albedo.Iceline._compute` and updates following attributes according to the freezing temperature ``self.param['Tf']`` and the surf...
python
def find_icelines(self): """Finds iceline according to the surface temperature. This method is called by the private function :func:`~climlab.surface.albedo.Iceline._compute` and updates following attributes according to the freezing temperature ``self.param['Tf']`` and the surf...
[ "def", "find_icelines", "(", "self", ")", ":", "Tf", "=", "self", ".", "param", "[", "'Tf'", "]", "Ts", "=", "self", ".", "state", "[", "'Ts'", "]", "lat_bounds", "=", "self", ".", "domains", "[", "'Ts'", "]", ".", "axes", "[", "'lat'", "]", ".",...
Finds iceline according to the surface temperature. This method is called by the private function :func:`~climlab.surface.albedo.Iceline._compute` and updates following attributes according to the freezing temperature ``self.param['Tf']`` and the surface temperature ``self.param['Ts']``...
[ "Finds", "iceline", "according", "to", "the", "surface", "temperature", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/surface/albedo.py#L236-L291
7,640
brian-rose/climlab
climlab/surface/albedo.py
StepFunctionAlbedo._get_current_albedo
def _get_current_albedo(self): '''Simple step-function albedo based on ice line at temperature Tf.''' ice = self.subprocess['iceline'].ice # noice = self.subprocess['iceline'].diagnostics['noice'] cold_albedo = self.subprocess['cold_albedo'].albedo warm_albedo = self.subprocess['...
python
def _get_current_albedo(self): '''Simple step-function albedo based on ice line at temperature Tf.''' ice = self.subprocess['iceline'].ice # noice = self.subprocess['iceline'].diagnostics['noice'] cold_albedo = self.subprocess['cold_albedo'].albedo warm_albedo = self.subprocess['...
[ "def", "_get_current_albedo", "(", "self", ")", ":", "ice", "=", "self", ".", "subprocess", "[", "'iceline'", "]", ".", "ice", "# noice = self.subprocess['iceline'].diagnostics['noice']", "cold_albedo", "=", "self", ".", "subprocess", "[", "'cold_albedo'", "]", ".",...
Simple step-function albedo based on ice line at temperature Tf.
[ "Simple", "step", "-", "function", "albedo", "based", "on", "ice", "line", "at", "temperature", "Tf", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/surface/albedo.py#L374-L381
7,641
brian-rose/climlab
climlab/process/process.py
process_like
def process_like(proc): """Make an exact clone of a process, including state and all subprocesses. The creation date is updated. :param proc: process :type proc: :class:`~climlab.process.process.Process` :return: new process identical to the given process :rtype: :class:`...
python
def process_like(proc): """Make an exact clone of a process, including state and all subprocesses. The creation date is updated. :param proc: process :type proc: :class:`~climlab.process.process.Process` :return: new process identical to the given process :rtype: :class:`...
[ "def", "process_like", "(", "proc", ")", ":", "newproc", "=", "copy", ".", "deepcopy", "(", "proc", ")", "newproc", ".", "creation_date", "=", "time", ".", "strftime", "(", "\"%a, %d %b %Y %H:%M:%S %z\"", ",", "time", ".", "localtime", "(", ")", ")", "retu...
Make an exact clone of a process, including state and all subprocesses. The creation date is updated. :param proc: process :type proc: :class:`~climlab.process.process.Process` :return: new process identical to the given process :rtype: :class:`~climlab.process.process.Proces...
[ "Make", "an", "exact", "clone", "of", "a", "process", "including", "state", "and", "all", "subprocesses", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L783-L817
7,642
brian-rose/climlab
climlab/process/process.py
get_axes
def get_axes(process_or_domain): """Returns a dictionary of all Axis in a domain or dictionary of domains. :param process_or_domain: a process or a domain object :type process_or_domain: :class:`~climlab.process.process.Process` or :class:`~climlab.domain.domain._Domain...
python
def get_axes(process_or_domain): """Returns a dictionary of all Axis in a domain or dictionary of domains. :param process_or_domain: a process or a domain object :type process_or_domain: :class:`~climlab.process.process.Process` or :class:`~climlab.domain.domain._Domain...
[ "def", "get_axes", "(", "process_or_domain", ")", ":", "if", "isinstance", "(", "process_or_domain", ",", "Process", ")", ":", "dom", "=", "process_or_domain", ".", "domains", "else", ":", "dom", "=", "process_or_domain", "if", "isinstance", "(", "dom", ",", ...
Returns a dictionary of all Axis in a domain or dictionary of domains. :param process_or_domain: a process or a domain object :type process_or_domain: :class:`~climlab.process.process.Process` or :class:`~climlab.domain.domain._Domain` :raises: :exc: `TypeE...
[ "Returns", "a", "dictionary", "of", "all", "Axis", "in", "a", "domain", "or", "dictionary", "of", "domains", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L820-L857
7,643
brian-rose/climlab
climlab/process/process.py
Process.add_subprocesses
def add_subprocesses(self, procdict): """Adds a dictionary of subproceses to this process. Calls :func:`add_subprocess` for every process given in the input-dictionary. It can also pass a single process, which will be given the name *default*. :param procdict: a dictionary w...
python
def add_subprocesses(self, procdict): """Adds a dictionary of subproceses to this process. Calls :func:`add_subprocess` for every process given in the input-dictionary. It can also pass a single process, which will be given the name *default*. :param procdict: a dictionary w...
[ "def", "add_subprocesses", "(", "self", ",", "procdict", ")", ":", "if", "isinstance", "(", "procdict", ",", "Process", ")", ":", "try", ":", "name", "=", "procdict", ".", "name", "except", ":", "name", "=", "'default'", "self", ".", "add_subprocess", "(...
Adds a dictionary of subproceses to this process. Calls :func:`add_subprocess` for every process given in the input-dictionary. It can also pass a single process, which will be given the name *default*. :param procdict: a dictionary with process names as keys :type procdict:...
[ "Adds", "a", "dictionary", "of", "subproceses", "to", "this", "process", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L191-L210
7,644
brian-rose/climlab
climlab/process/process.py
Process.add_subprocess
def add_subprocess(self, name, proc): """Adds a single subprocess to this process. :param string name: name of the subprocess :param proc: a Process object :type proc: :class:`~climlab.process.process.Process` :raises: :exc:`ValueError` ...
python
def add_subprocess(self, name, proc): """Adds a single subprocess to this process. :param string name: name of the subprocess :param proc: a Process object :type proc: :class:`~climlab.process.process.Process` :raises: :exc:`ValueError` ...
[ "def", "add_subprocess", "(", "self", ",", "name", ",", "proc", ")", ":", "if", "isinstance", "(", "proc", ",", "Process", ")", ":", "self", ".", "subprocess", ".", "update", "(", "{", "name", ":", "proc", "}", ")", "self", ".", "has_process_type_list"...
Adds a single subprocess to this process. :param string name: name of the subprocess :param proc: a Process object :type proc: :class:`~climlab.process.process.Process` :raises: :exc:`ValueError` if ``proc`` is not a process ...
[ "Adds", "a", "single", "subprocess", "to", "this", "process", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L212-L282
7,645
brian-rose/climlab
climlab/process/process.py
Process.remove_subprocess
def remove_subprocess(self, name, verbose=True): """Removes a single subprocess from this process. :param string name: name of the subprocess :param bool verbose: information whether warning message should be printed [default: True] :Example: ...
python
def remove_subprocess(self, name, verbose=True): """Removes a single subprocess from this process. :param string name: name of the subprocess :param bool verbose: information whether warning message should be printed [default: True] :Example: ...
[ "def", "remove_subprocess", "(", "self", ",", "name", ",", "verbose", "=", "True", ")", ":", "try", ":", "self", ".", "subprocess", ".", "pop", "(", "name", ")", "except", "KeyError", ":", "if", "verbose", ":", "print", "(", "'WARNING: {} not found in subp...
Removes a single subprocess from this process. :param string name: name of the subprocess :param bool verbose: information whether warning message should be printed [default: True] :Example: Remove albedo subprocess from energy balance model:...
[ "Removes", "a", "single", "subprocess", "from", "this", "process", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L284-L330
7,646
brian-rose/climlab
climlab/process/process.py
Process.set_state
def set_state(self, name, value): """Sets the variable ``name`` to a new state ``value``. :param string name: name of the state :param value: state variable :type value: :class:`~climlab.domain.field.Field` or *array* :raises: :exc:`ValueError` ...
python
def set_state(self, name, value): """Sets the variable ``name`` to a new state ``value``. :param string name: name of the state :param value: state variable :type value: :class:`~climlab.domain.field.Field` or *array* :raises: :exc:`ValueError` ...
[ "def", "set_state", "(", "self", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Field", ")", ":", "# populate domains dictionary with domains from state variables", "self", ".", "domains", ".", "update", "(", "{", "name", ":", "va...
Sets the variable ``name`` to a new state ``value``. :param string name: name of the state :param value: state variable :type value: :class:`~climlab.domain.field.Field` or *array* :raises: :exc:`ValueError` if state variable ``va...
[ "Sets", "the", "variable", "name", "to", "a", "new", "state", "value", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L332-L387
7,647
brian-rose/climlab
climlab/process/process.py
Process._add_field
def _add_field(self, field_type, name, value): """Adds a new field to a specified dictionary. The field is also added as a process attribute. field_type can be 'input', 'diagnostics' """ try: self.__getattribute__(field_type).update({name: value}) except: raise Va...
python
def _add_field(self, field_type, name, value): """Adds a new field to a specified dictionary. The field is also added as a process attribute. field_type can be 'input', 'diagnostics' """ try: self.__getattribute__(field_type).update({name: value}) except: raise Va...
[ "def", "_add_field", "(", "self", ",", "field_type", ",", "name", ",", "value", ")", ":", "try", ":", "self", ".", "__getattribute__", "(", "field_type", ")", ".", "update", "(", "{", "name", ":", "value", "}", ")", "except", ":", "raise", "ValueError"...
Adds a new field to a specified dictionary. The field is also added as a process attribute. field_type can be 'input', 'diagnostics'
[ "Adds", "a", "new", "field", "to", "a", "specified", "dictionary", ".", "The", "field", "is", "also", "added", "as", "a", "process", "attribute", ".", "field_type", "can", "be", "input", "diagnostics" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L396-L405
7,648
brian-rose/climlab
climlab/process/process.py
Process.add_diagnostic
def add_diagnostic(self, name, value=None): """Create a new diagnostic variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the diagnostics...
python
def add_diagnostic(self, name, value=None): """Create a new diagnostic variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the diagnostics...
[ "def", "add_diagnostic", "(", "self", ",", "name", ",", "value", "=", "None", ")", ":", "self", ".", "_diag_vars", ".", "append", "(", "name", ")", "self", ".", "__setattr__", "(", "name", ",", "value", ")" ]
Create a new diagnostic variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the diagnostics dictionary, i.e. ``proc.diagnostics['nam...
[ "Create", "a", "new", "diagnostic", "variable", "called", "name", "for", "this", "process", "and", "initialize", "it", "with", "the", "given", "value", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L407-L441
7,649
brian-rose/climlab
climlab/process/process.py
Process.add_input
def add_input(self, name, value=None): '''Create a new input variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the input dictionary, ...
python
def add_input(self, name, value=None): '''Create a new input variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the input dictionary, ...
[ "def", "add_input", "(", "self", ",", "name", ",", "value", "=", "None", ")", ":", "self", ".", "_input_vars", ".", "append", "(", "name", ")", "self", ".", "__setattr__", "(", "name", ",", "value", ")" ]
Create a new input variable called ``name`` for this process and initialize it with the given ``value``. Quantity is accessible in two ways: * as a process attribute, i.e. ``proc.name`` * as a member of the input dictionary, i.e. ``proc.input['name']`` Us...
[ "Create", "a", "new", "input", "variable", "called", "name", "for", "this", "process", "and", "initialize", "it", "with", "the", "given", "value", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L443-L460
7,650
brian-rose/climlab
climlab/process/process.py
Process.remove_diagnostic
def remove_diagnostic(self, name): """ Removes a diagnostic from the ``process.diagnostic`` dictionary and also delete the associated process attribute. :param str name: name of diagnostic quantity to be removed :Example: Remove diagnostic variable 'icelat' from energy ...
python
def remove_diagnostic(self, name): """ Removes a diagnostic from the ``process.diagnostic`` dictionary and also delete the associated process attribute. :param str name: name of diagnostic quantity to be removed :Example: Remove diagnostic variable 'icelat' from energy ...
[ "def", "remove_diagnostic", "(", "self", ",", "name", ")", ":", "#_ = self.diagnostics.pop(name)", "#delattr(type(self), name)", "try", ":", "delattr", "(", "self", ",", "name", ")", "self", ".", "_diag_vars", ".", "remove", "(", "name", ")", "except", ":", "p...
Removes a diagnostic from the ``process.diagnostic`` dictionary and also delete the associated process attribute. :param str name: name of diagnostic quantity to be removed :Example: Remove diagnostic variable 'icelat' from energy balance model:: >>> import cli...
[ "Removes", "a", "diagnostic", "from", "the", "process", ".", "diagnostic", "dictionary", "and", "also", "delete", "the", "associated", "process", "attribute", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L472-L503
7,651
brian-rose/climlab
climlab/process/process.py
Process.to_xarray
def to_xarray(self, diagnostics=False): """ Convert process variables to ``xarray.Dataset`` format. With ``diagnostics=True``, both state and diagnostic variables are included. Otherwise just the state variables are included. Returns an ``xarray.Dataset`` object with all spatial axes,...
python
def to_xarray(self, diagnostics=False): """ Convert process variables to ``xarray.Dataset`` format. With ``diagnostics=True``, both state and diagnostic variables are included. Otherwise just the state variables are included. Returns an ``xarray.Dataset`` object with all spatial axes,...
[ "def", "to_xarray", "(", "self", ",", "diagnostics", "=", "False", ")", ":", "if", "diagnostics", ":", "dic", "=", "self", ".", "state", ".", "copy", "(", ")", "dic", ".", "update", "(", "self", ".", "diagnostics", ")", "return", "state_to_xarray", "("...
Convert process variables to ``xarray.Dataset`` format. With ``diagnostics=True``, both state and diagnostic variables are included. Otherwise just the state variables are included. Returns an ``xarray.Dataset`` object with all spatial axes, including 'bounds' axes indicating cell bou...
[ "Convert", "process", "variables", "to", "xarray", ".", "Dataset", "format", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L505-L583
7,652
brian-rose/climlab
climlab/process/process.py
Process.diagnostics
def diagnostics(self): """Dictionary access to all diagnostic variables :type: dict """ diag_dict = {} for key in self._diag_vars: try: #diag_dict[key] = getattr(self,key) # using self.__dict__ doesn't count diagnostics defined ...
python
def diagnostics(self): """Dictionary access to all diagnostic variables :type: dict """ diag_dict = {} for key in self._diag_vars: try: #diag_dict[key] = getattr(self,key) # using self.__dict__ doesn't count diagnostics defined ...
[ "def", "diagnostics", "(", "self", ")", ":", "diag_dict", "=", "{", "}", "for", "key", "in", "self", ".", "_diag_vars", ":", "try", ":", "#diag_dict[key] = getattr(self,key)", "# using self.__dict__ doesn't count diagnostics defined as properties", "diag_dict", "[", "k...
Dictionary access to all diagnostic variables :type: dict
[ "Dictionary", "access", "to", "all", "diagnostic", "variables" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L586-L600
7,653
brian-rose/climlab
climlab/process/process.py
Process.input
def input(self): """Dictionary access to all input variables That can be boundary conditions and other gridded quantities independent of the `process` :type: dict """ input_dict = {} for key in self._input_vars: try: input_dict[...
python
def input(self): """Dictionary access to all input variables That can be boundary conditions and other gridded quantities independent of the `process` :type: dict """ input_dict = {} for key in self._input_vars: try: input_dict[...
[ "def", "input", "(", "self", ")", ":", "input_dict", "=", "{", "}", "for", "key", "in", "self", ".", "_input_vars", ":", "try", ":", "input_dict", "[", "key", "]", "=", "getattr", "(", "self", ",", "key", ")", "except", ":", "pass", "return", "inpu...
Dictionary access to all input variables That can be boundary conditions and other gridded quantities independent of the `process` :type: dict
[ "Dictionary", "access", "to", "all", "input", "variables" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/process.py#L602-L617
7,654
brian-rose/climlab
climlab/solar/orbital/table.py
_get_Berger_data
def _get_Berger_data(verbose=True): '''Read in the Berger and Loutre orbital table as a pandas dataframe, convert to xarray ''' # The first column of the data file is used as the row index, and represents kyr from present orbit91_pd, path = load_data_source(local_path = local_path, r...
python
def _get_Berger_data(verbose=True): '''Read in the Berger and Loutre orbital table as a pandas dataframe, convert to xarray ''' # The first column of the data file is used as the row index, and represents kyr from present orbit91_pd, path = load_data_source(local_path = local_path, r...
[ "def", "_get_Berger_data", "(", "verbose", "=", "True", ")", ":", "# The first column of the data file is used as the row index, and represents kyr from present", "orbit91_pd", ",", "path", "=", "load_data_source", "(", "local_path", "=", "local_path", ",", "remote_source_list"...
Read in the Berger and Loutre orbital table as a pandas dataframe, convert to xarray
[ "Read", "in", "the", "Berger", "and", "Loutre", "orbital", "table", "as", "a", "pandas", "dataframe", "convert", "to", "xarray" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/solar/orbital/table.py#L14-L36
7,655
brian-rose/climlab
climlab/utils/data_source.py
load_data_source
def load_data_source(local_path, remote_source_list, open_method, open_method_kwargs=dict(), remote_kwargs=dict(), verbose=True): '''Flexible data retreiver to download and cache the data files locally. Usage example (this makes a local...
python
def load_data_source(local_path, remote_source_list, open_method, open_method_kwargs=dict(), remote_kwargs=dict(), verbose=True): '''Flexible data retreiver to download and cache the data files locally. Usage example (this makes a local...
[ "def", "load_data_source", "(", "local_path", ",", "remote_source_list", ",", "open_method", ",", "open_method_kwargs", "=", "dict", "(", ")", ",", "remote_kwargs", "=", "dict", "(", ")", ",", "verbose", "=", "True", ")", ":", "try", ":", "path", "=", "loc...
Flexible data retreiver to download and cache the data files locally. Usage example (this makes a local copy of the ozone data file): :Example: .. code-block:: python from climlab.utils.data_source import load_data_source from xarray import open_dataset ozonename ...
[ "Flexible", "data", "retreiver", "to", "download", "and", "cache", "the", "data", "files", "locally", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/data_source.py#L4-L84
7,656
brian-rose/climlab
climlab/radiation/transmissivity.py
tril
def tril(array, k=0): '''Lower triangle of an array. Return a copy of an array with elements above the k-th diagonal zeroed. Need a multi-dimensional version here because numpy.tril does not broadcast for numpy verison < 1.9.''' try: tril_array = np.tril(array, k=k) except: # hav...
python
def tril(array, k=0): '''Lower triangle of an array. Return a copy of an array with elements above the k-th diagonal zeroed. Need a multi-dimensional version here because numpy.tril does not broadcast for numpy verison < 1.9.''' try: tril_array = np.tril(array, k=k) except: # hav...
[ "def", "tril", "(", "array", ",", "k", "=", "0", ")", ":", "try", ":", "tril_array", "=", "np", ".", "tril", "(", "array", ",", "k", "=", "k", ")", "except", ":", "# have to loop", "tril_array", "=", "np", ".", "zeros_like", "(", "array", ")", "s...
Lower triangle of an array. Return a copy of an array with elements above the k-th diagonal zeroed. Need a multi-dimensional version here because numpy.tril does not broadcast for numpy verison < 1.9.
[ "Lower", "triangle", "of", "an", "array", ".", "Return", "a", "copy", "of", "an", "array", "with", "elements", "above", "the", "k", "-", "th", "diagonal", "zeroed", ".", "Need", "a", "multi", "-", "dimensional", "version", "here", "because", "numpy", "."...
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/transmissivity.py#L209-L223
7,657
brian-rose/climlab
climlab/radiation/transmissivity.py
Transmissivity.flux_up
def flux_up(self, fluxUpBottom, emission=None): '''Compute downwelling radiative flux at interfaces between layers. Inputs: * fluxDownTop: flux down at top * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: ...
python
def flux_up(self, fluxUpBottom, emission=None): '''Compute downwelling radiative flux at interfaces between layers. Inputs: * fluxDownTop: flux down at top * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: ...
[ "def", "flux_up", "(", "self", ",", "fluxUpBottom", ",", "emission", "=", "None", ")", ":", "if", "emission", "is", "None", ":", "emission", "=", "np", ".", "zeros_like", "(", "self", ".", "absorptivity", ")", "E", "=", "np", ".", "concatenate", "(", ...
Compute downwelling radiative flux at interfaces between layers. Inputs: * fluxDownTop: flux down at top * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: * vector of downwelling radiative flux between levels (N+...
[ "Compute", "downwelling", "radiative", "flux", "at", "interfaces", "between", "layers", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/transmissivity.py#L121-L140
7,658
brian-rose/climlab
climlab/radiation/transmissivity.py
Transmissivity.flux_down
def flux_down(self, fluxDownTop, emission=None): '''Compute upwelling radiative flux at interfaces between layers. Inputs: * fluxUpBottom: flux up from bottom * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: ...
python
def flux_down(self, fluxDownTop, emission=None): '''Compute upwelling radiative flux at interfaces between layers. Inputs: * fluxUpBottom: flux up from bottom * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: ...
[ "def", "flux_down", "(", "self", ",", "fluxDownTop", ",", "emission", "=", "None", ")", ":", "if", "emission", "is", "None", ":", "emission", "=", "np", ".", "zeros_like", "(", "self", ".", "absorptivity", ")", "E", "=", "np", ".", "concatenate", "(", ...
Compute upwelling radiative flux at interfaces between layers. Inputs: * fluxUpBottom: flux up from bottom * emission: emission from atmospheric levels (N) defaults to zero if not given Returns: * vector of upwelling radiative flux between levels (N+1...
[ "Compute", "upwelling", "radiative", "flux", "at", "interfaces", "between", "layers", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/transmissivity.py#L149-L167
7,659
brian-rose/climlab
climlab/radiation/rrtm/rrtmg_lw.py
RRTMG_LW._compute_heating_rates
def _compute_heating_rates(self): '''Prepare arguments and call the RRTGM_LW driver to calculate radiative fluxes and heating rates''' (ncol, nlay, icld, permuteseed, irng, idrv, cp, play, plev, tlay, tlev, tsfc, h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr, ...
python
def _compute_heating_rates(self): '''Prepare arguments and call the RRTGM_LW driver to calculate radiative fluxes and heating rates''' (ncol, nlay, icld, permuteseed, irng, idrv, cp, play, plev, tlay, tlev, tsfc, h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr, ...
[ "def", "_compute_heating_rates", "(", "self", ")", ":", "(", "ncol", ",", "nlay", ",", "icld", ",", "permuteseed", ",", "irng", ",", "idrv", ",", "cp", ",", "play", ",", "plev", ",", "tlay", ",", "tlev", ",", "tsfc", ",", "h2ovmr", ",", "o3vmr", ",...
Prepare arguments and call the RRTGM_LW driver to calculate radiative fluxes and heating rates
[ "Prepare", "arguments", "and", "call", "the", "RRTGM_LW", "driver", "to", "calculate", "radiative", "fluxes", "and", "heating", "rates" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/rrtm/rrtmg_lw.py#L79-L126
7,660
brian-rose/climlab
climlab/radiation/rrtm/utils.py
_prepare_general_arguments
def _prepare_general_arguments(RRTMGobject): '''Prepare arguments needed for both RRTMG_SW and RRTMG_LW with correct dimensions.''' tlay = _climlab_to_rrtm(RRTMGobject.Tatm) tlev = _climlab_to_rrtm(interface_temperature(**RRTMGobject.state)) play = _climlab_to_rrtm(RRTMGobject.lev * np.ones_like(tlay)) ...
python
def _prepare_general_arguments(RRTMGobject): '''Prepare arguments needed for both RRTMG_SW and RRTMG_LW with correct dimensions.''' tlay = _climlab_to_rrtm(RRTMGobject.Tatm) tlev = _climlab_to_rrtm(interface_temperature(**RRTMGobject.state)) play = _climlab_to_rrtm(RRTMGobject.lev * np.ones_like(tlay)) ...
[ "def", "_prepare_general_arguments", "(", "RRTMGobject", ")", ":", "tlay", "=", "_climlab_to_rrtm", "(", "RRTMGobject", ".", "Tatm", ")", "tlev", "=", "_climlab_to_rrtm", "(", "interface_temperature", "(", "*", "*", "RRTMGobject", ".", "state", ")", ")", "play",...
Prepare arguments needed for both RRTMG_SW and RRTMG_LW with correct dimensions.
[ "Prepare", "arguments", "needed", "for", "both", "RRTMG_SW", "and", "RRTMG_LW", "with", "correct", "dimensions", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/rrtm/utils.py#L7-L37
7,661
brian-rose/climlab
climlab/radiation/rrtm/utils.py
interface_temperature
def interface_temperature(Ts, Tatm, **kwargs): '''Compute temperature at model layer interfaces.''' # Actually it's not clear to me how the RRTM code uses these values lev = Tatm.domain.axes['lev'].points lev_bounds = Tatm.domain.axes['lev'].bounds # Interpolate to layer interfaces f = interp1...
python
def interface_temperature(Ts, Tatm, **kwargs): '''Compute temperature at model layer interfaces.''' # Actually it's not clear to me how the RRTM code uses these values lev = Tatm.domain.axes['lev'].points lev_bounds = Tatm.domain.axes['lev'].bounds # Interpolate to layer interfaces f = interp1...
[ "def", "interface_temperature", "(", "Ts", ",", "Tatm", ",", "*", "*", "kwargs", ")", ":", "# Actually it's not clear to me how the RRTM code uses these values", "lev", "=", "Tatm", ".", "domain", ".", "axes", "[", "'lev'", "]", ".", "points", "lev_bounds", "=", ...
Compute temperature at model layer interfaces.
[ "Compute", "temperature", "at", "model", "layer", "interfaces", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/rrtm/utils.py#L41-L52
7,662
brian-rose/climlab
climlab/dynamics/meridional_moist_diffusion.py
moist_amplification_factor
def moist_amplification_factor(Tkelvin, relative_humidity=0.8): '''Compute the moisture amplification factor for the moist diffusivity given relative humidity and reference temperature profile.''' deltaT = 0.01 # slope of saturation specific humidity at 1000 hPa dqsdTs = (qsat(Tkelvin+deltaT/2, 100...
python
def moist_amplification_factor(Tkelvin, relative_humidity=0.8): '''Compute the moisture amplification factor for the moist diffusivity given relative humidity and reference temperature profile.''' deltaT = 0.01 # slope of saturation specific humidity at 1000 hPa dqsdTs = (qsat(Tkelvin+deltaT/2, 100...
[ "def", "moist_amplification_factor", "(", "Tkelvin", ",", "relative_humidity", "=", "0.8", ")", ":", "deltaT", "=", "0.01", "# slope of saturation specific humidity at 1000 hPa", "dqsdTs", "=", "(", "qsat", "(", "Tkelvin", "+", "deltaT", "/", "2", ",", "1000.", "...
Compute the moisture amplification factor for the moist diffusivity given relative humidity and reference temperature profile.
[ "Compute", "the", "moisture", "amplification", "factor", "for", "the", "moist", "diffusivity", "given", "relative", "humidity", "and", "reference", "temperature", "profile", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/meridional_moist_diffusion.py#L145-L151
7,663
brian-rose/climlab
climlab/solar/insolation.py
daily_insolation
def daily_insolation(lat, day, orb=const.orb_present, S0=const.S0, day_type=1): """Compute daily average insolation given latitude, time of year and orbital parameters. Orbital parameters can be interpolated to any time in the last 5 Myears with ``climlab.solar.orbital.OrbitalTable`` (see example above). ...
python
def daily_insolation(lat, day, orb=const.orb_present, S0=const.S0, day_type=1): """Compute daily average insolation given latitude, time of year and orbital parameters. Orbital parameters can be interpolated to any time in the last 5 Myears with ``climlab.solar.orbital.OrbitalTable`` (see example above). ...
[ "def", "daily_insolation", "(", "lat", ",", "day", ",", "orb", "=", "const", ".", "orb_present", ",", "S0", "=", "const", ".", "S0", ",", "day_type", "=", "1", ")", ":", "# Inputs can be scalar, numpy vector, or xarray.DataArray.", "# If numpy, convert to xarray so...
Compute daily average insolation given latitude, time of year and orbital parameters. Orbital parameters can be interpolated to any time in the last 5 Myears with ``climlab.solar.orbital.OrbitalTable`` (see example above). Longer orbital tables are available with ``climlab.solar.orbital.LongOrbitalTable``...
[ "Compute", "daily", "average", "insolation", "given", "latitude", "time", "of", "year", "and", "orbital", "parameters", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/solar/insolation.py#L46-L160
7,664
brian-rose/climlab
climlab/solar/insolation.py
solar_longitude
def solar_longitude( day, orb=const.orb_present, days_per_year = None ): """Estimates solar longitude from calendar day. Method is using an approximation from :cite:`Berger_1978` section 3 (lambda = 0 at spring equinox). **Function-call arguments** \n :param array day: Indicator of time...
python
def solar_longitude( day, orb=const.orb_present, days_per_year = None ): """Estimates solar longitude from calendar day. Method is using an approximation from :cite:`Berger_1978` section 3 (lambda = 0 at spring equinox). **Function-call arguments** \n :param array day: Indicator of time...
[ "def", "solar_longitude", "(", "day", ",", "orb", "=", "const", ".", "orb_present", ",", "days_per_year", "=", "None", ")", ":", "if", "days_per_year", "is", "None", ":", "days_per_year", "=", "const", ".", "days_per_year", "ecc", "=", "orb", "[", "'ecc'",...
Estimates solar longitude from calendar day. Method is using an approximation from :cite:`Berger_1978` section 3 (lambda = 0 at spring equinox). **Function-call arguments** \n :param array day: Indicator of time of year. :param dict orb: a dictionary with three members (as pr...
[ "Estimates", "solar", "longitude", "from", "calendar", "day", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/solar/insolation.py#L163-L215
7,665
brian-rose/climlab
climlab/domain/domain.py
single_column
def single_column(num_lev=30, water_depth=1., lev=None, **kwargs): """Creates domains for a single column of atmosphere overlying a slab of water. Can also pass a pressure array or pressure level axis object specified in ``lev``. If argument ``lev`` is not ``None`` then function tries to build a level axi...
python
def single_column(num_lev=30, water_depth=1., lev=None, **kwargs): """Creates domains for a single column of atmosphere overlying a slab of water. Can also pass a pressure array or pressure level axis object specified in ``lev``. If argument ``lev`` is not ``None`` then function tries to build a level axi...
[ "def", "single_column", "(", "num_lev", "=", "30", ",", "water_depth", "=", "1.", ",", "lev", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "lev", "is", "None", ":", "levax", "=", "Axis", "(", "axis_type", "=", "'lev'", ",", "num_points", "...
Creates domains for a single column of atmosphere overlying a slab of water. Can also pass a pressure array or pressure level axis object specified in ``lev``. If argument ``lev`` is not ``None`` then function tries to build a level axis and ``num_lev`` is ignored. **Function-call argument** \n ...
[ "Creates", "domains", "for", "a", "single", "column", "of", "atmosphere", "overlying", "a", "slab", "of", "water", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/domain.py#L411-L458
7,666
brian-rose/climlab
climlab/domain/domain.py
zonal_mean_surface
def zonal_mean_surface(num_lat=90, water_depth=10., lat=None, **kwargs): """Creates a 1D slab ocean Domain in latitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param int num_lat: number of latitude point...
python
def zonal_mean_surface(num_lat=90, water_depth=10., lat=None, **kwargs): """Creates a 1D slab ocean Domain in latitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param int num_lat: number of latitude point...
[ "def", "zonal_mean_surface", "(", "num_lat", "=", "90", ",", "water_depth", "=", "10.", ",", "lat", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "lat", "is", "None", ":", "latax", "=", "Axis", "(", "axis_type", "=", "'lat'", ",", "num_points...
Creates a 1D slab ocean Domain in latitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param int num_lat: number of latitude points [default: 90] :param float water_depth: depth of the slab ocean in meter...
[ "Creates", "a", "1D", "slab", "ocean", "Domain", "in", "latitude", "with", "uniform", "water", "depth", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/domain.py#L461-L499
7,667
brian-rose/climlab
climlab/domain/domain.py
surface_2D
def surface_2D(num_lat=90, num_lon=180, water_depth=10., lon=None, lat=None, **kwargs): """Creates a 2D slab ocean Domain in latitude and longitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param i...
python
def surface_2D(num_lat=90, num_lon=180, water_depth=10., lon=None, lat=None, **kwargs): """Creates a 2D slab ocean Domain in latitude and longitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param i...
[ "def", "surface_2D", "(", "num_lat", "=", "90", ",", "num_lon", "=", "180", ",", "water_depth", "=", "10.", ",", "lon", "=", "None", ",", "lat", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "lat", "is", "None", ":", "latax", "=", "Axis",...
Creates a 2D slab ocean Domain in latitude and longitude with uniform water depth. Domain has a single heat capacity according to the specified water depth. **Function-call argument** \n :param int num_lat: number of latitude points [default: 90] :param int num_lon: number of longitud...
[ "Creates", "a", "2D", "slab", "ocean", "Domain", "in", "latitude", "and", "longitude", "with", "uniform", "water", "depth", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/domain.py#L501-L553
7,668
brian-rose/climlab
climlab/domain/domain.py
_Domain._make_axes_dict
def _make_axes_dict(self, axes): """Makes an axes dictionary. .. note:: In case the input is ``None``, the dictionary :code:`{'empty': None}` is returned. **Function-call argument** \n :param axes: axes input :type axes: dict or single instance ...
python
def _make_axes_dict(self, axes): """Makes an axes dictionary. .. note:: In case the input is ``None``, the dictionary :code:`{'empty': None}` is returned. **Function-call argument** \n :param axes: axes input :type axes: dict or single instance ...
[ "def", "_make_axes_dict", "(", "self", ",", "axes", ")", ":", "if", "type", "(", "axes", ")", "is", "dict", ":", "axdict", "=", "axes", "elif", "type", "(", "axes", ")", "is", "Axis", ":", "ax", "=", "axes", "axdict", "=", "{", "ax", ".", "axis_t...
Makes an axes dictionary. .. note:: In case the input is ``None``, the dictionary :code:`{'empty': None}` is returned. **Function-call argument** \n :param axes: axes input :type axes: dict or single instance of :class:`~climlab....
[ "Makes", "an", "axes", "dictionary", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/domain.py#L129-L157
7,669
brian-rose/climlab
climlab/process/implicit.py
ImplicitProcess._compute
def _compute(self): """Computes the state variable tendencies in time for implicit processes. To calculate the new state the :func:`_implicit_solver()` method is called for daughter classes. This however returns the new state of the variables, not just the tendencies. Therefore, the adj...
python
def _compute(self): """Computes the state variable tendencies in time for implicit processes. To calculate the new state the :func:`_implicit_solver()` method is called for daughter classes. This however returns the new state of the variables, not just the tendencies. Therefore, the adj...
[ "def", "_compute", "(", "self", ")", ":", "newstate", "=", "self", ".", "_implicit_solver", "(", ")", "adjustment", "=", "{", "}", "tendencies", "=", "{", "}", "for", "name", ",", "var", "in", "self", ".", "state", ".", "items", "(", ")", ":", "adj...
Computes the state variable tendencies in time for implicit processes. To calculate the new state the :func:`_implicit_solver()` method is called for daughter classes. This however returns the new state of the variables, not just the tendencies. Therefore, the adjustment is calculated w...
[ "Computes", "the", "state", "variable", "tendencies", "in", "time", "for", "implicit", "processes", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/implicit.py#L23-L57
7,670
brian-rose/climlab
climlab/utils/walk.py
walk_processes
def walk_processes(top, topname='top', topdown=True, ignoreFlag=False): """Generator for recursive tree of climlab processes Starts walking from climlab process ``top`` and generates a complete list of all processes and sub-processes that are managed from ``top`` process. ``level`` indicades the rank o...
python
def walk_processes(top, topname='top', topdown=True, ignoreFlag=False): """Generator for recursive tree of climlab processes Starts walking from climlab process ``top`` and generates a complete list of all processes and sub-processes that are managed from ``top`` process. ``level`` indicades the rank o...
[ "def", "walk_processes", "(", "top", ",", "topname", "=", "'top'", ",", "topdown", "=", "True", ",", "ignoreFlag", "=", "False", ")", ":", "if", "not", "ignoreFlag", ":", "flag", "=", "topdown", "else", ":", "flag", "=", "True", "proc", "=", "top", "...
Generator for recursive tree of climlab processes Starts walking from climlab process ``top`` and generates a complete list of all processes and sub-processes that are managed from ``top`` process. ``level`` indicades the rank of specific process in the process hierarchy: .. note:: * level 0:...
[ "Generator", "for", "recursive", "tree", "of", "climlab", "processes" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/walk.py#L3-L71
7,671
brian-rose/climlab
climlab/utils/walk.py
process_tree
def process_tree(top, name='top'): """Creates a string representation of the process tree for process top. This method uses the :func:`walk_processes` method to create the process tree. :param top: top process for which process tree string should be created :typ...
python
def process_tree(top, name='top'): """Creates a string representation of the process tree for process top. This method uses the :func:`walk_processes` method to create the process tree. :param top: top process for which process tree string should be created :typ...
[ "def", "process_tree", "(", "top", ",", "name", "=", "'top'", ")", ":", "str1", "=", "''", "for", "name", ",", "proc", ",", "level", "in", "walk_processes", "(", "top", ",", "name", ",", "ignoreFlag", "=", "True", ")", ":", "indent", "=", "' '", "*...
Creates a string representation of the process tree for process top. This method uses the :func:`walk_processes` method to create the process tree. :param top: top process for which process tree string should be created :type top: :class:`~climlab.proce...
[ "Creates", "a", "string", "representation", "of", "the", "process", "tree", "for", "process", "top", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/walk.py#L74-L111
7,672
brian-rose/climlab
climlab/radiation/greygas.py
GreyGas._compute_fluxes
def _compute_fluxes(self): ''' All fluxes are band by band''' self.emission = self._compute_emission() self.emission_sfc = self._compute_emission_sfc() fromspace = self._from_space() self.flux_down = self.trans.flux_down(fromspace, self.emission) self.flux_reflected_up = ...
python
def _compute_fluxes(self): ''' All fluxes are band by band''' self.emission = self._compute_emission() self.emission_sfc = self._compute_emission_sfc() fromspace = self._from_space() self.flux_down = self.trans.flux_down(fromspace, self.emission) self.flux_reflected_up = ...
[ "def", "_compute_fluxes", "(", "self", ")", ":", "self", ".", "emission", "=", "self", ".", "_compute_emission", "(", ")", "self", ".", "emission_sfc", "=", "self", ".", "_compute_emission_sfc", "(", ")", "fromspace", "=", "self", ".", "_from_space", "(", ...
All fluxes are band by band
[ "All", "fluxes", "are", "band", "by", "band" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/greygas.py#L129-L146
7,673
brian-rose/climlab
climlab/radiation/greygas.py
GreyGas.flux_components_top
def flux_components_top(self): '''Compute the contributions to the outgoing flux to space due to emissions from each level and the surface.''' N = self.lev.size flux_up_bottom = self.flux_from_sfc emission = np.zeros_like(self.emission) this_flux_up = (np.ones_like(self.T...
python
def flux_components_top(self): '''Compute the contributions to the outgoing flux to space due to emissions from each level and the surface.''' N = self.lev.size flux_up_bottom = self.flux_from_sfc emission = np.zeros_like(self.emission) this_flux_up = (np.ones_like(self.T...
[ "def", "flux_components_top", "(", "self", ")", ":", "N", "=", "self", ".", "lev", ".", "size", "flux_up_bottom", "=", "self", ".", "flux_from_sfc", "emission", "=", "np", ".", "zeros_like", "(", "self", ".", "emission", ")", "this_flux_up", "=", "(", "n...
Compute the contributions to the outgoing flux to space due to emissions from each level and the surface.
[ "Compute", "the", "contributions", "to", "the", "outgoing", "flux", "to", "space", "due", "to", "emissions", "from", "each", "level", "and", "the", "surface", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/greygas.py#L185-L204
7,674
brian-rose/climlab
climlab/radiation/greygas.py
GreyGas.flux_components_bottom
def flux_components_bottom(self): '''Compute the contributions to the downwelling flux to surface due to emissions from each level.''' N = self.lev.size atmComponents = np.zeros_like(self.Tatm) flux_down_top = np.zeros_like(self.Ts) # same comment as above... would be ni...
python
def flux_components_bottom(self): '''Compute the contributions to the downwelling flux to surface due to emissions from each level.''' N = self.lev.size atmComponents = np.zeros_like(self.Tatm) flux_down_top = np.zeros_like(self.Ts) # same comment as above... would be ni...
[ "def", "flux_components_bottom", "(", "self", ")", ":", "N", "=", "self", ".", "lev", ".", "size", "atmComponents", "=", "np", ".", "zeros_like", "(", "self", ".", "Tatm", ")", "flux_down_top", "=", "np", ".", "zeros_like", "(", "self", ".", "Ts", ")",...
Compute the contributions to the downwelling flux to surface due to emissions from each level.
[ "Compute", "the", "contributions", "to", "the", "downwelling", "flux", "to", "surface", "due", "to", "emissions", "from", "each", "level", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/greygas.py#L206-L218
7,675
brian-rose/climlab
climlab/surface/turbulent.py
LatentHeatFlux._compute
def _compute(self): '''Overides the _compute method of EnergyBudget''' tendencies = self._temperature_tendencies() if 'q' in self.state: # in a model with active water vapor, this flux should affect # water vapor tendency, NOT air temperature tendency! tenden...
python
def _compute(self): '''Overides the _compute method of EnergyBudget''' tendencies = self._temperature_tendencies() if 'q' in self.state: # in a model with active water vapor, this flux should affect # water vapor tendency, NOT air temperature tendency! tenden...
[ "def", "_compute", "(", "self", ")", ":", "tendencies", "=", "self", ".", "_temperature_tendencies", "(", ")", "if", "'q'", "in", "self", ".", "state", ":", "# in a model with active water vapor, this flux should affect", "# water vapor tendency, NOT air temperature tenden...
Overides the _compute method of EnergyBudget
[ "Overides", "the", "_compute", "method", "of", "EnergyBudget" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/surface/turbulent.py#L187-L199
7,676
brian-rose/climlab
climlab/utils/legendre.py
Pn
def Pn(x): """Calculate Legendre polyomials P0 to P28 and returns them in a dictionary ``Pn``. :param float x: argument to calculate Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (from 0 to 28) as keys and the corresponding ...
python
def Pn(x): """Calculate Legendre polyomials P0 to P28 and returns them in a dictionary ``Pn``. :param float x: argument to calculate Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (from 0 to 28) as keys and the corresponding ...
[ "def", "Pn", "(", "x", ")", ":", "Pn", "=", "{", "}", "Pn", "[", "'0'", "]", "=", "P0", "(", "x", ")", "Pn", "[", "'1'", "]", "=", "P1", "(", "x", ")", "Pn", "[", "'2'", "]", "=", "P2", "(", "x", ")", "Pn", "[", "'3'", "]", "=", "P3...
Calculate Legendre polyomials P0 to P28 and returns them in a dictionary ``Pn``. :param float x: argument to calculate Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (from 0 to 28) as keys and the corresponding evaluation ...
[ "Calculate", "Legendre", "polyomials", "P0", "to", "P28", "and", "returns", "them", "in", "a", "dictionary", "Pn", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/legendre.py#L6-L36
7,677
brian-rose/climlab
climlab/utils/legendre.py
Pnprime
def Pnprime(x): """Calculates first derivatives of Legendre polynomials and returns them in a dictionary ``Pnprime``. :param float x: argument to calculate first derivate of Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (fro...
python
def Pnprime(x): """Calculates first derivatives of Legendre polynomials and returns them in a dictionary ``Pnprime``. :param float x: argument to calculate first derivate of Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (fro...
[ "def", "Pnprime", "(", "x", ")", ":", "Pnprime", "=", "{", "}", "Pnprime", "[", "'0'", "]", "=", "0", "Pnprime", "[", "'1'", "]", "=", "P1prime", "(", "x", ")", "Pnprime", "[", "'2'", "]", "=", "P2prime", "(", "x", ")", "Pnprime", "[", "'3'", ...
Calculates first derivatives of Legendre polynomials and returns them in a dictionary ``Pnprime``. :param float x: argument to calculate first derivate of Legendre polynomials :return Pn: dictionary which contains order of Legendre polynomials (from 0 to 4 and even numbe...
[ "Calculates", "first", "derivatives", "of", "Legendre", "polynomials", "and", "returns", "them", "in", "a", "dictionary", "Pnprime", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/utils/legendre.py#L38-L61
7,678
brian-rose/climlab
climlab/model/ebm.py
EBM.inferred_heat_transport
def inferred_heat_transport(self): """Calculates the inferred heat transport by integrating the TOA energy imbalance from pole to pole. The method is calculating .. math:: H(\\varphi) = 2 \pi R^2 \int_{-\pi/2}^{\\varphi} cos\phi \ R_{TOA} d\phi where :math:`R_{TOA...
python
def inferred_heat_transport(self): """Calculates the inferred heat transport by integrating the TOA energy imbalance from pole to pole. The method is calculating .. math:: H(\\varphi) = 2 \pi R^2 \int_{-\pi/2}^{\\varphi} cos\phi \ R_{TOA} d\phi where :math:`R_{TOA...
[ "def", "inferred_heat_transport", "(", "self", ")", ":", "phi", "=", "np", ".", "deg2rad", "(", "self", ".", "lat", ")", "energy_in", "=", "np", ".", "squeeze", "(", "self", ".", "net_radiation", ")", "return", "(", "1E-15", "*", "2", "*", "np", ".",...
Calculates the inferred heat transport by integrating the TOA energy imbalance from pole to pole. The method is calculating .. math:: H(\\varphi) = 2 \pi R^2 \int_{-\pi/2}^{\\varphi} cos\phi \ R_{TOA} d\phi where :math:`R_{TOA}` is the net radiation at top of atmosphere. ...
[ "Calculates", "the", "inferred", "heat", "transport", "by", "integrating", "the", "TOA", "energy", "imbalance", "from", "pole", "to", "pole", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/model/ebm.py#L312-L337
7,679
brian-rose/climlab
climlab/radiation/rrtm/_rrtmg_lw/setup.py
rrtmg_lw_gen_source
def rrtmg_lw_gen_source(ext, build_dir): '''Add RRTMG_LW fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.''' thispath = config.local_path module_src = [] for item in modules: fullname = join(thispath,'rrtmg_lw_v4.85','gcm_model','mod...
python
def rrtmg_lw_gen_source(ext, build_dir): '''Add RRTMG_LW fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.''' thispath = config.local_path module_src = [] for item in modules: fullname = join(thispath,'rrtmg_lw_v4.85','gcm_model','mod...
[ "def", "rrtmg_lw_gen_source", "(", "ext", ",", "build_dir", ")", ":", "thispath", "=", "config", ".", "local_path", "module_src", "=", "[", "]", "for", "item", "in", "modules", ":", "fullname", "=", "join", "(", "thispath", ",", "'rrtmg_lw_v4.85'", ",", "'...
Add RRTMG_LW fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.
[ "Add", "RRTMG_LW", "fortran", "source", "if", "Fortran", "90", "compiler", "available", "if", "no", "compiler", "is", "found", "do", "not", "try", "to", "build", "the", "extension", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/rrtm/_rrtmg_lw/setup.py#L77-L98
7,680
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess.compute
def compute(self): """Computes the tendencies for all state variables given current state and specified input. The function first computes all diagnostic processes. They don't produce any tendencies directly but they may affect the other processes (such as change in solar distri...
python
def compute(self): """Computes the tendencies for all state variables given current state and specified input. The function first computes all diagnostic processes. They don't produce any tendencies directly but they may affect the other processes (such as change in solar distri...
[ "def", "compute", "(", "self", ")", ":", "# First reset tendencies to zero -- recomputing them is the point of this method", "for", "varname", "in", "self", ".", "tendencies", ":", "self", ".", "tendencies", "[", "varname", "]", "*=", "0.", "if", "not", "self", "."...
Computes the tendencies for all state variables given current state and specified input. The function first computes all diagnostic processes. They don't produce any tendencies directly but they may affect the other processes (such as change in solar distribution). Subsequently, all ten...
[ "Computes", "the", "tendencies", "for", "all", "state", "variables", "given", "current", "state", "and", "specified", "input", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L162-L243
7,681
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess._compute_type
def _compute_type(self, proctype): """Computes tendencies due to all subprocesses of given type ``'proctype'``. Also pass all diagnostics up to parent process.""" tendencies = {} for varname in self.state: tendencies[varname] = 0. * self.state[varname] for proc in sel...
python
def _compute_type(self, proctype): """Computes tendencies due to all subprocesses of given type ``'proctype'``. Also pass all diagnostics up to parent process.""" tendencies = {} for varname in self.state: tendencies[varname] = 0. * self.state[varname] for proc in sel...
[ "def", "_compute_type", "(", "self", ",", "proctype", ")", ":", "tendencies", "=", "{", "}", "for", "varname", "in", "self", ".", "state", ":", "tendencies", "[", "varname", "]", "=", "0.", "*", "self", ".", "state", "[", "varname", "]", "for", "proc...
Computes tendencies due to all subprocesses of given type ``'proctype'``. Also pass all diagnostics up to parent process.
[ "Computes", "tendencies", "due", "to", "all", "subprocesses", "of", "given", "type", "proctype", ".", "Also", "pass", "all", "diagnostics", "up", "to", "parent", "process", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L245-L270
7,682
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess._compute
def _compute(self): """Where the tendencies are actually computed... Needs to be implemented for each daughter class Returns a dictionary with same keys as self.state""" tendencies = {} for name, value in self.state.items(): tendencies[name] = value * 0. ret...
python
def _compute(self): """Where the tendencies are actually computed... Needs to be implemented for each daughter class Returns a dictionary with same keys as self.state""" tendencies = {} for name, value in self.state.items(): tendencies[name] = value * 0. ret...
[ "def", "_compute", "(", "self", ")", ":", "tendencies", "=", "{", "}", "for", "name", ",", "value", "in", "self", ".", "state", ".", "items", "(", ")", ":", "tendencies", "[", "name", "]", "=", "value", "*", "0.", "return", "tendencies" ]
Where the tendencies are actually computed... Needs to be implemented for each daughter class Returns a dictionary with same keys as self.state
[ "Where", "the", "tendencies", "are", "actually", "computed", "..." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L272-L281
7,683
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess._build_process_type_list
def _build_process_type_list(self): """Generates lists of processes organized by process type. Following object attributes are generated or updated: :ivar dict process_types: a dictionary with entries: ``'diagnostic'``, ``'explicit'``, ...
python
def _build_process_type_list(self): """Generates lists of processes organized by process type. Following object attributes are generated or updated: :ivar dict process_types: a dictionary with entries: ``'diagnostic'``, ``'explicit'``, ...
[ "def", "_build_process_type_list", "(", "self", ")", ":", "self", ".", "process_types", "=", "{", "'diagnostic'", ":", "[", "]", ",", "'explicit'", ":", "[", "]", ",", "'implicit'", ":", "[", "]", ",", "'adjustment'", ":", "[", "]", "}", "#for name, proc...
Generates lists of processes organized by process type. Following object attributes are generated or updated: :ivar dict process_types: a dictionary with entries: ``'diagnostic'``, ``'explicit'``, ``'implicit'`` and ``'adjustmen...
[ "Generates", "lists", "of", "processes", "organized", "by", "process", "type", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L283-L305
7,684
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess.step_forward
def step_forward(self): """Updates state variables with computed tendencies. Calls the :func:`compute` method to get current tendencies for all process states. Multiplied with the timestep and added up to the state variables is updating all model states. :Example: ...
python
def step_forward(self): """Updates state variables with computed tendencies. Calls the :func:`compute` method to get current tendencies for all process states. Multiplied with the timestep and added up to the state variables is updating all model states. :Example: ...
[ "def", "step_forward", "(", "self", ")", ":", "tenddict", "=", "self", ".", "compute", "(", ")", "# Total tendency is applied as an explicit forward timestep", "# (already accounting properly for order of operations in compute() )", "for", "varname", ",", "tend", "in", "tend...
Updates state variables with computed tendencies. Calls the :func:`compute` method to get current tendencies for all process states. Multiplied with the timestep and added up to the state variables is updating all model states. :Example: :: >>> import clim...
[ "Updates", "state", "variables", "with", "computed", "tendencies", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L307-L342
7,685
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess._update_time
def _update_time(self): """Increments the timestep counter by one. Furthermore ``self.time['days_elapsed']`` and ``self.time['num_steps_per_year']`` are updated. The function is called by the time stepping methods. """ self.time['steps'] += 1 # time in days sin...
python
def _update_time(self): """Increments the timestep counter by one. Furthermore ``self.time['days_elapsed']`` and ``self.time['num_steps_per_year']`` are updated. The function is called by the time stepping methods. """ self.time['steps'] += 1 # time in days sin...
[ "def", "_update_time", "(", "self", ")", ":", "self", ".", "time", "[", "'steps'", "]", "+=", "1", "# time in days since beginning", "self", ".", "time", "[", "'days_elapsed'", "]", "+=", "self", ".", "time", "[", "'timestep'", "]", "/", "const", ".", "s...
Increments the timestep counter by one. Furthermore ``self.time['days_elapsed']`` and ``self.time['num_steps_per_year']`` are updated. The function is called by the time stepping methods.
[ "Increments", "the", "timestep", "counter", "by", "one", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L354-L369
7,686
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess.integrate_years
def integrate_years(self, years=1.0, verbose=True): """Integrates the model by a given number of years. :param float years: integration time for the model in years [default: 1.0] :param bool verbose: information whether model time details ...
python
def integrate_years(self, years=1.0, verbose=True): """Integrates the model by a given number of years. :param float years: integration time for the model in years [default: 1.0] :param bool verbose: information whether model time details ...
[ "def", "integrate_years", "(", "self", ",", "years", "=", "1.0", ",", "verbose", "=", "True", ")", ":", "days", "=", "years", "*", "const", ".", "days_per_year", "numsteps", "=", "int", "(", "self", ".", "time", "[", "'num_steps_per_year'", "]", "*", "...
Integrates the model by a given number of years. :param float years: integration time for the model in years [default: 1.0] :param bool verbose: information whether model time details should be printed [default: True] It ca...
[ "Integrates", "the", "model", "by", "a", "given", "number", "of", "years", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L380-L449
7,687
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess.integrate_days
def integrate_days(self, days=1.0, verbose=True): """Integrates the model forward for a specified number of days. It convertes the given number of days into years and calls :func:`integrate_years`. :param float days: integration time for the model in days ...
python
def integrate_days(self, days=1.0, verbose=True): """Integrates the model forward for a specified number of days. It convertes the given number of days into years and calls :func:`integrate_years`. :param float days: integration time for the model in days ...
[ "def", "integrate_days", "(", "self", ",", "days", "=", "1.0", ",", "verbose", "=", "True", ")", ":", "years", "=", "days", "/", "const", ".", "days_per_year", "self", ".", "integrate_years", "(", "years", "=", "years", ",", "verbose", "=", "verbose", ...
Integrates the model forward for a specified number of days. It convertes the given number of days into years and calls :func:`integrate_years`. :param float days: integration time for the model in days [default: 1.0] :param bool verbose: informa...
[ "Integrates", "the", "model", "forward", "for", "a", "specified", "number", "of", "days", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L451-L481
7,688
brian-rose/climlab
climlab/process/time_dependent_process.py
TimeDependentProcess.integrate_converge
def integrate_converge(self, crit=1e-4, verbose=True): """Integrates the model until model states are converging. :param crit: exit criteria for difference of iterated solutions [default: 0.0001] :type crit: float :param bool verbos...
python
def integrate_converge(self, crit=1e-4, verbose=True): """Integrates the model until model states are converging. :param crit: exit criteria for difference of iterated solutions [default: 0.0001] :type crit: float :param bool verbos...
[ "def", "integrate_converge", "(", "self", ",", "crit", "=", "1e-4", ",", "verbose", "=", "True", ")", ":", "# implemented by m-kreuzer", "for", "varname", ",", "value", "in", "self", ".", "state", ".", "items", "(", ")", ":", "value_old", "=", "copy", "....
Integrates the model until model states are converging. :param crit: exit criteria for difference of iterated solutions [default: 0.0001] :type crit: float :param bool verbose: information whether total elapsed time ...
[ "Integrates", "the", "model", "until", "model", "states", "are", "converging", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L483-L518
7,689
brian-rose/climlab
climlab/radiation/cam3/setup.py
cam3_gen_source
def cam3_gen_source(ext, build_dir): '''Add CAM3 fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.''' # Fortran 90 sources in order of compilation fort90source = ['pmgrid.F90', 'prescribed_aerosols.F90', 'shr_kind...
python
def cam3_gen_source(ext, build_dir): '''Add CAM3 fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.''' # Fortran 90 sources in order of compilation fort90source = ['pmgrid.F90', 'prescribed_aerosols.F90', 'shr_kind...
[ "def", "cam3_gen_source", "(", "ext", ",", "build_dir", ")", ":", "# Fortran 90 sources in order of compilation", "fort90source", "=", "[", "'pmgrid.F90'", ",", "'prescribed_aerosols.F90'", ",", "'shr_kind_mod.F90'", ",", "'quicksort.F90'", ",", "'abortutils.F90'", ",", ...
Add CAM3 fortran source if Fortran 90 compiler available, if no compiler is found do not try to build the extension.
[ "Add", "CAM3", "fortran", "source", "if", "Fortran", "90", "compiler", "available", "if", "no", "compiler", "is", "found", "do", "not", "try", "to", "build", "the", "extension", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/cam3/setup.py#L39-L74
7,690
brian-rose/climlab
climlab/domain/field.py
global_mean
def global_mean(field): """Calculates the latitude weighted global mean of a field with latitude dependence. :param Field field: input field :raises: :exc:`ValueError` if input field has no latitude axis :return: latitude weighted global mean of the field :rtype: float :Example: i...
python
def global_mean(field): """Calculates the latitude weighted global mean of a field with latitude dependence. :param Field field: input field :raises: :exc:`ValueError` if input field has no latitude axis :return: latitude weighted global mean of the field :rtype: float :Example: i...
[ "def", "global_mean", "(", "field", ")", ":", "try", ":", "lat", "=", "field", ".", "domain", ".", "lat", ".", "points", "except", ":", "raise", "ValueError", "(", "'No latitude axis in input field.'", ")", "try", ":", "# Field is 2D latitude / longitude", "lon...
Calculates the latitude weighted global mean of a field with latitude dependence. :param Field field: input field :raises: :exc:`ValueError` if input field has no latitude axis :return: latitude weighted global mean of the field :rtype: float :Example: initial global mean temperature ...
[ "Calculates", "the", "latitude", "weighted", "global", "mean", "of", "a", "field", "with", "latitude", "dependence", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/field.py#L194-L224
7,691
brian-rose/climlab
climlab/domain/field.py
to_latlon
def to_latlon(array, domain, axis = 'lon'): """Broadcasts a 1D axis dependent array across another axis. :param array input_array: the 1D array used for broadcasting :param domain: the domain associated with that array :param axis: the axis ...
python
def to_latlon(array, domain, axis = 'lon'): """Broadcasts a 1D axis dependent array across another axis. :param array input_array: the 1D array used for broadcasting :param domain: the domain associated with that array :param axis: the axis ...
[ "def", "to_latlon", "(", "array", ",", "domain", ",", "axis", "=", "'lon'", ")", ":", "# if array is latitude dependent (has the same shape as lat)", "axis", ",", "array", ",", "depth", "=", "np", ".", "meshgrid", "(", "domain", ".", "axes", "[", "axis", "]",...
Broadcasts a 1D axis dependent array across another axis. :param array input_array: the 1D array used for broadcasting :param domain: the domain associated with that array :param axis: the axis that the input array will ...
[ "Broadcasts", "a", "1D", "axis", "dependent", "array", "across", "another", "axis", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/field.py#L243-L281
7,692
brian-rose/climlab
climlab/domain/xarray.py
Field_to_xarray
def Field_to_xarray(field): '''Convert a climlab.Field object to xarray.DataArray''' dom = field.domain dims = []; dimlist = []; coords = {}; for axname in dom.axes: dimlist.append(axname) try: assert field.interfaces[dom.axis_index[axname]] bounds_name = axname +...
python
def Field_to_xarray(field): '''Convert a climlab.Field object to xarray.DataArray''' dom = field.domain dims = []; dimlist = []; coords = {}; for axname in dom.axes: dimlist.append(axname) try: assert field.interfaces[dom.axis_index[axname]] bounds_name = axname +...
[ "def", "Field_to_xarray", "(", "field", ")", ":", "dom", "=", "field", ".", "domain", "dims", "=", "[", "]", "dimlist", "=", "[", "]", "coords", "=", "{", "}", "for", "axname", "in", "dom", ".", "axes", ":", "dimlist", ".", "append", "(", "axname",...
Convert a climlab.Field object to xarray.DataArray
[ "Convert", "a", "climlab", ".", "Field", "object", "to", "xarray", ".", "DataArray" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/xarray.py#L8-L30
7,693
brian-rose/climlab
climlab/domain/xarray.py
state_to_xarray
def state_to_xarray(state): '''Convert a dictionary of climlab.Field objects to xarray.Dataset Input: dictionary of climlab.Field objects (e.g. process.state or process.diagnostics dictionary) Output: xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries i...
python
def state_to_xarray(state): '''Convert a dictionary of climlab.Field objects to xarray.Dataset Input: dictionary of climlab.Field objects (e.g. process.state or process.diagnostics dictionary) Output: xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries i...
[ "def", "state_to_xarray", "(", "state", ")", ":", "from", "climlab", ".", "domain", ".", "field", "import", "Field", "ds", "=", "Dataset", "(", ")", "for", "name", ",", "field", "in", "state", ".", "items", "(", ")", ":", "if", "isinstance", "(", "fi...
Convert a dictionary of climlab.Field objects to xarray.Dataset Input: dictionary of climlab.Field objects (e.g. process.state or process.diagnostics dictionary) Output: xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries in each spatial dimension. Any ...
[ "Convert", "a", "dictionary", "of", "climlab", ".", "Field", "objects", "to", "xarray", ".", "Dataset" ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/xarray.py#L32-L60
7,694
brian-rose/climlab
climlab/domain/xarray.py
to_xarray
def to_xarray(input): '''Convert climlab input to xarray format. If input is a climlab.Field object, return xarray.DataArray If input is a dictionary (e.g. process.state or process.diagnostics), return xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries ...
python
def to_xarray(input): '''Convert climlab input to xarray format. If input is a climlab.Field object, return xarray.DataArray If input is a dictionary (e.g. process.state or process.diagnostics), return xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries ...
[ "def", "to_xarray", "(", "input", ")", ":", "from", "climlab", ".", "domain", ".", "field", "import", "Field", "if", "isinstance", "(", "input", ",", "Field", ")", ":", "return", "Field_to_xarray", "(", "input", ")", "elif", "isinstance", "(", "input", "...
Convert climlab input to xarray format. If input is a climlab.Field object, return xarray.DataArray If input is a dictionary (e.g. process.state or process.diagnostics), return xarray.Dataset object with all spatial axes, including 'bounds' axes indicating cell boundaries in each spatial dimension. ...
[ "Convert", "climlab", "input", "to", "xarray", "format", "." ]
eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/domain/xarray.py#L62-L79
7,695
adamrehn/slidingwindow
slidingwindow/SlidingWindow.py
generate
def generate(data, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for the specified dataset. """ # Determine the dimensions of the input data width = data.shape[dimOrder.index('w')] height = data.shape[dimOrder.index('h')] # Generate the windows return gene...
python
def generate(data, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for the specified dataset. """ # Determine the dimensions of the input data width = data.shape[dimOrder.index('w')] height = data.shape[dimOrder.index('h')] # Generate the windows return gene...
[ "def", "generate", "(", "data", ",", "dimOrder", ",", "maxWindowSize", ",", "overlapPercent", ",", "transforms", "=", "[", "]", ")", ":", "# Determine the dimensions of the input data", "width", "=", "data", ".", "shape", "[", "dimOrder", ".", "index", "(", "'...
Generates a set of sliding windows for the specified dataset.
[ "Generates", "a", "set", "of", "sliding", "windows", "for", "the", "specified", "dataset", "." ]
17ea9395b48671e8cb7321b9510c6b25fec5e45f
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L87-L97
7,696
adamrehn/slidingwindow
slidingwindow/SlidingWindow.py
generateForSize
def generateForSize(width, height, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for a dataset with the specified dimensions and order. """ # If the input data is smaller than the specified window size, # clip the window size to the input size on both dimension...
python
def generateForSize(width, height, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for a dataset with the specified dimensions and order. """ # If the input data is smaller than the specified window size, # clip the window size to the input size on both dimension...
[ "def", "generateForSize", "(", "width", ",", "height", ",", "dimOrder", ",", "maxWindowSize", ",", "overlapPercent", ",", "transforms", "=", "[", "]", ")", ":", "# If the input data is smaller than the specified window size,", "# clip the window size to the input size on both...
Generates a set of sliding windows for a dataset with the specified dimensions and order.
[ "Generates", "a", "set", "of", "sliding", "windows", "for", "a", "dataset", "with", "the", "specified", "dimensions", "and", "order", "." ]
17ea9395b48671e8cb7321b9510c6b25fec5e45f
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L100-L143
7,697
adamrehn/slidingwindow
slidingwindow/SlidingWindow.py
SlidingWindow.apply
def apply(self, matrix): """ Slices the supplied matrix and applies any transform bound to this window """ view = matrix[ self.indices() ] return self.transform(view) if self.transform != None else view
python
def apply(self, matrix): """ Slices the supplied matrix and applies any transform bound to this window """ view = matrix[ self.indices() ] return self.transform(view) if self.transform != None else view
[ "def", "apply", "(", "self", ",", "matrix", ")", ":", "view", "=", "matrix", "[", "self", ".", "indices", "(", ")", "]", "return", "self", ".", "transform", "(", "view", ")", "if", "self", ".", "transform", "!=", "None", "else", "view" ]
Slices the supplied matrix and applies any transform bound to this window
[ "Slices", "the", "supplied", "matrix", "and", "applies", "any", "transform", "bound", "to", "this", "window" ]
17ea9395b48671e8cb7321b9510c6b25fec5e45f
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L27-L32
7,698
adamrehn/slidingwindow
slidingwindow/SlidingWindow.py
SlidingWindow.indices
def indices(self, includeChannel=True): """ Retrieves the indices for this window as a tuple of slices """ if self.dimOrder == DimOrder.HeightWidthChannel: # Equivalent to [self.y:self.y+self.h+1, self.x:self.x+self.w+1] return ( slice(self.y, self.y+self.h), slice(self.x, self.x+self.w) ) ...
python
def indices(self, includeChannel=True): """ Retrieves the indices for this window as a tuple of slices """ if self.dimOrder == DimOrder.HeightWidthChannel: # Equivalent to [self.y:self.y+self.h+1, self.x:self.x+self.w+1] return ( slice(self.y, self.y+self.h), slice(self.x, self.x+self.w) ) ...
[ "def", "indices", "(", "self", ",", "includeChannel", "=", "True", ")", ":", "if", "self", ".", "dimOrder", "==", "DimOrder", ".", "HeightWidthChannel", ":", "# Equivalent to [self.y:self.y+self.h+1, self.x:self.x+self.w+1]", "return", "(", "slice", "(", "self", "."...
Retrieves the indices for this window as a tuple of slices
[ "Retrieves", "the", "indices", "for", "this", "window", "as", "a", "tuple", "of", "slices" ]
17ea9395b48671e8cb7321b9510c6b25fec5e45f
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L46-L78
7,699
adamrehn/slidingwindow
slidingwindow/Batching.py
batchWindows
def batchWindows(windows, batchSize): """ Splits a list of windows into a series of batches. """ return np.array_split(np.array(windows), len(windows) // batchSize)
python
def batchWindows(windows, batchSize): """ Splits a list of windows into a series of batches. """ return np.array_split(np.array(windows), len(windows) // batchSize)
[ "def", "batchWindows", "(", "windows", ",", "batchSize", ")", ":", "return", "np", ".", "array_split", "(", "np", ".", "array", "(", "windows", ")", ",", "len", "(", "windows", ")", "//", "batchSize", ")" ]
Splits a list of windows into a series of batches.
[ "Splits", "a", "list", "of", "windows", "into", "a", "series", "of", "batches", "." ]
17ea9395b48671e8cb7321b9510c6b25fec5e45f
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/Batching.py#L3-L7