TNO Intern

Commit 877a66ba authored by Arjo Segers's avatar Arjo Segers
Browse files

Add `collection` level to overview plots. Read plot title from rcfile settings.

parent 16cb6f76
Loading
Loading
Loading
Loading
+41 −29
Original line number Diff line number Diff line
#
# Changes
# 
# 2023-08, Arjo Segers
#   Add `collection` level to overview plots.
#   Read plot title from rcfile settings.
#

########################################################################
###
@@ -149,10 +156,15 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :
            filenames.append( t0.strftime( filename_template.strip() ) )
        #endfor
        
        # current time:
        t = datetime.datetime.now()

        # annotation:
        title = t.strftime( self.GetSetting( 'title' ) )
        
        # target file template:
        figfile_template = self.GetSetting( 'output.file' )
        # target file:
        t = datetime.datetime.now()
        fig_file = t.strftime( figfile_template )

        # create?
@@ -184,11 +196,6 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :
                #endif
            #endfor

            # first ...
            filename = filenames[0]
            # annote:
            title = os.path.basename( filename ).replace('.csv','').replace('_',' ')

            # frequency:
            #freq = 'MS'  ; freqlabel = 'month'
            freq = 'W'   ; freqlabel = 'week'
@@ -200,10 +207,9 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :

            # full years, extra space for text:
            t1 = pandas.Timestamp( year=t1.year  , month=1, day=1 )
            t2 = max( t2+pandas.Timedelta(180,'days'), pandas.Timestamp( year=t2.year+1, month=1, day=1 ) )
            t2 = max( t2+pandas.Timedelta(270,'days'), pandas.Timestamp( year=t2.year+1, month=1, day=1 ) )
            # annotation:
            #t2x = t2-pandas.Timedelta(50,'days')
            t2x = t2-pandas.Timedelta(20,'days')
            t2x = t2 - pandas.Timedelta(90,'days')
            
            # collections:
            collections = df['collection'].unique()
@@ -237,7 +243,7 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :
            streamh = {}

            # previous row:
            #collection_prev = ''
            collection_prev = ''
            proc_prev = ''
            # row index in plot:
            irow = 0
@@ -245,28 +251,41 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :
            fig = plt.figure( figsize=(12,4) )
            ax = fig.add_axes( [0.03,0.07,0.94,0.85] )
            # loop over collections:
            #for collection in collections :
            # ignore collection, this is mainly a change in L1B data ..
            if True :
            for collection in collections :
                # loop over processings:
                for proc in procs :

                    # loop:
                    for stream in streams :
                        ## select:
                        #df2 = df[ (df['collection'       ] == collection) & \
                        #          (df['processing'       ] == stream    ) & \
                        #          (df['processor_version'] == proc      )   ]
                        # select:
                        df2 = df[ (df['processing'       ] == stream    ) & \
                        df2 = df[ (df['collection'       ] == collection) & \
                                  (df['processing'       ] == stream    ) & \
                                  (df['processor_version'] == proc      )   ]
                        # any?
                        if len(df2) > 0 :

                            # next row:
                            irow += 1

                            # add label for new collection?
                            if collection != collection_prev :
                                # annote:
                                lab = '  C%2.2i' % int(collection)
                                # add text:
                                ax.text( t2x, irow, lab, color='red', horizontalalignment='left', verticalalignment='center' )
                                # horizontal line under collection mark:
                                if irow > 1 :
                                    ax.plot( [t1,t2], [irow-0.5,irow-0.5], color='red', linestyle='-.' )
                                #endif
                                # flag to surpress version/patch line:
                                with_cmark = True
                            else :
                                # not marked:
                                with_cmark = False
                            #endif

                            # seperation line?
                            if (irow > 1) and (proc != proc_prev) :
                            if (irow > 1) and (proc != proc_prev) and (not with_cmark) :
                                # style depends on what is changed:
                                if proc[0:2] != proc_prev[0:2] :
                                    linestyle = '-'
@@ -285,15 +304,9 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :
                                # add text:
                                ax.text( t2x, irow, proclab, horizontalalignment='right', verticalalignment='center' )
                            #endif
                            ## label?
                            #if collection != collection_prev :
                            #    # annote:
                            #    lab = '  C%i' % int(collection)
                            #    # add text:
                            #    ax.text( t2x, irow, lab, color='red', horizontalalignment='left', verticalalignment='center' )
                            ##endif

                            # store for next line:
                            #collection_prev = collection
                            collection_prev = collection
                            proc_prev       = proc

                            # group by month, count number of orbits:
@@ -312,9 +325,8 @@ class CSO_Inquire_Plot( utopya.UtopyaRc ) :

                        #endif # orbits found
                    #endfor # streams

                #endfor  # processors
            #endfor # streams
            #endfor # collections
            # time axis:
            ax.set_xlim((t1,t2))
            ax.xaxis.set_minor_locator( mdates.MonthLocator() )