Commit 391d581c7281ce471f250a4cbd710e5a79837e89

Authored by Goutte
1 parent 32a46001

Make the CDF download more resilient to NaNs in the data.

Showing 1 changed file with 11 additions and 2 deletions   Show diff stats
@@ -1039,6 +1039,8 @@ def download_targets_cdf(targets, inp, started_at, stopped_at): @@ -1039,6 +1039,8 @@ def download_targets_cdf(targets, inp, started_at, stopped_at):
1039 environ['CDF_LIB'] = CDF_LIB 1039 environ['CDF_LIB'] = CDF_LIB
1040 from spacepy import pycdf 1040 from spacepy import pycdf
1041 try: 1041 try:
  1042 + # todo: maybe move this to the daily cache warmup ?
  1043 + log.info("Updating spacepy's table of leap seconds…")
1042 import spacepy.toolbox 1044 import spacepy.toolbox
1043 spacepy.toolbox.update() 1045 spacepy.toolbox.update()
1044 except Exception as e: 1046 except Exception as e:
@@ -1091,8 +1093,15 @@ def download_targets_cdf(targets, inp, started_at, stopped_at): @@ -1091,8 +1093,15 @@ def download_targets_cdf(targets, inp, started_at, stopped_at):
1091 index_x = available_params.index('xhee') 1093 index_x = available_params.index('xhee')
1092 index_y = available_params.index('yhee') 1094 index_y = available_params.index('yhee')
1093 for dkey in dkeys: 1095 for dkey in dkeys:
1094 - values_xhee.append(data[dkey][index_x])  
1095 - values_yhee.append(data[dkey][index_y]) 1096 + value_xhee = data[dkey][index_x]
  1097 + value_yhee = data[dkey][index_y]
  1098 + # We've got some `None`s cropping up in the data sometimes.
  1099 + # While they solve this upstream, let's make an ugly fix!
  1100 + if (value_xhee is not None) and (value_yhee is not None):
  1101 + values_xhee.append(value_xhee)
  1102 + values_yhee.append(value_yhee)
  1103 + else:
  1104 + log.warn("Orbit data for %s has NaNs." % target_slug)
1096 cdf_handle[kx] = values_xhee 1105 cdf_handle[kx] = values_xhee
1097 cdf_handle[ky] = values_yhee 1106 cdf_handle[ky] = values_yhee
1098 cdf_handle[kx].attrs['UNITS'] = 'Au' 1107 cdf_handle[kx].attrs['UNITS'] = 'Au'