Exemple #1
0
def crnsong_01():
    parser = crnparsers.HourlyCrnParser()

    # Get six stations that pretty much cover CONUS
    stations = parser.find_stations(('Darrington', 'Barbara', 'Northgate', 'Port Aransas', 'Old Town', 'Brunswick'))
    print stations

    fields = set(('T_CALC', 'SOIL_TEMP_10', 'SOIL_TEMP_50', 'SOLARAD', 'P_CALC'))
    #fields = set(('T_CALC', 'SOLARAD', 'SOIL_TEMP_10', 'SOIL_TEMP_50'))
    years = range(2008, 2013)
    doc = parser.parse(stations, years, fields)
    assert len(doc) == len(stations)
    doc.combine_all_ranges()

    # MIDI output
    mrenderer = MidiCCRenderer(sample_rate=24) #24 is the natural fit.
    sine_to_midi_map = {'T_CALC': 74, 'SOIL_TEMP_10': 75, 'SOIL_TEMP_50' : 76, 'SOLARAD' : 77, 'P_CALC' : 78} # sine to cc# # 1 is mod wheel, for bowing using the Serenade reaktor patch
    #sine_to_midi_map = {'T_CALC': 74, 'SOLARAD': 75, 'SOIL_TEMP_10': 76, 'SOIL_TEMP_50' : 77}
    transformed_doc = doc.transform(sine_to_midi_map, mrenderer)

    # Create graph
    vrenderer = LineGraphRenderer()
    # No mapping because LineGraphRenderer doesn't need one.
    vrenderer.render(transformed_doc, showplot=True, outfile='/tmp/test.svg')

    # Output MIDI
    mrenderer.render(transformed_doc, output_file='t.mid')
Exemple #2
0
def crnsong_01():
    parser = crnparsers.HourlyCrnParser()

    # Get six stations that pretty much cover CONUS
    stations = parser.find_stations(('Darrington', 'Barbara', 'Northgate',
                                     'Port Aransas', 'Old Town', 'Brunswick'))
    print stations

    fields = set(
        ('T_CALC', 'SOIL_TEMP_10', 'SOIL_TEMP_50', 'SOLARAD', 'P_CALC'))
    #fields = set(('T_CALC', 'SOLARAD', 'SOIL_TEMP_10', 'SOIL_TEMP_50'))
    years = range(2008, 2013)
    doc = parser.parse(stations, years, fields)
    assert len(doc) == len(stations)
    doc.combine_all_ranges()

    # MIDI output
    mrenderer = MidiCCRenderer(sample_rate=24)  #24 is the natural fit.
    sine_to_midi_map = {
        'T_CALC': 74,
        'SOIL_TEMP_10': 75,
        'SOIL_TEMP_50': 76,
        'SOLARAD': 77,
        'P_CALC': 78
    }  # sine to cc# # 1 is mod wheel, for bowing using the Serenade reaktor patch
    #sine_to_midi_map = {'T_CALC': 74, 'SOLARAD': 75, 'SOIL_TEMP_10': 76, 'SOIL_TEMP_50' : 77}
    transformed_doc = doc.transform(sine_to_midi_map, mrenderer)

    # Create graph
    vrenderer = LineGraphRenderer()
    # No mapping because LineGraphRenderer doesn't need one.
    vrenderer.render(transformed_doc, showplot=True, outfile='/tmp/test.svg')

    # Output MIDI
    mrenderer.render(transformed_doc, output_file='t.mid')
Exemple #3
0
def test_end_to_end_sines():
    parser = SineDictParser()
    sines = generate_sines(3, 40)
    doc = parser.parse(sines)
    renderer = LineGraphRenderer()
    plot = renderer.render(doc, showplot=False)
    assert plot.__sizeof__() == 16 # not many assert options on these objects
Exemple #4
0
def test_buoy_parser_01():
    parser = buoyparsers.GlobalDrifterParser()
    doc = parser.parse('test_resources/buoydata.dat')
    doc.intify()
#     doc = parser.parse('/Users/egg/Temp/oceancurrents/globaldrifter/buoydata_5001_sep12.dat')
    renderer = LineGraphRenderer()
    # No mapping because LineGraphRenderer doesn't need one.
    plot = renderer.render(doc, showplot=False, outfile='/tmp/test.svg')
    assert plot.__sizeof__() == 16
Exemple #5
0
def test_crn_parser_01():
    ''' fetches from the website, so may not want to always run. Built to fetch data at a 
    minimum granularity of 1 station-year, so can't be made much smaller. '''
    parser = crnparsers.HourlyCrnParser()
    stations = parser.find_stations('Torrey')
    assert len(stations) == 1, 'Finding the "Torrey" station should return exactly one station'
    fields = set(('T_CALC', 'SOLARAD'))
    doc = parser.parse(stations, [2012], fields=fields)
    assert len(doc) == 1
    assert len(doc[0]) == len(fields)

    #TODO add mapping for LGR for cases where we don't want to graph everything?

    renderer = LineGraphRenderer()
    # No mapping because LineGraphRenderer doesn't need one.
    plot = renderer.render(doc, showplot=True, outfile='/tmp/test.svg')
    assert plot.__sizeof__() == 16
Exemple #6
0
def graph(doc, keys=None):
    renderer = LineGraphRenderer()
    plot = renderer.render(doc, showplot=True, outfile='/tmp/plot.svg', keys=keys, render_separate=True)
    return plot