fractal_single_track.py 804 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
17
DirIn = 'sample_data/'
DirOut = 'output/'

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


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


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)



39
40
fractal.export_midi(normalized_climate_data, bpm=12,
                    track_type='single')