fractal_single_track.py 785 Bytes
Newer Older
ecofractal's avatar
ecofractal committed
1 2 3 4 5 6 7 8 9 10 11
'''
This is a fractaL code developed to sonify data.
Partially based on Sonify library.

@author: smjacques
'''
import json
import matplotlib.pyplot as plt
import pandas as pd

import fractaL.core as fractal
12

ecofractal's avatar
ecofractal committed
13

14 15 16
DirIn = 'sample_data/'

FileNameIn = '1880-2019.json'
ecofractal's avatar
ecofractal committed
17 18


19 20
with open(DirIn + FileNameIn) as data_file:    
    climate_json = json.load(data_file)
ecofractal's avatar
ecofractal committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37


normalized_climate_data = fractal.normalize_climate_data(climate_json)
plt.scatter(*zip(*normalized_climate_data))

#print(normalized_climate_data)


'''
Convert Array to pandas
'''
#define labels date and temperature
labels = ['date', 'temperature']
climatefile = pd.DataFrame.from_records(normalized_climate_data, columns=labels)



38
fractal.export_midi(normalized_climate_data, bpm=15,
39
                    track_type='single')