コード例 #1
0
"""

import os
import numpy as np
from copy import deepcopy

from fourdvar.datadef.abstract._fourdvar_data import FourDVarData

from fourdvar.util.archive_handle import get_archive_path
import fourdvar.util.file_handle as fh
import fourdvar.util.date_handle as dt
import fourdvar.params.template_defn as template
import fourdvar.util.netcdf_handle as ncf

import setup_logging
logger = setup_logging.get_logger(__file__)


class ObservationData(FourDVarData):
    """application: vector of observations, observed or simulated
    Can be either 'full' or 'lite' file.
    'lite' file has no weight_grid attribute and cannot be used in transforms
        (for achiving and analysis only)"""

    #Parameters
    length = None
    uncertainty = None
    weight_grid = None
    offset_term = None
    misc_meta = None
    grid_attr = None
コード例 #2
0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""

import numpy as np
import os
import shutil
import subprocess
import netCDF4 as ncf

import fourdvar.util.date_handle as dt
import setup_logging as logging

logger = logging.get_logger( __file__ )

def validate( filepath, dataset ):
    """
    extension: test that dataset is compatible with a netCDF file.
    input: string (path/to/file.ncf), dict (see notes)
    output: Boolean, True == create_from_template will work
    
    notes: dataset is a dictionary structured:
      key = name of variable
      value = numpy.ndarray with shape matching netCDF variable
    'compatible' means that every variable in dataset exists in the file
    and is the same shape (including unlimited dimensions)
    """
    with ncf.Dataset( filepath, 'r' ) as ncf_file:
        ncf_var = ncf_file.variables
コード例 #3
0
    import os
    import sys
    sys.path.insert(0, os.path.abspath('..'))

import kivy
kivy.require(r'1.10.0')
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.properties import (
    NumericProperty,
    ListProperty,
)

import setup_logging
logger = setup_logging.get_logger(__name__)

Builder.load_string(r"""
#:kivy 1.10.0

<CircleDrawer>:
    _radius: min(*self.size) / 2 - self.line_width
    canvas:
        Color:
            rgba: self.color
        Line:
            circle:
                (self.center_x, self.center_y, self._radius,
                self.angle_start, self.angle_end, 30, )
            width: self.line_width
            cap: 'none'
コード例 #4
0
import setup_logging
from load_settings import settings
from utils.utils import compress_dir, decompress_file

C20_FULL_DATA_DIR = os.path.join(settings.DATA_DIR, 'c20_full')
C20_GRIB_DATA_DIR = os.path.join(settings.DATA_DIR, 'c20_grib')
C20_MEAN_DATA_DIR = os.path.join(settings.DATA_DIR, 'c20_mean')

DATA_DIR = settings.DATA_DIR

CHUNK_SIZE = settings.CHUNK_SIZE
MINIMUM_DOWNLOAD_RATE_1 = settings.MINIMUM_DOWNLOAD_RATE_1
MINIMUM_DOWNLOAD_RATE_2 = settings.MINIMUM_DOWNLOAD_RATE_2

log = setup_logging.get_logger('st.download')


def _download_file(url, output_dir):
    log.info('Downloading url: {}'.format(url))
    path = os.path.join(output_dir, url.split('/')[-1])
    sha1path = path + '.sha1sum'
    log.info('Download to : {}'.format(path))

    if url[:3].lower() == 'ftp':
        path = _ftp_download_file(url, path)
    else:
        path = _min_download_speed_download_file(url, path)

    if path is not None:
        log.info('Downloaded')
コード例 #5
0
ファイル: c20data.py プロジェクト: xiaoxiaoyu0302/stormtracks
from netCDF4 import Dataset
from scipy.interpolate import interp1d
import scipy.ndimage as ndimage

from utils.c_wrapper import cvort, cvort4
from utils.utils import cfind_extrema, upscale_field
from load_settings import settings
import setup_logging

C20_DATA_DIR = os.path.join(settings.DATA_DIR, 'c20_full')

EARTH_RADIUS = 6371000
EARTH_CIRC = EARTH_RADIUS * 2 * np.pi
NUM_ENSEMBLE_MEMBERS = 56

log = setup_logging.get_logger('st.find_vortmax')


class C20Data(object):
    '''Class used for accessing data from C20 Reanalysis project.

    This acts as a wrapper around netCDF4.Datasets and makes it easy to view data.
    Typically it exposes the prmsl and vort850/vort9950 fields for all ensemble members.
    It will load these fields, along with corresponding maxima (vorticity) and minima (pressure)
    each time a new date is set.

    :param year: Year from which to take data
    :param fields: List of C20 fields that are to be loaded, or use 'all' for complete set
    :param version: Version of C20 data to use
    '''
コード例 #6
0
#!/usr/bin/env python
"""Utility library for "chunked" custom search commands."""

import sys
import json
from cStringIO import StringIO
import re
import csv
import traceback
import logging
from collections import OrderedDict
import time

import setup_logging

logger = setup_logging.get_logger()
messages = logger.getChild('messages')


def get_logger(name=None):
    """Returns a logger for internal messages."""
    if name:
        return logger.getChild(name)
    else:
        return logger


def get_messages_logger():
    """Returns a logger for user-visible messages."""
    return messages