text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2017, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/limits.py | .py | 698c3fe4f0ec4cfe | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2008, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/log.py | .py | e58d38481cb9febe | 7.87 | 54 |
# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
# Copyright 2016, by the California Institute of Technology. ALL RIGHTS
# RESERVED. United States Government Sponsorship acknowledged. Any
# commercial use must be negotiated with the... | NASA-AMMOS/AIT-Core | ait/core/pcap.py | .py | daa2e590468b632e | 7.87 | 54 |
import gevent.monkey
import zmq.green as zmq
gevent.monkey.patch_all()
from typing import List, Any
import ait.core
import ait.core.server
from ait.core import log
from .config import ZmqConfig
class Broker(gevent.Greenlet):
"""
This broker contains the ZeroMQ context and proxy that connects all
stream... | NASA-AMMOS/AIT-Core | ait/core/server/broker.py | .py | 81e650bb8b3a0e68 | 7.87 | 54 |
import gevent.monkey
import gevent.server as gs
import gevent.socket
gevent.monkey.patch_all()
import zmq.green as zmq
import socket
import ait.core
from ait.core import log
import ait.core.server.utils as utils
class ZMQClient(object):
"""
This is the base ZeroMQ client class that all streams and plugins
... | NASA-AMMOS/AIT-Core | ait/core/server/client.py | .py | 5d7c1f69041ab9c3 | 7.87 | 54 |
import ait.core.server
class ZmqConfig:
"""
Configuration methods associated with ZeroMQ
"""
@staticmethod
def get_xsub_url():
return ait.config.get("server.xsub", ait.SERVER_DEFAULT_XSUB_URL)
@staticmethod
def get_xpub_url():
return ait.config.get("server.xpub", ait.SERV... | NASA-AMMOS/AIT-Core | ait/core/server/config.py | .py | 25bf042038be0293 | 7.37 | 54 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
FunDrive 集成示例代码
本文件展示了如何在实际应用中集成和使用FunDrive框架
包含常见的使用场景和最佳实践
"""
import os
import json
import logging
from typing import List, Dict, Optional, Any
from pathlib import Path
from fundrive import (
get_drive,
list_available_drives,
BaseDrive,
DriveFile,... | farfarfun/fundrive | example/integration_examples.py | .py | 94f5bf80944c7a5d | 7.93 | 72 |
"""
FunDrive - 统一云存储接口框架
提供统一的接口来操作20个主流云存储服务,包括Google Drive、OneDrive、
Dropbox、Amazon S3、GitHub、百度网盘、阿里云盘等。
主要特性:
- 🌟 统一的API接口,支持20个云存储服务
- 📁 完整的文件操作功能(上传、下载、删除、搜索等)
- 🔐 多种认证方式(OAuth2、API密钥、Token等)
- 🚀 高性能设计(缓存、连接池、重试机制)
- 🛡️ 完善的错误处理和日志记录
- 📖 详细的文档和示例代码
快速开始:
>>> from fundrive import get_drive
>>> driv... | farfarfun/fundrive | src/fundrive/__init__.py | .py | 38220b04b29c51f7 | 7.93 | 72 |
"""
FunDrive 统一异常处理模块
提供标准化的异常类和错误处理装饰器
"""
import functools
import time
from typing import Callable, Optional
from farlog import getLogger
logger = getLogger("fundrive.exceptions")
class FunDriveError(Exception):
"""FunDrive 基础异常类"""
def __init__(
self,
message: str,
error_code: ... | farfarfun/fundrive | src/fundrive/core/exceptions.py | .py | cf636fa869635482 | 7.93 | 72 |
"""共享 HTTP 会话工厂
各驱动此前的 HTTP 用法有四种方言:模块级 ``requests.get`` / 裸
``requests.Session()`` / 每个调用点手写 ``timeout=10`` / 什么都不写。
结果是 88 个请求里 81 个没有超时(一个挂住的 TCP 连接会永久挂死调用方),
没有任何驱动配置连接池或重试。
本模块提供一个统一入口:
>>> from fundrive.core.http import new_session
>>> session = new_session() # 带默认超时 + 重试 + 连接池
>>> session.get("https:... | farfarfun/fundrive | src/fundrive/core/http.py | .py | 450fb0603ac2429f | 7.93 | 72 |
"""
通用网盘驱动测试框架
这个模块提供了一个通用的测试框架,可以测试任何继承自 BaseDrive 的网盘驱动实现。
所有驱动的 example.py 都可以使用这个框架进行标准化测试。
"""
import os
import tempfile
from farlog import getLogger
from .base import BaseDrive
logger = getLogger("fundrive")
class BaseDriveTest:
"""通用网盘驱动测试类"""
def __init__(self, drive: BaseDrive, test_dir: str = ... | farfarfun/fundrive | src/fundrive/core/test.py | .py | 8387253d49b38ead | 8.43 | 72 |
"""
FunDrive 统一云存储驱动模块
驱动按需懒加载:``import fundrive`` 不会导入任何第三方 SDK,
只有真正取用某个驱动时才导入它的依赖。
设计要点
--------
* :data:`DRIVE_SPECS` 是唯一的事实来源(驱动 key -> 模块/类名/pip extra)。
* 类名拼写错误会**立即抛出** :class:`ImportError`,不再被"依赖没装"掩盖。
历史上 ``oss``/``webdav``/``lanzou``/``alipan``/``alipan_open`` 五个驱动
因为注册表里的类名拼错而永久不可用,且因为整段 import 被
``... | farfarfun/fundrive | src/fundrive/drives/__init__.py | .py | c9e44d896a41f6a5 | 7.93 | 72 |
import os
from datetime import datetime, timedelta, timezone
from typing import Any, List, Optional
from aligo import Aligo
from farlog import getLogger
from funsecret import read_secret
from fundrive.core import BaseDrive, DriveFile
from fundrive.core.base import get_filepath
logger = getLogger("fundrive")
class ... | farfarfun/fundrive | src/fundrive/drives/alipan/drive_aligo.py | .py | d88b90bf185f1045 | 7.93 | 72 |
# 标准库导入
from datetime import datetime, timedelta, timezone
from typing import Any, List, Optional
# 第三方库导入
from fundrives.aliopen import AliOpenManage
from farlog import getLogger
from funsecret import read_secret
# 项目内部导入
from fundrive.core import BaseDrive, DriveFile
from fundrive.core.base import get_filepath
log... | farfarfun/fundrive | src/fundrive/drives/alipan/drive_open.py | .py | ce6c90b35054ebd2 | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
阿里云盘驱动测试和演示脚本
支持两种阿里云盘驱动:
1. AlipanDrive - 基于aligo库的阿里云盘驱动
2. AliopenDrive - 基于开放API的阿里云盘驱动
使用方法:
python example.py --test # 运行完整测试
python example.py --interactive # 运行交互式演示
python example.py --help # 显示帮助信息
配置方法:
# 使用funsecret配置(... | farfarfun/fundrive | src/fundrive/drives/alipan/example.py | .py | 6d1217a960517cdf | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Amazon S3驱动示例和测试脚本
本脚本演示如何使用Amazon S3驱动进行文件操作,包括:
- AWS认证配置
- 存储桶操作
- 文件上传下载
- 目录管理
- 搜索和分享功能
使用方法:
1. 快速演示: python example.py --demo
2. 完整测试: python example.py --test
3. 交互式演示: python example.py --interactive
配置方法:
1. 使用funsecret: funsecret set fundrive.amazon.acc... | farfarfun/fundrive | src/fundrive/drives/amazon/example.py | .py | 25a9018bdffbb6fc | 7.93 | 72 |
# 标准库导入
import os
from typing import Any, List, Optional
# 第三方库导入
from fundrives.baidu import BaiduPCSApi, PcsFile
from funget import download
from farlog import getLogger
from funsecret import read_secret
# 项目内部导入
from fundrive.core import BaseDrive, DriveFile
from fundrive.core.base import get_filepath
logger = ge... | farfarfun/fundrive | src/fundrive/drives/baidu/drive.py | .py | d390ce8db1af4b9e | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
百度网盘驱动测试和演示脚本
使用方法:
python example.py --test # 运行完整测试
python example.py --interactive # 运行交互式演示
python example.py --help # 显示帮助信息
配置方法:
# 使用funsecret配置(推荐)
funsecret set fundrive baidu access_token "your_access_token"
funse... | farfarfun/fundrive | src/fundrive/drives/baidu/example.py | .py | b34612cabcda834d | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Dropbox 网盘驱动示例
本示例展示了如何使用 DropboxDrive 类进行各种网盘操作。
支持多种运行模式:
- --test: 基础功能测试
- --demo: 完整功能演示
- --simple: 简单使用示例
使用前请确保已配置 Dropbox API 访问令牌。
作者: fundrive 开发团队
文档: https://github.com/farfarfun/fundrive
"""
import argparse
import os
import tempfile
from farlog impor... | farfarfun/fundrive | src/fundrive/drives/dropbox/example.py | .py | a1860b3993c5f649 | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Gitee驱动使用示例
本示例展示如何使用Gitee驱动进行各种文件操作,包括:
- 基本连接和认证
- 文件上传下载
- 目录操作
- 搜索功能
- 分享链接生成
使用前请确保已配置Gitee访问令牌和仓库信息。
作者: FunDrive Team
"""
import os
import sys
import argparse
# 添加项目路径
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../.."))
from fundri... | farfarfun/fundrive | src/fundrive/drives/gitee/example.py | .py | 801ecc448d2b0156 | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GitHub驱动示例和测试脚本
本脚本演示如何使用GitHub驱动进行文件操作,包括:
- GitHub认证配置
- 仓库文件管理
- 文件上传下载
- 版本控制操作
- 搜索和分享功能
使用方法:
1. 快速演示: python example.py --demo
2. 完整测试: python example.py --test
3. 交互式演示: python example.py --interactive
配置方法:
1. 使用funsecret: funsecret set fundrive.github.acc... | farfarfun/fundrive | src/fundrive/drives/github/example.py | .py | 156ad00e603ed142 | 7.93 | 72 |
"""
蓝奏云网盘API封装
"""
import os
from typing import Any, List, Optional
from fundrives.lanzou import LanZouCloud
from fundrives.lanzou.utils import convert_file_size_to_int
from farlog import getLogger
from funsecret import read_secret
from tqdm import tqdm
from fundrive.core import BaseDrive, DriveFile
logger = getLog... | farfarfun/fundrive | src/fundrive/drives/lanzou/drive.py | .py | a4273760f0d97cec | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
MediaFire驱动测试和演示脚本
使用方法:
python example.py --test # 运行完整测试
python example.py --interactive # 运行交互式演示
python example.py --help # 显示帮助信息
配置方法:
# 使用funsecret配置(推荐)
funsecret set fundrive mediafire email "your_email@example.com"
... | farfarfun/fundrive | src/fundrive/drives/mediafire/example.py | .py | cf91d97b114e852f | 7.93 | 72 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OpenXLab驱动测试和演示脚本
使用方法:
python example.py --test # 运行完整测试
python example.py --interactive # 运行交互式演示
python example.py --help # 显示帮助信息
配置方法:
# 使用funsecret配置(推荐)
funsecret set fundrive openxlab opendatalab_session "your_session_c... | farfarfun/fundrive | src/fundrive/drives/openxlab/example.py | .py | e1e0fb89d774737c | 7.93 | 72 |
import pdaggerq
from extract_spins import *
def derive_equation(eqs, proj_eqname, ops, coeffs, L = None, R = None, T = None, spin_block = False):
"""
Derive and simplify the equation for the given projection operator.
Args:
proj_eqname (str): Name of the projection equation.
P (list): Proj... | edeprince3/pdaggerq | examples/eom_qed_ccsd_21.py | .py | 4995ca269a3e8346 | 7.9 | 61 |
import pdaggerq
from extract_spins import *
def derive_equation(eqs, proj_eqname, ops, coeffs, L = None, R = None, T = None, spin_block = False):
"""
Derive and simplify the equation for the given projection operator.
Args:
proj_eqname (str): Name of the projection equation.
P (list): Proj... | edeprince3/pdaggerq | examples/eom_qed_ccsd_21_1rdm.py | .py | 67e5565724cae60f | 7.9 | 61 |
import pdaggerq
from extract_spins import *
def derive_equation(eqs, proj_eqname, ops, coeffs, L = None, R = None, T = None, spin_block = False):
"""
Derive and simplify the equation for the given projection operator.
Args:
proj_eqname (str): Name of the projection equation.
P (list): Proj... | edeprince3/pdaggerq | examples/eom_qed_ccsd_21_2rdm.py | .py | 81f1575703086e87 | 7.9 | 61 |
def get_spin_labels(ops):
"""
Get spin labels for the given operators.
Args:
ops (list): List of operators.
Returns:
dict: Dictionary mapping spin types to label-spin mappings.
"""
spin_map = {}
labels = set()
found = False
# find all labels in the operators
fo... | edeprince3/pdaggerq | examples/extract_spins.py | .py | cccfc48a3f21081f | 7.9 | 61 |
"""Collision avoidance logic based on depth estimation.
Implements navigation algorithms that use depth maps to avoid obstacles and navigate
towards regions with greater depth.
"""
import numpy as np
from collections import deque
from typing import Tuple, Optional, Dict, Any
import time
from .config import Config
fr... | dronefreak/dji-tello-collision-avoidance-pydnet | src/collision_avoidance.py | .py | 72983a4b0e733ce9 | 7.87 | 55 |
"""Configuration management for the collision avoidance system.
This module provides a centralized configuration class for managing model parameters,
camera settings, and navigation options.
"""
import os
from dataclasses import dataclass
from typing import Tuple
@dataclass
class Config:
"""Configuration class ... | dronefreak/dji-tello-collision-avoidance-pydnet | src/config.py | .py | cf34232e65e61eed | 7.87 | 55 |
#!/usr/bin/env python3
"""Convert PyDNet TensorFlow 1.x checkpoint to TensorFlow 2.x/Keras format.
This script loads weights from the original PyDNet TF1 checkpoint and saves them in a
format compatible with TensorFlow 2.x and Keras 3.
"""
import os
import sys
import argparse
try:
import tensorflow as tf
except ... | dronefreak/dji-tello-collision-avoidance-pydnet | src/convert_weights.py | .py | 8737e22be7748dc8 | 7.87 | 55 |
"""Webcam camera source implementation.
Provides webcam access through OpenCV for testing depth estimation without a drone.
"""
import cv2
import numpy as np
from typing import Optional, Tuple
from .camera_interface import CameraInterface
from .config import Config
class WebcamSource(CameraInterface):
"""Webca... | dronefreak/dji-tello-collision-avoidance-pydnet | src/webcam_source.py | .py | d74336e88b69efd6 | 7.87 | 55 |
#!/usr/bin/env python3
"""Tello Drone Demo with Depth Estimation.
Run depth estimation on DJI Tello drone video stream with optional collision avoidance.
Commands are disabled by default for safety.
Press 'q' or ESC to quit, 't' to takeoff, 'l' to land, 'e' for emergency stop.
"""
import argparse
import os
import sy... | dronefreak/dji-tello-collision-avoidance-pydnet | tello_demo.py | .py | 1c83bda4f1fa6721 | 7.87 | 55 |
"""Unit tests for depth_estimator module."""
import os
import sys
import unittest
import numpy as np
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from src.config import Config
# Check if TensorFlow is available
try:
import tensorflow as tf # noqa: F401
TF_AVAILABLE ... | dronefreak/dji-tello-collision-avoidance-pydnet | tests/test_depth_estimator.py | .py | 0c5ecd4cc3695f0c | 8.37 | 55 |
"""Unit tests for utils module."""
import os
import sys
import unittest
import numpy as np
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
# Check if OpenCV is available (required for utils module)
try:
import cv2 # noqa: F401
CV2_AVAILABLE = True
from src.utils imp... | dronefreak/dji-tello-collision-avoidance-pydnet | tests/test_utils.py | .py | a6cac984f2e95144 | 7.37 | 55 |
"""Unit tests for webcam_demo functionality.
Tests the webcam source and integration without requiring actual hardware.
"""
import os
import sys
import unittest
from unittest.mock import MagicMock, patch
import numpy as np
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
# Check ... | dronefreak/dji-tello-collision-avoidance-pydnet | tests/test_webcam_demo.py | .py | c396c90906afd1a6 | 7.37 | 55 |
#!/usr/bin/env python3
"""Webcam Demo for Depth Estimation.
Test the depth estimation system using a webcam without needing a drone. Press 'q' or
ESC to quit, 'p' to pause, 's' to save screenshot.
"""
import argparse
import os
import sys
import cv2
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(_... | dronefreak/dji-tello-collision-avoidance-pydnet | webcam_demo.py | .py | 96fdefa93043bf17 | 7.87 | 55 |
"""Builds/parses the LangGraph checkpointer thread_id from a (stream_id, user_id) pair."""
_SEPARATOR = "::"
def thread_id(stream_id: str, user_id: int) -> str:
return f"{stream_id}{_SEPARATOR}{user_id}"
def stream_id_from_thread(thread_id: str) -> str:
return thread_id.split(_SEPARATOR, 1)[0]
| finos/symphony-bdk-python | examples/ai_agent/memory_ids.py | .py | bd22a9c6cbe0b4e5 | 7.29 | 37 |
"""BDK-backed tools exposed to the LLM agent."""
from langchain_core.tools import tool
from examples.ai_agent.memory_ids import stream_id_from_thread
from symphony.bdk.core.symphony_bdk import SymphonyBdk
def build_tools(bdk: SymphonyBdk):
@tool
async def lookup_user(username_or_email: str) -> str:
... | finos/symphony-bdk-python | examples/ai_agent/tools.py | .py | 0b19fed749b3c872 | 7.79 | 37 |
import logging
from symphony.bdk.core.activity.api import AbstractActivity, ActivityContext
from symphony.bdk.core.activity.exception import FatalActivityExecutionException
from symphony.bdk.core.activity.parsing.arguments import Arguments
from symphony.bdk.core.activity.parsing.command_token import MatchingUserIdMent... | finos/symphony-bdk-python | symphony/bdk/core/activity/command.py | .py | 1bda3ef5e52baf71 | 7.79 | 37 |
import logging
from symphony.bdk.core.activity.api import AbstractActivity, ActivityContext
from symphony.bdk.gen.agent_model.v4_initiator import V4Initiator
from symphony.bdk.gen.agent_model.v4_symphony_elements_action import V4SymphonyElementsAction
logger = logging.getLogger(__name__)
class FormReplyContext(Acti... | finos/symphony-bdk-python | symphony/bdk/core/activity/form.py | .py | c2fa2321508b9f5f | 7.79 | 37 |
from symphony.bdk.core.activity.command import CommandContext, SlashCommandActivity
from symphony.bdk.core.symphony_bdk import SymphonyBdk
class HelpCommand(SlashCommandActivity):
"""The help command is a particular CommandActivity which returns the list of all commands available for the
specific bot
The ... | finos/symphony-bdk-python | symphony/bdk/core/activity/help_command.py | .py | 4b24db3ff78d3a55 | 7.79 | 37 |
import json
import re
from defusedxml.ElementTree import fromstring
from symphony.bdk.core.activity.parsing.message_entities import Cashtag, Hashtag, Mention
from symphony.bdk.gen.agent_model.v4_message import V4Message
class InputTokenizer:
"""
Class responsible for parsing a {@link V4Message} into a list ... | finos/symphony-bdk-python | symphony/bdk/core/activity/parsing/input_tokenizer.py | .py | 65ff237224b89db6 | 7.79 | 37 |
from symphony.bdk.core.activity.parsing.arguments import Arguments
class MatchResult:
"""
Class representing the outcome of a matching between a {@link SlashCommandPattern} and a message.
It can contain the map of arguments if applicable. Key is argument name, value is the actual value in the message.
... | finos/symphony-bdk-python | symphony/bdk/core/activity/parsing/match_result.py | .py | 846546f3ea806d40 | 7.79 | 37 |
import re
from symphony.bdk.core.activity.parsing.command_token import (
ArgumentCommandToken,
CashArgumentCommandToken,
HashArgumentCommandToken,
MentionArgumentCommandToken,
StaticCommandToken,
StringArgumentCommandToken,
)
from symphony.bdk.core.activity.parsing.input_tokenizer import InputT... | finos/symphony-bdk-python | symphony/bdk/core/activity/parsing/slash_command_pattern.py | .py | 2b35825f9414e1b1 | 7.79 | 37 |
import logging
from symphony.bdk.core.activity.api import AbstractActivity
from symphony.bdk.core.activity.command import CommandActivity, CommandContext, SlashCommandActivity
from symphony.bdk.core.activity.form import FormReplyActivity, FormReplyContext
from symphony.bdk.core.activity.user_joined_room import (
U... | finos/symphony-bdk-python | symphony/bdk/core/activity/registry.py | .py | cc38ad2c562f5f5a | 7.79 | 37 |
import logging
from symphony.bdk.core.activity.api import AbstractActivity, ActivityContext
from symphony.bdk.gen.agent_model.v4_initiator import V4Initiator
from symphony.bdk.gen.agent_model.v4_user_joined_room import V4UserJoinedRoom
logger = logging.getLogger(__name__)
class UserJoinedRoomContext(ActivityContext... | finos/symphony-bdk-python | symphony/bdk/core/activity/user_joined_room.py | .py | 106ab3901108c9dc | 7.79 | 37 |
"""Module containing session handle classes."""
import logging
from datetime import datetime, timezone
from symphony.bdk.core.auth.exception import AuthInitializationError
from symphony.bdk.core.auth.jwt_helper import extract_token_claims
logger = logging.getLogger(__name__)
EXPIRATION_SAFETY_BUFFER_SECONDS = 5
SKD... | finos/symphony-bdk-python | symphony/bdk/core/auth/auth_session.py | .py | 20377d426690162d | 7.79 | 37 |
"""Module for instantiating various authenticator objects."""
from symphony.bdk.core.auth.bot_authenticator import (
BotAuthenticator,
BotAuthenticatorCert,
BotAuthenticatorRsa,
)
from symphony.bdk.core.auth.exception import AuthInitializationError
from symphony.bdk.core.auth.ext_app_authenticator import (... | finos/symphony-bdk-python | symphony/bdk/core/auth/authenticator_factory.py | .py | 335624969ce12167 | 7.79 | 37 |
"""Module containing BotAuthenticator classes."""
from abc import ABC, abstractmethod
from typing import Optional, Tuple
from symphony.bdk.core.auth.jwt_helper import create_signed_jwt, generate_expiration_time
from symphony.bdk.core.config.model.bdk_bot_config import BdkBotConfig
from symphony.bdk.core.config.model.... | finos/symphony-bdk-python | symphony/bdk/core/auth/bot_authenticator.py | .py | 1e84bb1a219703c1 | 7.79 | 37 |
"""Module containing all authentication related exception."""
class AuthInitializationError(Exception):
"""Thrown when unable to read/parse a RSA Private Key or a certificate."""
def __init__(self, message: str):
super().__init__()
self.message = message
class AuthUnauthorizedError(Exceptio... | finos/symphony-bdk-python | symphony/bdk/core/auth/exception.py | .py | 479b0cd217d77861 | 7.79 | 37 |
from . import grids
from .models import (
camx,
chimere,
cmaq,
fv3chem,
hysplit,
hytraj,
ncep_grib,
pardump,
prepchem,
raqms,
)
from .obs import (
aeronet,
airnow,
aqs,
cems,
crn,
improve,
ish,
ish_lite,
nadp,
openaq,
openaq_v2,
ope... | noaa-oar-arl/monetio | monetio/__init__.py | .py | 4893a930bb7bbc49 | 7.75 | 30 |
"""CAMx File Reader"""
import warnings
# from numpy import array, concatenate
import numpy as np
import xarray as xr
from pandas import Series, to_datetime
from ..grids import get_ioapi_pyresample_area_def, grid_from_dataset
def can_do(index):
if index.max():
return True
else:
return False
... | noaa-oar-arl/monetio | monetio/models/_camx_mm.py | .py | 4116ae1a86164e60 | 7.75 | 30 |
import datetime
import os
import numpy as np
# import monet.utilhysplit.hysp_func as hf
from netCDF4 import Dataset
# import matplotlib.pyplot as plt
# 01/28/2020 AMC cdump2awips created to make a netcdf file appropriate for input into AWIPS
# hysplit.py was modified in the forked version of MONET to make this work... | noaa-oar-arl/monetio | monetio/models/cdump2netcdf.py | .py | 436b166ec5bd0eee | 7.75 | 30 |
"""reads tdump files int pandas DataFrame
combine_dataset : reads multiple tdump files
open_dataset : reads one tdump file
open_tdump
get_metinfo
get_traj
get_startlocs
time_str_fixer
"""
import re
import numpy as np
import pandas as pd
def combine_dataset(flist, taglist=None, renumber=False, verbose=False):
... | noaa-oar-arl/monetio | monetio/models/hytraj.py | .py | 54469ec7d2094fdf | 7.75 | 30 |
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
"""
PGRMMR: Alice Crawford ORG: NOAA/ARL
PYTHON 3
ABSTRACT: classes and functions for reading and writing binary HYSPLIT
PARDUMP file
CLASSES
Pardump - contains methods to write or read a binary pardump file
FUNCTIONS
open_dataset()
"""
import datetime... | noaa-oar-arl/monetio | monetio/models/pardump.py | .py | 845e896770ed1c53 | 7.75 | 30 |
import xarray as xr
try:
import fv3grid as fg
has_fv3grid = True
except ImportError:
has_fv3grid = False
def open_dataset(fname, dtype="f4", res="C384", tile=1):
"""Reads the binary data for FV3-CHEM input generated by prep_chem_sources.
Parameters
----------
fname : type
Descri... | noaa-oar-arl/monetio | monetio/models/prepchem.py | .py | 98fc350086eb2df3 | 7.75 | 30 |
"""
Reader for RAQMS real-time files.
RAQMS: Realtime Air Quality Monitoring System
More information: http://raqms-ops.ssec.wisc.edu/
"""
import xarray as xr
def open_dataset(fname, *, convert_to_ppb=True, surf_only=False):
"""Open a single dataset from RAQMS output. Currently expects netCDF file format.
... | noaa-oar-arl/monetio | monetio/models/raqms.py | .py | c725a1f6b4742032 | 7.75 | 30 |
"""
AERONET
"""
import time
import warnings
from datetime import datetime
from functools import lru_cache
import numpy as np
import pandas as pd
try:
import dask
has_dask = True
except ImportError:
has_dask = False
def add_local(
fname,
*,
#
# post-proc
freq=None,
detect_dust=F... | noaa-oar-arl/monetio | monetio/obs/aeronet.py | .py | f071e71cb444970e | 7.75 | 30 |
"""AirNow"""
import os
# this is written to retrieve airnow data concatenate and add to pandas array
# for usage
from datetime import datetime
import pandas as pd
datadir = "."
cwd = os.getcwd()
url = None
dates = [
datetime.strptime("2016-06-06 12:00:00", "%Y-%m-%d %H:%M:%S"),
datetime.strptime("2016-06-06... | noaa-oar-arl/monetio | monetio/obs/airnow.py | .py | e9c8c0f441bb1544 | 7.75 | 30 |
import pandas as pd
from numpy import nan
class IMPROVE:
"""Short summary.
Attributes
----------
datestr : type
Description of attribute `datestr`.
df : type
Description of attribute `df`.
daily : type
Description of attribute `daily`.
se_states : type
Desc... | noaa-oar-arl/monetio | monetio/obs/improve_mod.py | .py | de5c4c208dd18bbf | 7.75 | 30 |
"""NOAA Integrated Surface Hourly (ISH; also known as ISD, Integrated Surface Data) lite version.
https://www.ncei.noaa.gov/pub/data/noaa/isd-lite/isd-lite-format.txt
ISDLite is a derived product that makes it easier to work with for general research and scientific purposes.
It is a subset of the full ISD containing ... | noaa-oar-arl/monetio | monetio/obs/ish_lite.py | .py | 828c3604f0df6973 | 7.75 | 30 |
"""Get v1 (government-only) OpenAQ data from AWS.
https://openaq.org/
https://openaq-fetches.s3.amazonaws.com/index.html
"""
import json
import sys
import warnings
import pandas as pd
from numpy import nan
_PY39_PLUS = sys.version_info >= (3, 9)
_URL_CAP_RANDOM_SAMPLE = False # if false, take from end of list
_U... | noaa-oar-arl/monetio | monetio/obs/openaq.py | .py | 7783e862be9b0848 | 7.75 | 30 |
"""OpenAQ archive data on AWS.
https://openaq.org/
https://registry.opendata.aws/openaq/
https://docs.openaq.org/aws/about
"""
import logging
import warnings
from pathlib import Path
from time import perf_counter
import pandas as pd
HERE = Path(__file__).parent
logger = logging.getLogger(__name__)
def read(fp)... | noaa-oar-arl/monetio | monetio/obs/openaq_aws.py | .py | fe39f7e34ee9ea61 | 7.75 | 30 |
"""Get AQ data from the OpenAQ v2 REST API.
Visit https://docs.openaq.org/docs/getting-started to get an API key
and set environment variable ``OPENAQ_API_KEY`` to use it.
For example, in Bash:
.. code-block:: bash
export OPENAQ_API_KEY="your_api_key_here"
https://openaq.org/
https://api.openaq.org/docs#/v2
""... | noaa-oar-arl/monetio | monetio/obs/openaq_v2.py | .py | 0fc41503cb322974 | 7.75 | 30 |
# Reads json data files from
# https://aqs.epa.gov/aqsweb/documents/data_api.html
import json
import pandas as pd
def add_data(filename):
"""Opens a json file, returns data array
Parameters
-----------------
filename: string
Full file path for json file
Returns
----------------... | noaa-oar-arl/monetio | monetio/obs/pams.py | .py | 464faf37f624f101 | 7.75 | 30 |
"""
GEOMS -- The Generic Earth Observation Metadata Standard
This is a format for storing profile data,
used by several LiDAR networks.
It is currently `TOLNet <https://www-air.larc.nasa.gov/missions/TOLNet/>`__'s
format of choice.
For more info, see: https://evdc.esa.int/documentation/geoms/
"""
import warnings
i... | noaa-oar-arl/monetio | monetio/profile/geoms.py | .py | 70cfbb3a8004f2e9 | 7.75 | 30 |
import os
import pandas as pd
import xarray as xr
def open_dataset(fname):
t = TOLNet()
return t.add_data(fname)
def open_mfdataset(fname):
from glob import glob
from numpy import sort
t = TOLNet()
dsets = []
for i in sort(glob(fname)):
dsets.append(t.add_data(i))
return x... | noaa-oar-arl/monetio | monetio/profile/tolnet.py | .py | 819b0a6bdabecdb5 | 7.75 | 30 |
import os
import pandas as pd
import xarray as xr
def open_dataset(fname):
t = CL51()
return t.add_data(fname)
def open_mfdataset(fname):
from glob import glob
from numpy import sort
t = CL51()
dsets = []
for i in sort(glob(fname)):
dsets.append(t.add_data(i))
return xr.co... | noaa-oar-arl/monetio | monetio/profile/umbc_aerosol.py | .py | edb8cdf2d1178381 | 7.75 | 30 |
import logging
from typing import Dict, List
from django.contrib.auth.models import User as DjangoUser
from django.contrib.contenttypes.models import ContentType
from ninja import Router, Path
from notifications.models import Notification
from serde import to_dict
from api.auth import get_submit_write_access
from com... | mrlvsb/kelvin | api/v2/task/submit/default.py | .py | c89b97060a62d8b6 | 7.77 | 34 |
import datetime
from .inbus import inbus
from common.utils import is_teacher, user_from_login
import serde
from dataclasses import dataclass
from django.contrib.auth.models import User, Group
from common.models import Class, Semester, Subject
from typing import List, Dict, Generator
import traceback
from .inbus.dto im... | mrlvsb/kelvin | common/bulk_import.py | .py | f3adb36be8f72672 | 7.77 | 34 |
from typing import List
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404
from notifications.models import Notification
from notifications.signals import notify
from common.dto import CommentDTO
from django.contrib.auth.models import User as DjangoUser
from comm... | mrlvsb/kelvin | common/comment.py | .py | 916ea936f89b2082 | 7.77 | 34 |
import datetime
import logging
import traceback
from typing import Callable, TYPE_CHECKING
from django.conf import settings
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.db import transaction
from django.http import HttpRequest
from django.template.loader import render_... | mrlvsb/kelvin | common/emails/__init__.py | .py | 05ef77fce9ee97ea | 7.77 | 34 |
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
class Email(models.Model):
"""
E-mail sent by Kelvin.
"""
class Meta:
indexes = [
models.Index(name="sent_at", fields=["sent_at"]),
]
subject = models.TextField()... | mrlvsb/kelvin | common/emails/models.py | .py | 64a11b2faa4a2205 | 7.77 | 34 |
import io
import logging
import os
import tarfile
import tempfile
from pathlib import Path
from typing import Any, Optional
import django_rq
import requests
import yaml
from django.conf import settings
from django.core import signing
from django.urls import reverse
from django.utils import timezone
from rq import get_... | mrlvsb/kelvin | common/evaluate.py | .py | 793ac5d8b15e9c1c | 7.77 | 34 |
import dataclasses
import datetime
import logging
from typing import TYPE_CHECKING
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import caches
from django.db import models
from django.db.models import JSONField
from django.http import HttpRequest
if TYPE_CHECKING:... | mrlvsb/kelvin | common/event_log.py | .py | f7ebc2d570b06108 | 7.77 | 34 |
import logging
from django.http import HttpRequest
from common.exceptions import HttpExceptionData
from kelvin import settings
from web.views.common import render_custom_error_page
logger = logging.getLogger(__name__)
"""
Having custom error pages in Django is.. stupidly hard.
We want to render a custom error page... | mrlvsb/kelvin | common/exceptions/middleware.py | .py | 292fbe29ec57f5f9 | 7.77 | 34 |
from dataclasses import dataclass
from typing import NewType, List
import serde
DepartmentId = NewType("DepartmentId", int)
SubjectVersionId = NewType("SubjectVersionId", int)
SubjectVersionSchedule = NewType("SubjectVersionSchedule", List["ConcreteActivity"])
ConcreteActivityId = NewType("ConcreteActivityId", int)
... | mrlvsb/kelvin | common/inbus/dto.py | .py | 68479ac662e258f0 | 7.77 | 34 |
import requests
from typing import Dict
from django.core.cache import caches
from . import auth
def set_token_to_cache(token: Dict) -> None:
"""
Sets INBUS token to cache.
We set its timeout to one hour less than epecified by API provider.
"""
cache = caches["default"]
timeout = token["expi... | mrlvsb/kelvin | common/inbus/utils.py | .py | f927d325ee53bc3b | 7.77 | 34 |
import numpy as np
import xarray as xr
from .config import nround
from .domain import rewrite_coords
# from .utils import _get_info, _guess_domain
from .tables import domains
IDS = ["domain_id", "CORDEX_domain"]
def _get_domain_id(ds):
"""search for any valid domain id"""
for attr in IDS:
if attr i... | euro-cordex/py-cordex | cordex/accessor.py | .py | 23512f255b9a8701 | 7.7 | 24 |
"""CORDEX Cmorization utilities."""
import datetime as dt
import json
import tempfile
from warnings import warn
import cftime as cfdt
import xarray as xr
from xarray import DataArray, Dataset
from .. import cordex_domain
from .config import time_bounds_name
xr.set_options(keep_attrs=True)
def to_cftime(date, cale... | euro-cordex/py-cordex | cordex/cmor/utils.py | .py | f4137438964ce7c5 | 7.7 | 24 |
"""this module should help on managing ESGF metadata"""
import pandas as pd
try:
from tqdm import tqdm
except Exception:
def tqdm(x):
return x
try:
from pyesgf.search import SearchConnection
except Exception:
print(
"pyesgf client is not installed! please install https://github.com/... | euro-cordex/py-cordex | cordex/esgf_access.py | .py | ffab6a02068063ec | 7.7 | 24 |
from . import _regions
from ._resources import fetch_vg2500
class Germany:
"""VG2500 Deutschland Verwaltungsgrenzen
Attributes
----------
ADE :
Administrative Ebene
Werteübersicht: 1 = Staat 2 = Land 3 = Regierungsbezirk 4 = Kreis
ARS :
Amtlicher Regionalschlüssel (bishe... | euro-cordex/py-cordex | cordex/regions/_germany.py | .py | 0c79ee9477d6f853 | 7.7 | 24 |
"""convert to WGS84 latitude-longitude projection"""
WGS84 = "EPSG:4326"
def get_geodataframe(shapefile, to_crs=WGS84, **kwargs):
import geopandas as gpd
shp = gpd.read_file(shapefile)
if to_crs is not None:
shp = shp.to_crs(to_crs)
return shp
def get_regionmask(geodataframe, **kwargs):
... | euro-cordex/py-cordex | cordex/regions/_regions.py | .py | 54d3ce1eb3121974 | 7.2 | 24 |
from pooch import retrieve
cache_url = "~/.py-cordex"
def fetch_vg2500():
"""Fetch Germany Verwaltungsgebiete 1:2,500,000"""
# downloader = HTTPDownloader(verify=False)
fname = retrieve(
path=cache_url,
url="https://daten.gdz.bkg.bund.de/produkte/vg/vg2500/2020/vg2500_01-01.gk3.shape.zip"... | euro-cordex/py-cordex | cordex/regions/_resources.py | .py | 598c050463ce83eb | 7.7 | 24 |
from importlib.resources import files
import pandas as pd
from ._resources import ( # fetch_cmip6_cmor_table,
cmor_tables_inpath,
ecmwf_tables,
fetch_cordex_cmor_table,
# read_domain_table,
)
# __cmor_table_version__ = cmor_table_version
__all__ = [
"cmor_tables_inpath",
"ecmwf_tables",
... | euro-cordex/py-cordex | cordex/tables/__init__.py | .py | 1d900c2ce65f3948 | 7.7 | 24 |
from warnings import warn
import numpy as np
import xarray as xr
from pyproj import CRS, Transformer
from . import cf
xr.set_options(keep_attrs=True)
def _map_crs(x_stack, y_stack, src_crs, trg_crs=None):
"""coordinate transformation of longitude and latitude"""
from cartopy import crs as ccrs
if trg... | euro-cordex/py-cordex | cordex/transform.py | .py | 898b81613df5e816 | 7.7 | 24 |
"""
Useful for:
* users learning py-cordex
"""
# code stolen from xarray, I am sorry!
import os
import pathlib
from xarray import open_dataset as _open_dataset
from .preprocessing import cordex_dataset_id
_default_cache_dir_name = "py-cordex_tutorial_data"
base_url = "https://github.com/euro-cordex/py-cordex-data... | euro-cordex/py-cordex | cordex/tutorial.py | .py | 4ad54cad0c84484f | 7.7 | 24 |
import tempfile
import numpy as np
def get_tempfile():
"""Creates a temporay filename."""
return tempfile.mkstemp()[1]
def to_center_coordinate(ds):
ds.coords["lon"] = (ds.coords["lon"] + 180) % 360 - 180
return ds
def _cell_area(ds, R=6371000):
"""Compute cell area of a regular spherical gri... | euro-cordex/py-cordex | cordex/utils.py | .py | 7e4a0d758845f172 | 7.7 | 24 |
import numpy as np
import pytest
import xarray as xr
import cordex as cx
from cordex.accessor import CordexDataArrayAccessor, CordexDatasetAccessor # noqa
@pytest.mark.parametrize(
"domain_id", ["EUR-11", "EUR-22", "EUR-44", "EUR-11i", "AFR-44"]
)
def test_guess_info(domain_id):
ds = xr.decode_cf(cx.cordex_... | euro-cordex/py-cordex | tests/test_accessor.py | .py | 9936ba04c3fba19d | 7.2 | 24 |
import numpy as np
import pandas as pd
import pytest
import xarray as xr
import cordex as cx
from . import requires_cartopy
# from cordex.utils import _get_info, _guess_domain
@pytest.mark.parametrize("domain_id", ["EUR-11", "EUR-11i", "SAM-44", "AFR-22"])
@pytest.mark.parametrize("bounds", [False, True])
@pytest.... | euro-cordex/py-cordex | tests/test_domain.py | .py | 91fb85ec18885f33 | 8.2 | 24 |
import numpy as np
import pytest
import xarray as xr
import cordex as cx
from cordex import cordex_domain
from cordex.preprocessing.preprocessing import (
attr_to_coord,
check_domain,
cordex_dataset_id,
get_grid_mapping,
get_grid_mapping_name,
member_id_to_dset_id,
promote_empty_dims,
r... | euro-cordex/py-cordex | tests/test_preprocessing.py | .py | e3db83254a080e06 | 8.2 | 24 |
import pytest
import requests
import cordex as cx
from . import requires_geopandas
SERVICE_URL = "https://daten.gdz.bkg.bund.de"
def _service_available(url: str = SERVICE_URL, timeout: float = 2.0) -> bool:
"""Return True if remote service can be reached quickly.
Uses a HEAD request first (cheap); falls b... | euro-cordex/py-cordex | tests/test_regions.py | .py | 87513e10452d96d6 | 8.2 | 24 |
import numpy as np
import pytest
import cordex as cx
from cordex.utils import cell_area
@pytest.mark.parametrize("domain_id", ["EUR-11", "EUR-11i", "SAM-44", "AFR-22"])
def test_cell_area(domain_id):
"""compare against cdo"""
from cdo import Cdo
cdo = Cdo()
ds = cx.cordex_domain(domain_id, dummy=Tr... | euro-cordex/py-cordex | tests/test_utils.py | .py | c7bf65f6917560b1 | 7.2 | 24 |
"""Functions for configuring CuBIDS."""
import importlib.resources
from pathlib import Path
import yaml
def load_config(config_file):
"""Load a YAML file containing a configuration for param groups.
Parameters
----------
config_file : str or pathlib.Path, optional
The path to the configurat... | PennLINC/CuBIDS | cubids/config.py | .py | 9fd44d4451ccf72e | 7.75 | 31 |
"""Shared pytest fixtures for CuBIDS tests."""
import json
from pathlib import Path
import pytest
from niworkflows.utils.testing import generate_bids_skeleton
from cubids.tests.utils import TEST_DATA
def _convert_relative_to_bids_uri(dataset_root: Path) -> None:
"""Convert IntendedFor sidecar values from relat... | PennLINC/CuBIDS | cubids/tests/conftest.py | .py | 474a0f12f6fc01fd | 8.25 | 31 |
"""Unit tests for the CuBIDS class in the CuBIDS package."""
import pandas as pd
import pytest
from cubids.cubids import CuBIDS
@pytest.fixture
def cubids_instance():
"""Fixture for creating a CuBIDS instance.
Returns
-------
CuBIDS
An instance of the CuBIDS class.
"""
data_root = "... | PennLINC/CuBIDS | cubids/tests/test_cubids.py | .py | 509586978ad76636 | 7.25 | 31 |
"""Test file collection management in CuBIDS."""
import json
import pytest
from cubids.workflows import add_file_collections
@pytest.mark.parametrize(
"skeleton_name",
["skeleton_file_collection_01.yml", "skeleton_file_collection_02.yml"],
)
def test_add_file_collections(tmp_path, build_bids_dataset, skele... | PennLINC/CuBIDS | cubids/tests/test_file_collections.py | .py | d7bf3749646e999b | 7.25 | 31 |
"""Tests for ASL/M0 renaming behavior.
Ensures that when ASL scans are renamed with variant acquisition labels:
- aslcontext files are renamed to match the ASL scan
- M0 files (nii/json) are NOT renamed
- M0 JSON IntendedFor entries are updated to point to the new ASL path
"""
import json
from pathlib import Path
fr... | PennLINC/CuBIDS | cubids/tests/test_perf_m0.py | .py | cb508a50661569cc | 8.25 | 31 |
"""Tests for the utils module."""
import pandas as pd
from cubids import utils
from cubids.constants import NON_KEY_ENTITIES
from cubids.cubids import CuBIDS
from cubids.tests.utils import compare_group_assignments
def test_find_json_files_excludes_git_metadata(tmp_path):
"""Find JSON files in a dataset without... | PennLINC/CuBIDS | cubids/tests/test_utils.py | .py | bebfa3dd6b619e70 | 7.25 | 31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.