<commit_before>"""
plots.py
"""

from matplotlib import pylab as plt
import datetime

def visPlot(timeSeries):
  """
  plots visible wavebands
  """

  vizBandSwitch = {
    'Sentinel2':('B2','B3','B4'),
    'Landsat8':('B2','B3','B4'),
    'Landsat7':('B1','B2','B3'),
    'Landsat5':('B1','B2','B3'),
    'Landsat4':('B1','B2','B3')

  }

  vizBands = vizBandSwitch[timeSeries['mission']]

  plt.plot(timeSeries['dates'], timeSeries[vizBands[0]], 'blue')
  plt.plot(timeSeries['dates'], timeSeries[vizBands[1]], 'green')
  plt.plot(timeSeries['dates'], timeSeries[vizBands[2]], 'red')
  plt.title('RGB')
  plt.show()

def nirPlot(timeSeries):

  nirSwitch = {
    'Sentinel2':{'bands':['B5','B6','B7','B7'],
                 'colors':['#cbc9e2', '#9e9ac8', '#756bb1', '#54278f'],
                 'labels':['705 nm', '740 nm', '783 nm', '842 nm']},

    'Landsat8':{'bands':['B5'],
                 'colors':['#cbc9e2'],
                 'labels':['865 nm']},

    'Landsat7':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']},

    'Landsat5':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']},

    'Landsat4':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']}

  }

  config = nirSwitch[timeSeries['mission']]

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
  
  plt.title('Near Infrared')
  plt.legend()
  plt.show()

def swirPlot(timeSeries):

  swirSwitch = {
    'Sentinel2':{'bands':['B11','B12'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1610 nm', '2190 nm']},

    'Landsat8':{'bands':['B6','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1610 nm', '2200 nm']},

    'Landsat7':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']},

    'Landsat5':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']},

    'Landsat4':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']}

  }

  config = swirSwitch[timeSeries['mission']]

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
  
  plt.title('Short-wave Infrared')
  plt.legend()
  plt.show()

def atmPlot(timeSeries):

  atmSwitch = {
    'Sentinel2':{'bands':['B1','B9','B10'],
                 'colors':['#c994c7', '#225ea8', '#c7e9b4'],
                 'labels':['aerosol (443 nm)', 'water vapour (940 nm)', 'cirrus (1375 nm)']},

    'Landsat8':{'bands':['B1','B9'],
                 'colors':['#c994c7','#c7e9b4'],
                 'labels':['aerosol (440 nm)', 'cirrus (1370 nm)']},

    'Landsat7':None,

    'Landsat5':None,

    'Landsat4':None

  }

  config = atmSwitch[timeSeries['mission']]

  if not config:
    return None

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
    
  plt.title('Atmospheric')
  plt.legend()
  plt.show()

def plot_timeseries(timeSeries, plotType):
  
  timeSeries['dates'] = [datetime.datetime.utcfromtimestamp(dt) for dt in timeSeries['timeStamp']]
  
  switch = {
    'visible':visPlot,
    'nir':nirPlot,
    'swir':swirPlot,
    'atmospheric':atmPlot
  }
  
  return switch[plotType](timeSeries)






<commit_msg>ylim [0,1] allplots<commit_after>"""
plots.py
"""

from matplotlib import pylab as plt
import datetime

def visPlot(timeSeries):
  """
  plots visible wavebands
  """

  vizBandSwitch = {
    'Sentinel2':('B2','B3','B4'),
    'Landsat8':('B2','B3','B4'),
    'Landsat7':('B1','B2','B3'),
    'Landsat5':('B1','B2','B3'),
    'Landsat4':('B1','B2','B3')

  }

  vizBands = vizBandSwitch[timeSeries['mission']]

  plt.plot(timeSeries['dates'], timeSeries[vizBands[0]], 'blue')
  plt.plot(timeSeries['dates'], timeSeries[vizBands[1]], 'green')
  plt.plot(timeSeries['dates'], timeSeries[vizBands[2]], 'red')
  plt.title('RGB')
  plt.ylim([0,1])
  plt.show()

def nirPlot(timeSeries):

  nirSwitch = {
    'Sentinel2':{'bands':['B5','B6','B7','B7'],
                 'colors':['#cbc9e2', '#9e9ac8', '#756bb1', '#54278f'],
                 'labels':['705 nm', '740 nm', '783 nm', '842 nm']},

    'Landsat8':{'bands':['B5'],
                 'colors':['#cbc9e2'],
                 'labels':['865 nm']},

    'Landsat7':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']},

    'Landsat5':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']},

    'Landsat4':{'bands':['B4'],
                 'colors':['#cbc9e2'],
                 'labels':['830 nm']}

  }

  config = nirSwitch[timeSeries['mission']]

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
  
  plt.title('Near Infrared')
  plt.ylim([0,1])
  plt.legend()
  plt.show()

def swirPlot(timeSeries):

  swirSwitch = {
    'Sentinel2':{'bands':['B11','B12'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1610 nm', '2190 nm']},

    'Landsat8':{'bands':['B6','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1610 nm', '2200 nm']},

    'Landsat7':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']},

    'Landsat5':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']},

    'Landsat4':{'bands':['B5','B7'],
                 'colors':['#993404', '#fe9929'],
                 'labels':['1650 nm', '2270 nm']}

  }

  config = swirSwitch[timeSeries['mission']]

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
  
  plt.title('Short-wave Infrared')
  plt.ylim([0,1])
  plt.legend()
  plt.show()

def atmPlot(timeSeries):

  atmSwitch = {
    'Sentinel2':{'bands':['B1','B9','B10'],
                 'colors':['#c994c7', '#225ea8', '#c7e9b4'],
                 'labels':['aerosol (443 nm)', 'water vapour (940 nm)', 'cirrus (1375 nm)']},

    'Landsat8':{'bands':['B1','B9'],
                 'colors':['#c994c7','#c7e9b4'],
                 'labels':['aerosol (440 nm)', 'cirrus (1370 nm)']},

    'Landsat7':None,

    'Landsat5':None,

    'Landsat4':None

  }

  config = atmSwitch[timeSeries['mission']]

  if not config:
    return None

  for i, band in enumerate(config['bands']):
    plt.plot(timeSeries['dates'], timeSeries[band], config['colors'][i], label=config['labels'][i])
    
  plt.title('Atmospheric')
  plt.ylim([0,1])
  plt.legend()
  plt.show()

  return 1

def plot_timeseries(timeSeries, plotType):
  
  timeSeries['dates'] = [datetime.datetime.utcfromtimestamp(dt) for dt in timeSeries['timeStamp']]
  
  switch = {
    'visible':visPlot,
    'nir':nirPlot,
    'swir':swirPlot,
    'atmospheric':atmPlot
  }
  
  return switch[plotType](timeSeries)







{'fraction_non_alphanumeric': 0.23663393344244407, 'fraction_numerical': 0.06560283687943262, 'mean_word_length': 3.0379955947136565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4962563', 'n_tokens_mistral': 3040, 'n_tokens_neox': 2712, 'n_words': 402}