mardi 8 septembre 2020

How to print intervals of data in a for loop (if else statement)? Python Question

Hi everyone! I read in a CDF file with the date, time, latitude, and longitude of a satellite in orbit. I am trying to write up a txt file that saves the data every time the satellite hovers over an Arctic station (I have it's LAT and LON with a small error value).

I managed to save a txt file with the appropriate conditions, but it is way too much data to look through and outputs this:

2013-01-09 02:05:00 -57.097008 40.165134

2013-01-09 02:06:00 -57.29849 40.504826

2013-01-09 02:07:00 -57.49554 40.834732

2013-01-09 02:08:00 -57.68884 41.154243

2013-01-09 02:09:00 -57.881386 41.45857

etc.

Several years of data equals way too much to handle... Essentially, I want to find a way for the code to show intervals of time. So instead of minute by minute, it would be more like:

2013-09-01 02:00:00 ~ 2013-09-01 02:14:00

2013-10-05 04:23:00 ~ 2013-10-05 04:32:00

The code I used was:

#Loop Count
count = 0

with open("example.txt", "a") as testing:
    for i, j in zip(LAT, LON):
        if(-65.26 <= i <= -59.26 and 32.31 <= j <= 52.31):            
            count +=1
            n = count
            testing.write(str(TIME[n-1])+'\t'+str(i)+'\t'+str(j)+ '\n')
           
       
        else:
            count +=1

Apologies if my question is confusing. I am new to programming and never used stackoverflow either.

Aucun commentaire:

Enregistrer un commentaire