Home > database >  Delete several elements from array
Delete several elements from array

Time:01-04

I have this data :

Temperature = [1054.36258, 1092.96819, 1051.45602, 1058.94926, 1083.66115, 1080.66721
, 1046.96163, 1018.42441, 1049.44307, 1068.91551, 1018.44764, 1035.11906
, 1020.44599,  993.275818 1037.41013, 1005.4047,  1025.73646,  975.301913
, 1000.45743, 1033.21562, 1037.31104,  968.730834, 907.474634, 930.465587
, 998.967526, 911.791887, 915.951873, 829.331306, 931.702088, 890.075633
, 830.659093, 878.715978, 866.238768, 897.958014, 940.495055, 841.990924
, 875.391469, 898.393043, 925.048353, 931.445104, 904.151363, 965.550728
, 916.348809, 936.315168, 900.445995, 887.76832,  875.064126, 881.480871
, 878.240278, 862.958271, 893.813659, 883.678318, 923.593998, 915.52458
, 877.919073, 891.754242, 919.274917, 862.223914, 881.275387, 862.33147
, 869.461632, 890.014577, 902.656117, 874.446393, 876.284046, 866.751916
, 854.095049, 844.540741, 870.263794, 866.687327, 818.019291, 821.875267
, 813.385138, 843.198211, 870.558259, 794.039978, 813.497634, 812.217789
, 801.361143, 800.263045, 747.101493, 735.923635, 732.930255, 775.930026
, 783.786631, 775.255742, 774.938671, 704.186773, 747.612911, 729.315237
, 694.021293, 742.723487, 709.890191, 760.674339, 751.491228, 723.875166
, 741.451471, 749.69441,  743.337883, 700.286359, 720.250078, 732.189596
, 693.097572, 782.342462, 711.995854, 684.432159, 761.195087, 746.725427
, 744.614939, 648.985204, 676.023106, 689.141056, 627.855922, 707.298358
, 652.207871, 652.609278, 680.52524,  689.328581, 678.148423, 728.229663
, 691.857497, 743.998987, 696.885527, 733.249599, 722.833678, 734.832942
, 719.049095, 703.573908, 711.15146,  689.345427]

and :

