How to add a 2nd dimension and “altitude dependency” to Xarray Dataset variables that are currently only time dependent

I currently am working with atmospheric data that came from multiple files separated in time (time discontinuous). I loaded in the netCDF files using the xarray open_mfdataset function and combined the files “by_coords”. All of this data, however, is strictly time-dependent only when I open the Dataset. Provided is a snippet of what the data looks like when opened. The main variables I am concerned about here would be “pres” (pressure) and “tdry” (temperature). There are many other variables in this Dataset as well such as wind components, wind speed/direction, relative humidity, etc. My problem here is I want each of the data variables to also be dependent on the coordinate seen here as “gpsalt” or altitude/height. For example, only time is attached to each temperature value and I would want altitude to also be attached to the same temperature value with the respective correct altitude value.

Currently what I have tried is simply adding the gpsalt variable as an expanded dimension to the Dataset and labeling it as “altitude”. I took the specific values of altitude as an array and expanded the dataset dimensions. I’m assuming (could be an incorrect assumption) that this takes the indexes of the gpsalt value and aligns them with the other “time” dimension too.

gpsalt_data = (ds['gpsalt'].values)
ds = ds.expand_dims(altitude = gpsalt_data, axis=1)

ds

With this I get the following dataset where “altitude” is added to the data variables:

With this I’m assuming that the time and altitude values “match up” exactly where they should (i.e. the 5th index of time should accurately be the 5th index of altitude too in the dataset. So time and altitude should align and thus the temperature value at those [5,5] indexing should be correct as well.) I don’t know if this is correct though. The next step I want to take is resampling the Dataset to a new resolution of altitude data. To do so, I’m using the xarray.interp function:

new_gpsalt = np.linspace(ds.gpsalt.min().compute(), ds.gpsalt.max().compute(), new_time.size)
ds = ds.interp(altitude=new_gpsalt, method='linear')

But I get the following error:

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

The end goal of this is for me to resample and interpolate the atmospheric data values, which are time discontinuous, in height and time. So I want to fill in the data gaps between time by interpolating between data variables at similar heights. Could anyone provide any insight and help as to if this is the correct way about doing this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật