@@ -44,6 +44,28 @@ def print_sinex_comments(file):
4444 if line .startswith ('-FILE/COMMENT' ):
4545 go = False
4646
47+ def read_sinex_comments (file ):
48+ """This function reads comments in a SINEX file.
49+
50+ :param str file: the input SINEX file
51+ :return: comments block
52+ :rtype: list of strings
53+ """
54+ comments = []
55+ go = False
56+ with open (file ) as f :
57+ for line in f .readlines ():
58+ if line .startswith ('+FILE/COMMENT' ):
59+ go = True
60+ if go :
61+ comments .append (line .strip ())
62+ if line .startswith ('-FILE/COMMENT' ):
63+ go = False
64+
65+ comments .insert (- 1 ,f"* File created by Geodepy.gnss.py at { datetime .now ().strftime ('%d-%m-%Y, %H:%M' )} " )
66+
67+ return comments
68+
4769
4870def set_creation_time ():
4971 """This function sets the creation time, in format YY:DDD:SSSSS, for use
@@ -588,6 +610,15 @@ def remove_stns_sinex(sinex, sites):
588610 header = header .replace (str (old_num_params ), str (num_params ))
589611 out .write (header )
590612
613+ out .write ("*-------------------------------------------------------------------------------\n " )
614+
615+ # Read in the +FILE/COMMENT block and write to output file
616+ comments = read_sinex_comments (sinex )
617+ for i in comments :
618+ out .write (f"{ i } \n " )
619+
620+ out .write ("*-------------------------------------------------------------------------------\n " )
621+
591622 # Read in the site ID block and write out the sites not being removed
592623 site_id = read_sinex_site_id_block (sinex )
593624 for line in site_id :
@@ -600,6 +631,8 @@ def remove_stns_sinex(sinex, sites):
600631 out .write (line )
601632 del site_id
602633
634+ out .write ("*-------------------------------------------------------------------------------\n " )
635+
603636 # Read in the solution epochs block and write out the epochs of the
604637 # sites not being removed
605638 solution_epochs = read_sinex_solution_epochs_block (sinex )
@@ -613,6 +646,8 @@ def remove_stns_sinex(sinex, sites):
613646 out .write (line )
614647 del solution_epochs
615648
649+ out .write ("*-------------------------------------------------------------------------------\n " )
650+
616651 # Read in the solution estimate block and write out the estimates of
617652 # the sites not being removed
618653 skip = []
@@ -634,6 +669,8 @@ def remove_stns_sinex(sinex, sites):
634669 out .write (line )
635670 del solution_estimate
636671
672+ out .write ("*-------------------------------------------------------------------------------\n " )
673+
637674 # Read in the matrix estimate block and write out minus the sites
638675 # being removed
639676 vcv = {}
@@ -734,12 +771,23 @@ def remove_velocity_sinex(sinex):
734771 header = header .replace ('V' , '' )
735772 out .write (header )
736773 del header
774+
775+ out .write ("*-------------------------------------------------------------------------------\n " )
776+
777+ # Read in the +FILE/COMMENT block and write to output file
778+ comments = read_sinex_comments (sinex )
779+ for i in comments :
780+ out .write (f"{ i } \n " )
781+
782+ out .write ("*-------------------------------------------------------------------------------\n " )
737783
738784 # Read in the +SITE/ID block and write to file
739785 site_id = read_sinex_site_id_block (sinex )
740786 for line in site_id :
741787 out .write (f"{ line } " )
742788 del site_id
789+
790+ out .write ("*-------------------------------------------------------------------------------\n " )
743791
744792 # Read in the +SOLUTION/EPOCHS block and write to file
745793 # - also collect count on number of sites for use later
@@ -751,6 +799,8 @@ def remove_velocity_sinex(sinex):
751799 numSites += 1
752800 del solution_epochs
753801
802+ out .write ("*-------------------------------------------------------------------------------\n " )
803+
754804 # Read in the +SOLUTION/ESTIMATE block:
755805 # - gather velocity indices
756806 # - remove velocity rows
@@ -771,6 +821,8 @@ def remove_velocity_sinex(sinex):
771821 out .write (f"{ line } " )
772822 del solution_estimate
773823
824+ out .write ("*-------------------------------------------------------------------------------\n " )
825+
774826 # Read in the +SOLUTION/MATRIX_ESTIMATE block:
775827 # - identify if matrix is upper or lower triangle form
776828 # - form full matrix
@@ -880,25 +932,40 @@ def remove_matrixzeros_sinex(sinex):
880932 header = header .replace (old_creation_time , creation_time )
881933 out .write (header )
882934 del header
935+
936+ out .write ("*-------------------------------------------------------------------------------\n " )
937+
938+ # Read in the +FILE/COMMENT block and write to output file
939+ comments = read_sinex_comments (sinex )
940+ for i in comments :
941+ out .write (f"{ i } \n " )
942+
943+ out .write ("*-------------------------------------------------------------------------------\n " )
883944
884945 # Read in the +SITE/ID block and write to file
885946 site_id = read_sinex_site_id_block (sinex )
886947 for line in site_id :
887948 out .write (f"{ line } " )
888949 del site_id
950+
951+ out .write ("*-------------------------------------------------------------------------------\n " )
889952
890953 # Read in the +SOLUTION/EPOCHS block and write to file
891954 solution_epochs = read_sinex_solution_epochs_block (sinex )
892955 for line in solution_epochs :
893956 out .write (f"{ line } " )
894957 del solution_epochs
895958
959+ out .write ("*-------------------------------------------------------------------------------\n " )
960+
896961 # Read in the +SOLUTION/ESTIMATE block
897962 solution_estimate = read_sinex_solution_estimate_block (sinex )
898963 for line in solution_estimate :
899964 out .write (f"{ line } " )
900965 del solution_estimate
901966
967+ out .write ("*-------------------------------------------------------------------------------\n " )
968+
902969 # Read in the +SOLUTION/MATRIX_ESTIMATE block:
903970 # - Remove lines that contain only zeros
904971 solution_matrix_estimate = read_sinex_solution_matrix_estimate_block (sinex )
0 commit comments