1
$\begingroup$

I am working with 13 dropsonde profiles that were launched during a field program. I have been attempting to create composite profiles of them using python, but I am a bit stuck. Here are the issues that I'm dealing with:

  1. The altitudes at which each dropsonde began its descent and ended its descent are different for each dropsonde. In addition, the altitude profiles are different for each dropsonde and therefore have differing amounts of total data points
  2. Although each dropsonde transmitted data every 0.25 seconds, the data were not transmitted the same for each dropsonde. For example, the fill value for the dropsonde data is -9999, and that value occurred at the same or similar altitude as another dropsonde that did not have a -9999 fill value at the same or similar altitude.
  3. Since there are values missing in one dropsonde at the same or similar altitude levels as other dropsondes, the calculation of the composite profiles would be skewed, since some dropsondes transmitted data at the same altitude as each other, or only one dropsonde transmitted data at a certain altitude.

Here is a sample of what the data look like:

Time_Start TimeFLStart Pressure Temperature RH Speed Direction Latitude Longitude Altitude GPS Altitude Dewpoint Uwnd Vwnd Ascent
73810.00 0.00 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999
73810.25 0.25 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999
73810.50 0.50 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999
73810.75 0.75 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999
73811.00 1.00 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999

And here is a snippet of some of the code for two dropsondes:

import numpy as np
import pandas as pd

# Read data

dropsonde_2030 = pd.read_csv('~/Dropsonde_DC8_202108212030_RA.ict', skiprows = 103)
dropsonde_2058 = pd.read_csv('~/Dropsonde_DC8_202108212058_RA.ict', skiprows = 103)

# Create variables for altitude and temperature profiles and mask the data. I sliced the altitude arrays at 0:2615 since the first array has a length of 2615.

dropsonde_2030_alt  = dropsonde_2030['GPS Altitude'].values
dropsonde_2030_alt  = np.ma.masked_where(dropsonde_2030_alt  == -9999, dropsonde_2030_alt)
dropsonde_2030_alt  = np.array([dropsonde_2030_alt])
dropsonde_2030_alt  = dropsonde_2030_alt[0,0:2615]
dropsonde_2030_temp = np.array(dropsonde_2030['Temperature'].values)
dropsonde_2030_temp = np.ma.masked_where(dropsonde_2030_temp == -9.999E3, dropsonde_2030_temp)

dropsonde_2058_alt  = dropsonde_2058['GPS Altitude'].values
dropsonde_2058_alt  = np.ma.masked_where(dropsonde_2058_alt  == -9999, dropsonde_2058_alt)
dropsonde_2058_alt  = np.array([dropsonde_2058_alt])
dropsonde_2058_alt  = dropsonde_2058_alt[0,0:2615]
dropsonde_2058_temp = dropsonde_2058['Temperature'].values
dropsonde_2058_temp = np.ma.masked_where(dropsonde_2058_temp == -9999, dropsonde_2058_temp)

# Combine dropsondes together into one array

combined = np.vstack((dropsonde_2030_alt, dropsonde_2058_alt)).T # has shape of (2615,2)

# Compute the average altitude at each point 

means_all  = []
for i in range(len(combined)):
  for j in range(len(combined[i])):
    means = np.mean(combined[i][j])
    means_all.append(means)
means_all = np.array(means_all) # Convert list back to np.array
means_all_2d = np.reshape(means_all, (2615, 2)) # Convert back to 2d array in order to take the means along axis 1
means_alt = np.mean(means_all_2d, axis = 1) 
means_alt = np.ma.masked_where(means_alt == -9999, means_alt) # Mask -9999 values

Above, I tried to calculate the average altitude profile for the two dropsondes, but I think I may be overcomplicating it. I tried to create a nested for loop in order to calculate the means at each index, but the outputted means do not look correct.

If anyone has an idea of what I should change, add, or delete, please let me know. Any feedback is greatly appreciated. Thanks in advance.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.