使用datetime,创建一个元组,以使用来自NASA CDF fi的数据在数组中获取特定范围的值

2024-09-29 13:25:14 发布

您现在位置:Python中文网/ 问答频道 /正文

正如标题所说,我试图创建一个元组,并使用它从NASA CDF文件中获取特定范围的x、y和z值。我有用于开始和停止时间的datetime对象,我遇到了一些问题,通常会出现错误:“无法将datetime.datetime与var进行比较”

'''

####These are the arrays for the whole range of x, y and z values in arrays..

x = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][0:,0]
y = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][0:,1]
z = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][0:,2]


###These are the datetime values to be used as interval bounds..
### Filedate & n aren't impoortant, the point is these two datetiem objects will be used...

start_Time = Filedate - datetime.timedelta(hours = n)
end_Time = Filedate - datetime.timedelta(hours = n)

### This is the tuple, it needs to be full of datetime objects that will be used to set bounds
### to get a specific set of x,y and z values...

tloc = (FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'] >= start_Time,
        FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'] <= end_Time)                               


###Here im using the tuple to get the specific x,y and z values

orb_x = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][:,0:tloc]
orb_y = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][:,1:tloc]
orb_z = FGMdata['sc_pos_xyz_gse__C1_CP_FGM_SPIN'][:,2:tloc]


###Print statement im using to test values...
for x in orb_x:
    print x

'''


Tags: thetoposdatetimetimebecpvalues