def CALIOP_track_on_SLSTR(SLSTR_pathname, CALIOP_pathname, SLSTR_brightness=0.2): """ Produce false colour image for SLSTR file superimposed with CALIOP track. Parameters ---------- Sreference: str or satpy Scene object SLSTR file to produce an image of. Either scene object or path to SLSTR files Plot: bool If True, plot false colour image Default is True """ # SLSTR rgb, TitleStr = FalseColour(SLSTR_pathname, plot=False, brightness=SLSTR_brightness) plt.figure('CALIOP track on SLSTR scene') plt.xlabel('km') plt.ylabel('km') plt.xticks(np.arange(0, 3000, 100), np.arange(0, 1500, 50)) plt.yticks(np.arange(0, 2400, 100), np.arange(0, 1200, 50)) plt.imshow(rgb) Stime = TitleStr.split('\n')[-1] Stime = datetime.strptime(Stime, '%Y%m%dT%H%M%S') coords = c.collocate(SLSTR_pathname, CALIOP_pathname) Srows = np.array([i[0] for i in coords]) Scols = np.array([i[1] for i in coords]) Cinds = [i[2] for i in coords] with DL.SDopener(CALIOP_pathname) as file: flags = DL.load_data(file, 'Feature_Classification_Flags')[Cinds, 0] Ctime = DL.load_data(file, 'Profile_Time')[Cinds, 0] Ctime += 725846390 Ctime1 = datetime.utcfromtimestamp(Ctime[0]) diff1 = Stime - Ctime1 if diff1.days == -1: diff1 = Ctime1 - Stime diff1 = diff1.seconds Ctime2 = datetime.utcfromtimestamp(Ctime[-1]) diff2 = Stime - Ctime2 if diff2.days == -1: diff2 = Ctime2 - Stime diff2 = diff2.seconds mindiff = min(diff1, diff2) maxdiff = max(diff1, diff2) + 180 TitleStr += '\nTime Difference: %s - %s seconds' % (mindiff, maxdiff) plt.title('False colour image with CALIPSO track\n' + TitleStr) CTruth = DL.vfm_feature_flags(flags) mask = CTruth == 2 plt.scatter(Scols[mask], Srows[mask], c='lightgreen', alpha=0.2) plt.scatter(Scols[~mask], Srows[~mask], c='lightpink', alpha=0.2) plt.show()
def get_collocation_reference_vector(self): if not self.collocation_reference_vector: self.collocation_reference_vector = \ Collocation.get_reference(self.contexts) return self.collocation_reference_vector
def collocations(word, context): return Collocation.get_vector(context, word)