<commit_before>#!/usr/bin/env python
import numpy as np
from numpy.ma import MaskedArray

mesonet_vars = ['STID', 'STNM', 'TIME', 'RELH', 'TAIR', 'WSPD', 'WVEC', 'WDIR',
    'WDSD', 'WSSD', 'WMAX', 'RAIN', 'PRES', 'SRAD', 'TA9M', 'WS2M', 'TS10',
    'TB10', 'TS05', 'TB05', 'TS30', 'TR05', 'TR25', 'TR60', 'TR75']

def remote_mesonet_ts(site, date=None, fields=None, unpack=True):
    '''
    Reads in Oklahoma Mesonet timeseries data directly from their servers.

    site : string
        The station id for the data to be fetched.  This is
        case-insensitive.

    date : datetime object
        A python :class:`datetime` object specify that date
        for which that data should be downloaded.

    fields : sequence
        A list of the variables which should be returned.  See
        :func:`read_mesonet_ts` for a list of valid fields.

    unpack : bool
        If True, the returned array is transposed, so that arguments may be
        unpacked using ``x, y, z = remote_mesonet_ts(...)``. Defaults to True.

    Returns : array
        A nfield by ntime masked array.  nfield is the number of fields
        requested and ntime is the number of times in the file.  Each
        variable is a row in the array.  The variables are returned in
        the order given in *fields*.
    '''
    import urllib2
    
    if date is None:
        import datetime
        datetime.date.today()
    
    #Create the various parts of the URL and assemble them together
    path = '/mts/%d/%d/%d/' % (date.year, date.month, date.day)
    fname = '%s%s.mts' % (dt.strftime('%Y%m%d'), site.lower())
    baseurl='http://www.mesonet.org/public/data/getfile.php?dir=%s&filename=%s'
    
    #Open the remote location
    datafile = urllib2.urlopen(baseurl % (path+fname, fname))
    print datafile.url<commit_msg>Fix stupid bug in mesonet remote reader with default datetime.<commit_after>#!/usr/bin/env python
import numpy as np
from numpy.ma import MaskedArray

mesonet_vars = ['STID', 'STNM', 'TIME', 'RELH', 'TAIR', 'WSPD', 'WVEC', 'WDIR',
    'WDSD', 'WSSD', 'WMAX', 'RAIN', 'PRES', 'SRAD', 'TA9M', 'WS2M', 'TS10',
    'TB10', 'TS05', 'TB05', 'TS30', 'TR05', 'TR25', 'TR60', 'TR75']

def remote_mesonet_ts(site, date=None, fields=None, unpack=True):
    '''
    Reads in Oklahoma Mesonet timeseries data directly from their servers.

    site : string
        The station id for the data to be fetched.  This is
        case-insensitive.

    date : datetime object
        A python :class:`datetime` object specify that date
        for which that data should be downloaded.

    fields : sequence
        A list of the variables which should be returned.  See
        :func:`read_mesonet_ts` for a list of valid fields.

    unpack : bool
        If True, the returned array is transposed, so that arguments may be
        unpacked using ``x, y, z = remote_mesonet_ts(...)``. Defaults to True.

    Returns : array
        A nfield by ntime masked array.  nfield is the number of fields
        requested and ntime is the number of times in the file.  Each
        variable is a row in the array.  The variables are returned in
        the order given in *fields*.
    '''
    import urllib2
    
    if date is None:
        import datetime
        date = datetime.date.today()
    
    #Create the various parts of the URL and assemble them together
    path = '/mts/%d/%d/%d/' % (date.year, date.month, date.day)
    fname = '%s%s.mts' % (dt.strftime('%Y%m%d'), site.lower())
    baseurl='http://www.mesonet.org/public/data/getfile.php?dir=%s&filename=%s'
    
    #Open the remote location
    datafile = urllib2.urlopen(baseurl % (path+fname, fname))
    print datafile.url
{'fraction_non_alphanumeric': 0.11876355748373102, 'fraction_numerical': 0.01193058568329718, 'mean_word_length': 2.799176107106076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2951575', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1164, 'n_words': 423}