time =[datetime.datetime(2015, 11, 7, 18, 14, 24),
 datetime.datetime(2015, 11, 7, 18, 19, 12),
 datetime.datetime(2015, 11, 7, 18, 23, 9),
 datetime.datetime(2015, 11, 7, 18, 26, 38),
 datetime.datetime(2015, 11, 7, 18, 29, 55),
 datetime.datetime(2015, 11, 7, 18, 32, 52),
 datetime.datetime(2015, 11, 7, 18, 35, 36),
 datetime.datetime(2015, 11, 7, 18, 38, 26),
 datetime.datetime(2015, 11, 7, 18, 41, 13),
 datetime.datetime(2015, 11, 7, 18, 44, 16),
 datetime.datetime(2015, 11, 7, 18, 47, 12),
 datetime.datetime(2015, 11, 7, 18, 50, 1),
 datetime.datetime(2015, 11, 7, 18, 53, 2),
 datetime.datetime(2015, 11, 7, 18, 56, 17),
 datetime.datetime(2015, 11, 7, 18, 59, 45),
 datetime.datetime(2015, 11, 7, 19, 3, 14),
 datetime.datetime(2015, 11, 7, 19, 6, 28),
 datetime.datetime(2015, 11, 7, 19, 10, 4),
 datetime.datetime(2015, 11, 7, 19, 13, 46),
 datetime.datetime(2015, 11, 7, 19, 17, 47),
 datetime.datetime(2015, 11, 7, 19, 21, 35),
 datetime.datetime(2015, 11, 7, 19, 25, 15),
 datetime.datetime(2015, 11, 7, 19, 29, 22),
 datetime.datetime(2015, 11, 7, 19, 33, 41),
 datetime.datetime(2015, 11, 7, 19, 38, 38),
 datetime.datetime(2015, 11, 7, 19, 43, 16),
 datetime.datetime(2015, 11, 7, 19, 47, 53),
 datetime.datetime(2015, 11, 7, 19, 53, 21),
 datetime.datetime(2015, 11, 7, 19, 59, 4),
 datetime.datetime(2015, 11, 7, 20, 5, 14),
 datetime.datetime(2015, 11, 7, 20, 11, 6),
 datetime.datetime(2015, 11, 7, 20, 17, 7),
 datetime.datetime(2015, 11, 7, 20, 24, 11),
 datetime.datetime(2015, 11, 7, 20, 31, 5),
 datetime.datetime(2015, 11, 7, 20, 50, 8),
 datetime.datetime(2015, 11, 7, 20, 54, 31),
 datetime.datetime(2015, 11, 7, 20, 59, 28),
 datetime.datetime(2015, 11, 7, 21, 4, 54),
 datetime.datetime(2015, 11, 7, 21, 10, 24),
 datetime.datetime(2015, 11, 7, 21, 15, 56),
 datetime.datetime(2015, 11, 7, 21, 21, 50),
 datetime.datetime(2015, 11, 7, 21, 33, 24),
 datetime.datetime(2015, 11, 7, 21, 37, 54),
 datetime.datetime(2015, 11, 7, 21, 42, 24),
 datetime.datetime(2015, 11, 7, 21, 47, 20),
 datetime.datetime(2015, 11, 7, 21, 52, 12),
 datetime.datetime(2015, 11, 7, 21, 57, 3),
 datetime.datetime(2015, 11, 7, 22, 1, 41),
 datetime.datetime(2015, 11, 7, 22, 6, 21),
 datetime.datetime(2015, 11, 7, 22, 11, 30),
 datetime.datetime(2015, 11, 7, 22, 16, 44),
 datetime.datetime(2015, 11, 7, 22, 21, 59),
 datetime.datetime(2015, 11, 7, 22, 26, 56),
 datetime.datetime(2015, 11, 7, 22, 32),
 datetime.datetime(2015, 11, 7, 22, 37, 43),
 datetime.datetime(2015, 11, 7, 22, 43, 21),
 datetime.datetime(2015, 11, 7, 22, 48, 45),
 datetime.datetime(2015, 11, 7, 22, 53, 49),
 datetime.datetime(2015, 11, 7, 22, 58, 49),
 datetime.datetime(2015, 11, 7, 23, 4, 4),
 datetime.datetime(2015, 11, 7, 23, 9, 8),
 datetime.datetime(2015, 11, 7, 23, 14, 3),
 datetime.datetime(2015, 11, 7, 23, 18, 34),
 datetime.datetime(2015, 11, 7, 23, 22, 58),
 datetime.datetime(2015, 11, 7, 23, 27, 43),
 datetime.datetime(2015, 11, 7, 23, 32, 22),
 datetime.datetime(2015, 11, 7, 23, 36, 48),
 datetime.datetime(2015, 11, 7, 23, 41, 9),
 datetime.datetime(2015, 11, 7, 23, 45, 29),
 datetime.datetime(2015, 11, 7, 23, 49, 59),
 datetime.datetime(2015, 11, 7, 23, 54, 34),
 datetime.datetime(2015, 11, 7, 23, 59, 6),
 datetime.datetime(2015, 11, 8, 0, 3, 37),
 datetime.datetime(2015, 11, 8, 0, 8, 17),
 datetime.datetime(2015, 11, 8, 0, 13, 15),
 datetime.datetime(2015, 11, 8, 0, 18, 22),
 datetime.datetime(2015, 11, 8, 0, 23, 23),
 datetime.datetime(2015, 11, 8, 0, 28, 28),
 datetime.datetime(2015, 11, 8, 0, 33, 59),
 datetime.datetime(2015, 11, 8, 0, 39, 51),
 datetime.datetime(2015, 11, 8, 0, 45, 56),
 datetime.datetime(2015, 11, 8, 0, 51, 57),
 datetime.datetime(2015, 11, 8, 0, 57, 48),
 datetime.datetime(2015, 11, 8, 1, 4, 2),
 datetime.datetime(2015, 11, 8, 1, 10, 47),
 datetime.datetime(2015, 11, 8, 1, 17, 43),
 datetime.datetime(2015, 11, 8, 1, 24, 22),
 datetime.datetime(2015, 11, 8, 1, 30, 39),
 datetime.datetime(2015, 11, 8, 1, 37, 2),
 datetime.datetime(2015, 11, 8, 1, 43, 51),
 datetime.datetime(2015, 11, 8, 1, 50, 38),
 datetime.datetime(2015, 11, 8, 1, 57, 23),
 datetime.datetime(2015, 11, 8, 2, 4, 3),
 datetime.datetime(2015, 11, 8, 2, 10, 46),
 datetime.datetime(2015, 11, 8, 2, 18, 6),
 datetime.datetime(2015, 11, 8, 2, 25, 14),
 datetime.datetime(2015, 11, 8, 2, 32, 30),
 datetime.datetime(2015, 11, 8, 2, 39, 35),
 datetime.datetime(2015, 11, 8, 2, 46, 49),
 datetime.datetime(2015, 11, 8, 2, 54, 43),
 datetime.datetime(2015, 11, 8, 3, 2, 33),
 datetime.datetime(2015, 11, 8, 3, 10, 15),
 datetime.datetime(2015, 11, 8, 3, 17, 28),
 datetime.datetime(2015, 11, 8, 3, 24, 30),
 datetime.datetime(2015, 11, 8, 3, 32, 8),
 datetime.datetime(2015, 11, 8, 3, 39, 13),
 datetime.datetime(2015, 11, 8, 3, 46, 10),
 datetime.datetime(2015, 11, 8, 3, 52, 48),
 datetime.datetime(2015, 11, 8, 3, 59, 1),
 datetime.datetime(2015, 11, 8, 4, 5, 39),
 datetime.datetime(2015, 11, 8, 4, 11, 59),
 datetime.datetime(2015, 11, 8, 4, 18, 27),
 datetime.datetime(2015, 11, 8, 4, 24, 49),
 datetime.datetime(2015, 11, 8, 4, 31, 7),
 datetime.datetime(2015, 11, 8, 4, 39, 18),
 datetime.datetime(2015, 11, 8, 4, 46, 26),
 datetime.datetime(2015, 11, 8, 4, 53, 13),
 datetime.datetime(2015, 11, 8, 5, 0, 11),
 datetime.datetime(2015, 11, 8, 5, 8, 57),
 datetime.datetime(2015, 11, 8, 5, 15, 45),
 datetime.datetime(2015, 11, 8, 5, 22, 6),
 datetime.datetime(2015, 11, 8, 5, 28, 5),
 datetime.datetime(2015, 11, 8, 5, 34, 57),
 datetime.datetime(2015, 11, 8, 5, 40, 4),
 datetime.datetime(2015, 11, 8, 5, 44, 45),
 datetime.datetime(2015, 11, 8, 5, 49, 8),
 datetime.datetime(2015, 11, 8, 5, 54, 41),
 datetime.datetime(2015, 11, 8, 5, 58, 46),
 datetime.datetime(2015, 11, 8, 6, 2, 35),
 datetime.datetime(2015, 11, 8, 6, 6, 18)]

ploted like this :

enter image description here

My objectif is to delete the elements between index 27 and 90, in the red region below :

enter image description here

By using this code :

time_2 = np.delete(time, slice(27, 90 1))
Temperature_2 = np.delete(Temperature, slice(27, 90 1))

But by ploting, I found a figure like this :

enter image description here

I want to delete the red region below ?

enter image description here

I want to delete this red region in order to be able to found an appropriate fuction for fitting.

CodePudding user response:

The responce given in the comments "Just plot the dataset twice in the same figure, once with the left selection, once with the right selection. – 9769953"

Is correct. Two separate plots would work quite well. With that said, it all depends on what you truly mean by delete. What num py is doing i believe is trying to draw a line from each point to the next. So when you remove a bunch of entries, numpy is still trying to connect the dots and will just draw a line from the last point to the start of the new one. its purely visual and you should be able to add in data where you deleted the old ones and itll appear as you would expect.

CodePudding user response:

You can set the color of the unwanted range to white:

import matplotlib.pyplot as plt
plt.plot(time[:27], Temperature[:27], 'g--')
plt.plot(time[91:], Temperature[91:], 'g--')
plt.plot(time[27:91], Temperature[27:91], 'w');

Output:

enter image description here

  •  Tags:  
  • Related