# Count the number of orbits from this Orbit Data?

**URL:** <https://community.wolfram.com/t/count-the-number-of-orbits-from-this-orbit-data/13653>\
**Category:** Questions\
**Tags:** physics, signal-processing, graphics-and-visualization\
**Created:** [February 9, 2019, 4:27am UTC](https://community.wolfram.com/t/count-the-number-of-orbits-from-this-orbit-data/13653 "2019-02-09T04:27:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjpraseu](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tjpraseu](https://community.wolfram.com/u/tjpraseu)\
**Post date:** [February 9, 2019, 4:27am UTC](https://community.wolfram.com/t/count-the-number-of-orbits-from-this-orbit-data/13653/1 "2019-02-09T04:27:12Z")

</div>

![orbit.JPG](https://global.discourse-cdn.com/wolfram/original/2X/d/dc8213d64a7af204c97d04d4d90fce86098a8eb6.jpeg)

If the y-axis in the image corresponds to MLT, and we are looking at a number of orbits. How do you interpret the way the lines are with respect to an orbit?

If I zoom in closer:

 ![orbit2.JPG](https://global.discourse-cdn.com/wolfram/original/2X/f/fb922f1f899b817cd50d12b440478ed6880038a1.jpeg)

My loop double counts the number of orbits because of this issue.

I need to be able to cut it off as appropriate and there is alot of data.

```
orbitStarts = {};
orbitEnds = {};
inOrbit = False;
sd2T = Transpose[sd2];
For[i = 1, i <= Length[sd2[[1]]], i++,
  sdtemp = sd2T[[i]];
  If[sdtemp[[2]] >= 40 && 
    sdtemp[[2]] <= 80 && (sdtemp[[3]] >= 18 || sdtemp[[3]] <= 6),
   If[inOrbit, Continue,
     inOrbit = True;
     AppendTo[orbitStarts, i];];
   , If[inOrbit, inOrbit = False; AppendTo[orbitEnds, i];, Continue]];
  
  ];
If[inOrbit, inOrbit = False; AppendTo[orbitEnds, i];];

```

The condition in the loop filters for lat 40\<x\<80 and nightside MLT 18 hr \< x \< 6 hr.

One could use a median on the filter, to check the last 10 data points before actually ending an orbit. Is this the best approach?

What do you recommend?
