From 21d008b0fc161b399e4386fbdb91dace6abb7040 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 20 Jun 2015 13:18:42 +0000 Subject: diadia (20may15) git-svn-id: svn://tug.org/texlive/trunk@37630 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/diadia/201504.dat | 60 +- Master/texmf-dist/doc/latex/diadia/README | 9 + Master/texmf-dist/doc/latex/diadia/ddbsl1avg.dat | 60 + .../texmf-dist/doc/latex/diadia/diadia-example.pdf | Bin 96283 -> 126910 bytes .../texmf-dist/doc/latex/diadia/diadia-example.tex | 29 +- Master/texmf-dist/doc/latex/diadia/diadia.dtx | 1320 ++++++++++++++++---- Master/texmf-dist/doc/latex/diadia/diadia.pdf | Bin 248800 -> 318603 bytes Master/texmf-dist/doc/latex/diadia/makefile | 10 +- Master/texmf-dist/doc/latex/diadia/manifest.txt | 6 +- Master/texmf-dist/scripts/diadia/diadia.lua | 298 +++++ .../tex/latex/diadia/diadia-english.trsl | 1 + .../tex/latex/diadia/diadia-fallback.trsl | 1 + .../texmf-dist/tex/latex/diadia/diadia-german.trsl | 1 + Master/texmf-dist/tex/latex/diadia/diadia.cfg | 233 ++++ Master/texmf-dist/tex/latex/diadia/diadia.sty | 173 +-- 15 files changed, 1727 insertions(+), 474 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/diadia/ddbsl1avg.dat create mode 100644 Master/texmf-dist/scripts/diadia/diadia.lua create mode 100644 Master/texmf-dist/tex/latex/diadia/diadia.cfg diff --git a/Master/texmf-dist/doc/latex/diadia/201504.dat b/Master/texmf-dist/doc/latex/diadia/201504.dat index 5780b93d2b7..d8c909ad8b3 100644 --- a/Master/texmf-dist/doc/latex/diadia/201504.dat +++ b/Master/texmf-dist/doc/latex/diadia/201504.dat @@ -1,30 +1,30 @@ -date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul -2015-04-02 101 nan nan nan nan nan nan nan nan nan nan -2015-04-03 105 nan nan nan nan nan nan nan nan nan nan -2015-04-04 116 nan nan nan nan nan nan nan nan nan nan -2015-04-05 118 nan nan nan nan nan nan nan nan nan nan -2015-04-06 124 nan nan nan nan nan nan nan nan nan nan -2015-04-07 97 nan nan nan nan nan nan nan nan nan nan -2015-04-08 111 nan nan nan nan nan nan nan nan nan nan -2015-04-09 97 nan nan nan nan nan nan nan nan nan nan -2015-04-10 102 nan nan nan nan nan nan nan nan nan nan -2015-04-11 96 nan nan nan nan nan nan nan nan nan nan -2015-04-12 104 nan nan nan nan nan nan nan nan nan nan -2015-04-13 105 nan nan nan nan nan nan nan nan nan nan -2015-04-14 105 nan nan nan nan nan nan nan nan nan nan -2015-04-15 125 nan nan nan nan nan nan nan nan nan nan -2015-04-16 102 nan nan nan nan nan nan nan nan nan nan -2015-04-17 102 nan nan nan nan nan nan nan nan nan nan -2015-04-18 97 nan nan nan nan nan nan nan nan nan nan -2015-04-19 96 nan nan nan nan nan nan nan nan nan nan -2015-04-20 119 nan nan nan nan nan nan nan nan nan nan -2015-04-21 101 nan nan nan nan nan nan nan nan nan nan -2015-04-22 96 nan nan nan nan nan nan nan nan nan nan -2015-04-23 93 nan nan nan nan nan nan nan nan nan nan -2015-04-24 108 nan nan nan nan nan nan nan nan nan nan -2015-04-25 114 nan nan nan nan nan nan nan nan nan nan -2015-04-26 95 nan nan nan nan nan nan nan nan nan nan -2015-04-27 110 nan nan nan nan nan nan nan nan nan nan -2015-04-28 114 nan nan nan nan nan nan nan nan nan nan -2015-04-29 104 nan nan nan nan nan nan nan nan nan nan -2015-04-30 99 nan nan nan nan nan nan nan nan nan nan +date value avg07 avg14 avg30 avg60 avg90 +2015-04-02 101 96 103 113 135 135 +2015-04-03 105 98 102 111 134 134 +2015-04-04 116 103 104 111 133 133 +2015-04-05 118 106 106 111 133 133 +2015-04-06 124 109 107 112 132 132 +2015-04-07 97 110 107 110 132 132 +2015-04-08 111 110 107 110 131 131 +2015-04-09 97 110 106 109 130 130 +2015-04-10 102 109 105 107 129 129 +2015-04-11 96 106 105 107 129 129 +2015-04-12 104 104 105 106 128 128 +2015-04-13 105 102 105 106 127 127 +2015-04-14 105 103 106 106 127 127 +2015-04-15 125 105 108 106 127 127 +2015-04-16 102 106 108 106 126 126 +2015-04-17 102 106 107 106 126 126 +2015-04-18 97 106 106 105 125 125 +2015-04-19 96 105 105 105 123 125 +2015-04-20 119 107 104 105 122 124 +2015-04-21 101 106 104 105 120 124 +2015-04-22 96 102 103 105 119 123 +2015-04-23 93 101 103 105 117 123 +2015-04-24 108 101 104 105 115 123 +2015-04-25 114 104 105 105 114 122 +2015-04-26 95 104 104 104 113 122 +2015-04-27 110 102 105 105 112 122 +2015-04-28 114 104 105 105 111 122 +2015-04-29 104 105 104 105 110 121 +2015-04-30 99 106 103 105 110 121 diff --git a/Master/texmf-dist/doc/latex/diadia/README b/Master/texmf-dist/doc/latex/diadia/README index 2b097bb23dc..37ec19b0646 100644 --- a/Master/texmf-dist/doc/latex/diadia/README +++ b/Master/texmf-dist/doc/latex/diadia/README @@ -13,3 +13,12 @@ Supported languages: english, german Feel free to provide other translation files! ;-) License: LPPL + +Changes in v1.1: + +- added diadia.lua + It provides the cut, compose and average modes for data + management + +- moved style definitions to diadia.cfg + diff --git a/Master/texmf-dist/doc/latex/diadia/ddbsl1avg.dat b/Master/texmf-dist/doc/latex/diadia/ddbsl1avg.dat new file mode 100644 index 00000000000..1000861b7a2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/diadia/ddbsl1avg.dat @@ -0,0 +1,60 @@ +date value avg07 avg14 avg30 avg60 avg90 +2015-02-18 182 182 182 182 182 182 +2015-02-19 190 186 186 186 186 186 +2015-02-20 181 184 184 184 184 184 +2015-02-21 154 177 177 177 177 177 +2015-02-22 186 179 179 179 179 179 +2015-02-23 190 181 181 181 181 181 +2015-02-24 165 178 178 178 178 178 +2015-02-25 160 175 176 176 176 176 +2015-02-26 151 170 173 173 173 173 +2015-02-27 141 164 170 170 170 170 +2015-02-28 142 162 167 167 167 167 +2015-03-01 134 155 165 165 165 165 +2015-03-02 145 148 163 163 163 163 +2015-03-03 133 144 161 161 161 161 +2015-03-04 138 141 158 159 159 159 +2015-03-06 122 136 151 157 157 157 +2015-03-08 132 134 146 156 156 156 +2015-03-11 144 133 138 155 155 155 +2015-03-13 131 136 136 154 154 154 +2015-03-16 119 131 131 152 152 152 +2015-03-19 109 120 126 150 150 150 +2015-03-20 107 112 124 146 148 148 +2015-03-21 103 110 121 142 146 146 +2015-03-22 97 107 116 138 144 144 +2015-03-23 111 105 115 136 143 143 +2015-03-24 96 104 113 132 141 141 +2015-03-25 109 105 109 128 140 140 +2015-03-26 115 105 110 126 139 139 +2015-03-28 96 104 106 121 137 137 +2015-03-31 90 103 103 117 136 136 +2015-04-02 101 96 103 113 135 135 +2015-04-03 105 98 102 111 134 134 +2015-04-04 116 103 104 111 133 133 +2015-04-05 118 106 106 111 133 133 +2015-04-06 124 109 107 112 132 132 +2015-04-07 97 110 107 110 132 132 +2015-04-08 111 110 107 110 131 131 +2015-04-09 97 110 106 109 130 130 +2015-04-10 102 109 105 107 129 129 +2015-04-11 96 106 105 107 129 129 +2015-04-12 104 104 105 106 128 128 +2015-04-13 105 102 105 106 127 127 +2015-04-14 105 103 106 106 127 127 +2015-04-15 125 105 108 106 127 127 +2015-04-16 102 106 108 106 126 126 +2015-04-17 102 106 107 106 126 126 +2015-04-18 97 106 106 105 125 125 +2015-04-19 96 105 105 105 123 125 +2015-04-20 119 107 104 105 122 124 +2015-04-21 101 106 104 105 120 124 +2015-04-22 96 102 103 105 119 123 +2015-04-23 93 101 103 105 117 123 +2015-04-24 108 101 104 105 115 123 +2015-04-25 114 104 105 105 114 122 +2015-04-26 95 104 104 104 113 122 +2015-04-27 110 102 105 105 112 122 +2015-04-28 114 104 105 105 111 122 +2015-04-29 104 105 104 105 110 121 +2015-04-30 99 106 103 105 110 121 diff --git a/Master/texmf-dist/doc/latex/diadia/diadia-example.pdf b/Master/texmf-dist/doc/latex/diadia/diadia-example.pdf index b0af24e01fb..89f6c84885d 100644 Binary files a/Master/texmf-dist/doc/latex/diadia/diadia-example.pdf and b/Master/texmf-dist/doc/latex/diadia/diadia-example.pdf differ diff --git a/Master/texmf-dist/doc/latex/diadia/diadia-example.tex b/Master/texmf-dist/doc/latex/diadia/diadia-example.tex index 03e550ea904..94c53a33126 100644 --- a/Master/texmf-dist/doc/latex/diadia/diadia-example.tex +++ b/Master/texmf-dist/doc/latex/diadia/diadia-example.tex @@ -53,6 +53,20 @@ \end{diadiaplot} \end{diadiasidebyside} +\vfill +\begin{diadiaplot}[plotstyle=bloodsugar] + {width=\textwidth, + height=11cm, + legend style={at={(0.5,-0.15)},font=\footnotesize,anchor=north,legend columns=-1}, + xtick={2015-03-01,2015-04-01,2015-05-01}, + xmin=2015-02-18, + xmax=2015-04-30} +\diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} +\diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} +\diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} +\diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} +\legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$,morning} +\end{diadiaplot} \chapter{February 2015} \section{Data} \diadiatab{font=\small}{201502.dat} @@ -150,12 +164,15 @@ \chapter{April 2015} \section{Data} \begin{diadiasidebyside} -\diadiatab{columns={date,bsl1,bsl2,bsl3}}{201504.dat} - -\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-04-01,xmax=2015-04-29,enlargelimits=0.25} -\annotation[text width=1.4cm]{2015-04-06}{129}{rise after discharge} -\diadiaaddplot{}{x=date,y=bsl1}{diadia.dat} -\legend{morning} +\diadiatab{columns={date,value,avg07,avg30,avg90}}{201504.dat} + +\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-04-02,xmax=2015-04-29} +\annotation[text width=1.4cm]{2015-04-10}{123}{rise after discharge} +\diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} +\diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} +\diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} +\diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} +\legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$,morning} \end{diadiaplot} \end{diadiasidebyside} diff --git a/Master/texmf-dist/doc/latex/diadia/diadia.dtx b/Master/texmf-dist/doc/latex/diadia/diadia.dtx index 8ad273843e4..5ba8cffa369 100644 --- a/Master/texmf-dist/doc/latex/diadia/diadia.dtx +++ b/Master/texmf-dist/doc/latex/diadia/diadia.dtx @@ -19,6 +19,15 @@ Supported languages: english, german Feel free to provide other translation files! ;-) License: LPPL + +Changes in v1.1: + +- added diadia.lua + It provides the cut, compose and average modes for data + management + +- moved style definitions to diadia.cfg + % %<*data> date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul @@ -83,6 +92,68 @@ date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul 2015-04-29 104 nan nan nan nan nan nan nan nan nan nan 2015-04-30 99 nan nan nan nan nan nan nan nan nan nan % +%<*dataavg> +date value avg07 avg14 avg30 avg60 avg90 +2015-02-18 182 182 182 182 182 182 +2015-02-19 190 186 186 186 186 186 +2015-02-20 181 184 184 184 184 184 +2015-02-21 154 177 177 177 177 177 +2015-02-22 186 179 179 179 179 179 +2015-02-23 190 181 181 181 181 181 +2015-02-24 165 178 178 178 178 178 +2015-02-25 160 175 176 176 176 176 +2015-02-26 151 170 173 173 173 173 +2015-02-27 141 164 170 170 170 170 +2015-02-28 142 162 167 167 167 167 +2015-03-01 134 155 165 165 165 165 +2015-03-02 145 148 163 163 163 163 +2015-03-03 133 144 161 161 161 161 +2015-03-04 138 141 158 159 159 159 +2015-03-06 122 136 151 157 157 157 +2015-03-08 132 134 146 156 156 156 +2015-03-11 144 133 138 155 155 155 +2015-03-13 131 136 136 154 154 154 +2015-03-16 119 131 131 152 152 152 +2015-03-19 109 120 126 150 150 150 +2015-03-20 107 112 124 146 148 148 +2015-03-21 103 110 121 142 146 146 +2015-03-22 97 107 116 138 144 144 +2015-03-23 111 105 115 136 143 143 +2015-03-24 96 104 113 132 141 141 +2015-03-25 109 105 109 128 140 140 +2015-03-26 115 105 110 126 139 139 +2015-03-28 96 104 106 121 137 137 +2015-03-31 90 103 103 117 136 136 +2015-04-02 101 96 103 113 135 135 +2015-04-03 105 98 102 111 134 134 +2015-04-04 116 103 104 111 133 133 +2015-04-05 118 106 106 111 133 133 +2015-04-06 124 109 107 112 132 132 +2015-04-07 97 110 107 110 132 132 +2015-04-08 111 110 107 110 131 131 +2015-04-09 97 110 106 109 130 130 +2015-04-10 102 109 105 107 129 129 +2015-04-11 96 106 105 107 129 129 +2015-04-12 104 104 105 106 128 128 +2015-04-13 105 102 105 106 127 127 +2015-04-14 105 103 106 106 127 127 +2015-04-15 125 105 108 106 127 127 +2015-04-16 102 106 108 106 126 126 +2015-04-17 102 106 107 106 126 126 +2015-04-18 97 106 106 105 125 125 +2015-04-19 96 105 105 105 123 125 +2015-04-20 119 107 104 105 122 124 +2015-04-21 101 106 104 105 120 124 +2015-04-22 96 102 103 105 119 123 +2015-04-23 93 101 103 105 117 123 +2015-04-24 108 101 104 105 115 123 +2015-04-25 114 104 105 105 114 122 +2015-04-26 95 104 104 104 113 122 +2015-04-27 110 102 105 105 112 122 +2015-04-28 114 104 105 105 111 122 +2015-04-29 104 105 104 105 110 121 +2015-04-30 99 106 103 105 110 121 +% %<*feb15> date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul 2015-02-18 182 197 196 nan nan 10 120 80 102.3 12 64 @@ -121,36 +192,36 @@ date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul 2015-03-31 90 nan nan nan nan nan nan nan nan nan nan % %<*apr15> -date bsl1 bsl2 bsl3 id1 id2 id3 bps bpd weight cu pul -2015-04-02 101 nan nan nan nan nan nan nan nan nan nan -2015-04-03 105 nan nan nan nan nan nan nan nan nan nan -2015-04-04 116 nan nan nan nan nan nan nan nan nan nan -2015-04-05 118 nan nan nan nan nan nan nan nan nan nan -2015-04-06 124 nan nan nan nan nan nan nan nan nan nan -2015-04-07 97 nan nan nan nan nan nan nan nan nan nan -2015-04-08 111 nan nan nan nan nan nan nan nan nan nan -2015-04-09 97 nan nan nan nan nan nan nan nan nan nan -2015-04-10 102 nan nan nan nan nan nan nan nan nan nan -2015-04-11 96 nan nan nan nan nan nan nan nan nan nan -2015-04-12 104 nan nan nan nan nan nan nan nan nan nan -2015-04-13 105 nan nan nan nan nan nan nan nan nan nan -2015-04-14 105 nan nan nan nan nan nan nan nan nan nan -2015-04-15 125 nan nan nan nan nan nan nan nan nan nan -2015-04-16 102 nan nan nan nan nan nan nan nan nan nan -2015-04-17 102 nan nan nan nan nan nan nan nan nan nan -2015-04-18 97 nan nan nan nan nan nan nan nan nan nan -2015-04-19 96 nan nan nan nan nan nan nan nan nan nan -2015-04-20 119 nan nan nan nan nan nan nan nan nan nan -2015-04-21 101 nan nan nan nan nan nan nan nan nan nan -2015-04-22 96 nan nan nan nan nan nan nan nan nan nan -2015-04-23 93 nan nan nan nan nan nan nan nan nan nan -2015-04-24 108 nan nan nan nan nan nan nan nan nan nan -2015-04-25 114 nan nan nan nan nan nan nan nan nan nan -2015-04-26 95 nan nan nan nan nan nan nan nan nan nan -2015-04-27 110 nan nan nan nan nan nan nan nan nan nan -2015-04-28 114 nan nan nan nan nan nan nan nan nan nan -2015-04-29 104 nan nan nan nan nan nan nan nan nan nan -2015-04-30 99 nan nan nan nan nan nan nan nan nan nan +date value avg07 avg14 avg30 avg60 avg90 +2015-04-02 101 96 103 113 135 135 +2015-04-03 105 98 102 111 134 134 +2015-04-04 116 103 104 111 133 133 +2015-04-05 118 106 106 111 133 133 +2015-04-06 124 109 107 112 132 132 +2015-04-07 97 110 107 110 132 132 +2015-04-08 111 110 107 110 131 131 +2015-04-09 97 110 106 109 130 130 +2015-04-10 102 109 105 107 129 129 +2015-04-11 96 106 105 107 129 129 +2015-04-12 104 104 105 106 128 128 +2015-04-13 105 102 105 106 127 127 +2015-04-14 105 103 106 106 127 127 +2015-04-15 125 105 108 106 127 127 +2015-04-16 102 106 108 106 126 126 +2015-04-17 102 106 107 106 126 126 +2015-04-18 97 106 106 105 125 125 +2015-04-19 96 105 105 105 123 125 +2015-04-20 119 107 104 105 122 124 +2015-04-21 101 106 104 105 120 124 +2015-04-22 96 102 103 105 119 123 +2015-04-23 93 101 103 105 117 123 +2015-04-24 108 101 104 105 115 123 +2015-04-25 114 104 105 105 114 122 +2015-04-26 95 104 104 104 113 122 +2015-04-27 110 102 105 105 112 122 +2015-04-28 114 104 105 105 111 122 +2015-04-29 104 105 104 105 110 121 +2015-04-30 99 106 103 105 110 121 % %<*hba1c> date hba1c @@ -184,6 +255,7 @@ date hba1c \DeclareTranslationFallback{dd-CU}{CU}% \DeclareTranslationFallback{dd-Pulse}{Pulse}% \DeclareTranslationFallback{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslationFallback{dd-Value}{Value}% % %<*english> \DeclareTranslation{English}{dd-BloodSugar}{Blood Sugar}% @@ -212,6 +284,7 @@ date hba1c \DeclareTranslation{English}{dd-CU}{CU}% \DeclareTranslation{English}{dd-Pulse}{Pulse}% \DeclareTranslation{English}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslation{English}{dd-Value}{Value}% % %<*german> \DeclareTranslation{German}{dd-BloodSugar}{Blutzucker}% @@ -240,6 +313,7 @@ date hba1c \DeclareTranslation{German}{dd-CU}{BE}% \DeclareTranslation{German}{dd-Pulse}{Puls}% \DeclareTranslation{German}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslation{German}{dd-Value}{Wert}% % %<*bibfile> @misc{bib:pgfplots, @@ -306,6 +380,20 @@ date hba1c \end{diadiaplot} \end{diadiasidebyside} +\vfill +\begin{diadiaplot}[plotstyle=bloodsugar] + {width=\textwidth, + height=11cm, + legend style={at={(0.5,-0.15)},font=\footnotesize,anchor=north,legend columns=-1}, + xtick={2015-03-01,2015-04-01,2015-05-01}, + xmin=2015-02-18, + xmax=2015-04-30} +\diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} +\diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} +\diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} +\diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} +\legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$,morning} +\end{diadiaplot} \chapter{February 2015} \section{Data} \diadiatab{font=\small}{201502.dat} @@ -403,12 +491,15 @@ date hba1c \chapter{April 2015} \section{Data} \begin{diadiasidebyside} -\diadiatab{columns={date,bsl1,bsl2,bsl3}}{201504.dat} +\diadiatab{columns={date,value,avg07,avg30,avg90}}{201504.dat} -\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-04-01,xmax=2015-04-29,enlargelimits=0.25} -\annotation[text width=1.4cm]{2015-04-06}{129}{rise after discharge} -\diadiaaddplot{}{x=date,y=bsl1}{diadia.dat} -\legend{morning} +\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-04-02,xmax=2015-04-29} +\annotation[text width=1.4cm]{2015-04-10}{123}{rise after discharge} +\diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} +\diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} +\diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} +\diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} +\legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$,morning} \end{diadiaplot} \end{diadiasidebyside} @@ -458,14 +549,14 @@ This work consists of the following files: diadia.pdf diadia.dtx +diadia-example.pdf README makefile Files packaged in diadia.dtx: diadia.sty -diadia-example.tex -> diadia-example.pdf -manifest.txt +diadia.cfg diadia-fallback.trsl diadia-english.trsl diadia-german.trsl @@ -474,6 +565,8 @@ diadia.dat 201503.dat 201504.dat hba1c.dat +diadia-example.tex +manifest.txt % %<*internal> \fi @@ -514,6 +607,9 @@ This work consists of all files listed in manifest.txt. \generate{ \file{\jobname.sty}{\from{\jobname.dtx}{package}} } +\generate{ + \file{\jobname.cfg}{\from{\jobname.dtx}{cfg}} +} \generate{ \file{\jobname-fallback.trsl}{\from{\jobname.dtx}{fallback}} } @@ -527,10 +623,17 @@ This work consists of all files listed in manifest.txt. \file{\jobname-example}{\from{\jobname.dtx}{examplefile}} } \nopreamble\nopostamble +\usedir{scripts/diadia} +\generate{ + \file{\jobname.lua}{\from{\jobname.dtx}{lua}} +} \usedir{doc/latex/diadia} \generate{ \file{\jobname.dat}{\from{\jobname.dtx}{data}} } +\generate{ + \file{ddbsl1avg.dat}{\from{\jobname.dtx}{dataavg}} +} % %\endbatchfile %<*internal> @@ -580,6 +683,7 @@ This work consists of all files listed in manifest.txt. \usepackage[numbered]{hypdoc} \usepackage{ragged2e}% \usepackage{url}% +\usepackage{csquotes}% \usepackage{diadia}% \usepackage{alltt}% \usepackage{marvosym}% @@ -759,13 +863,13 @@ emph={}} % \lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue}, % emph={medicationchart,diadiasidebyside,diadiaplot},emphstyle=\color{Tomato}, % emph={[2]columns,column,chol,string,replace,name,ddpuser,font,tabstyle,tabcolor,date,type,bsl1,bsl2,bsl3,plotstyle,xlabel,tick,label,style,xmin,xmax,x,y, -% text,width,very,thick,fill,draw,mark,options}, +% text,width,very,thick,fill,draw,mark,options,anchor}, % emphstyle={[2]\color{OliveDrab}}, -% morekeywords={pgfplotsset,pgfplotstableset,diadiatab,diadiaaddplot,legend,annotation,setlimit,mcentry,infobox,Telefon}} +% morekeywords={pgfplotsset,pgfplotstableset,diadiatab,diadiaaddplot,legend,annotation,setlimit,mcentry,infobox,Telefon,varnothing,lastdate}} % \DoNotIndex{\,,\\,\begin,\end,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter, % \fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\renewcommand,\NewEnviron,\newenvironment,\newif, % \PackageInfo,\PackageError,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage, -% \space,\errmessage,\ExecuteOptionsX,} +% \space,\errmessage,\ExecuteOptionsX,\n} % % \setlength\parskip{6pt}% % \bibliographystyle{plain} @@ -829,9 +933,6 @@ emph={}} % charts and info boxes. % \end{abstract} % \clearpage -% \tableofcontents -% \clearpage -% \Headline{2 Storing data} % % \section{Options} % The following options can be set as package options with global scope, @@ -864,6 +965,21 @@ emph={}} % % \fi % +% These definitions are out-sourced into \texttt{diadia.cfg}. You can copy this file to your local \TeX\ tree +% to alter definitions or to add new ones. +% +% Among other things, it defines the general plot styles \texttt{ddpuser} and \texttt{ddpdefault}, as well as the special +% plot styles \texttt{ddpweight}, \texttt{ddpbloodpressure}, \texttt{ddpinsulin}, \texttt{ddpbloodsugar}, \texttt{ddppulse}, +% \texttt{ddpcu} and \texttt{ddphbaonec}. Additionally, it defines the special styles \texttt{ddpweightplot} for +% filled weight plots and \texttt{nomarks} for \enquote{deleting} the data marks. +% +% Furthermore, it defines the appearance of tables in general and header elements. It defines the usually used color cycle list +% \texttt{diadiacyclelist} and make the color styles also available as \texttt{plot1} to \texttt{plot4}. +% +% Moreover, it defines the \texttt{ddpannotation}, \texttt{setlimit} and \texttt{ddaddplotfill} for filled plots (\texttt{teal!50}). +% Finally, it defines the box styles \texttt{medicationchart} and \texttt{infobox} based on \texttt{ddboxdefault}. +% See section \ref{sec:config} on page \pageref{sec:config} for a more or less detailed description of the config file. +% % The \package{pgfplots}\cite{bib:pgfplots}, \package{pgfplotstable}\cite{bib:pgfplotstable} and \package{tcolorbox}\cite{bib:tcolorbox} packages offer % zillions of options to influence the design! % \Headline{2 Storing data} @@ -921,6 +1037,143 @@ emph={}} % % This sets the column name in tables and prevents that \texttt{nan} values are printed. For plots you only need the \texttt{chol} key! % +% \section{Editing data} +% \label{sec:diadialua} +% +% The \texttt{diadia.lua} script offers several ways to edit your data file. At the moment it supports the following modes: +% \begin{itemize} +% \item[\texttt{cut}] This mode allows you to cut chunks of data out of your data file, e.g. for preparing data files for monthly reports. +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +$ diadia -m cut -i diadia.dat -o 201504.dat -s 2015-04-01 +-e 2015-04-30 +set mode to cut +reading data file diadia.dat +writing data file 201504.dat +\end{lstlisting} +% \iffalse +% +% \fi +% \item[\texttt{compose}] This mode allows you to rearrange the columns of your data file, e.g. as preperation for the \texttt{average} mode +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +$ diadia -m compose -i diadia.dat -o ddbsl1.dat -c 1,2 +set mode to compose +reading data file diadia.dat +writing data file ddbs1.dat +\end{lstlisting} +% \iffalse +% +% \fi +% \item[\texttt{average}] This mode allows you to create a new data file. By definition, it takes the first +% two columns (\texttt{date} and \texttt{value}) of the input file and adds columns for the 7, 14, 30, +% 60 and 90 days average.\footnote {Your data files should be big enough, as a correct 90 day average can +% of course only be calculated with data starting at least 90 days \textbf{before} the date period you +% want to visualize.} +% +% \clearpage +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +$ diadia -m average -i ddbsl1.dat -o bsl1.dat +set mode to average +reading data file ddbs1.dat +writing data file bsl1.dat +\end{lstlisting} +% \iffalse +% +% \fi +% \end{itemize} +% +% As shown in the examples, the script supports the following command line options: +% +% \begin{optionlist} +% \optitempgf{-m}{specify the mode (cut\textbar{}compose\textbar{}average)} +% \optitempgf{-i}{specify the input file} +% \optitempgf{-o}{specify the output file} +% \optitempgf{-c}{specify a list of columns for \texttt{compose} mode, e.g. \texttt{-c 1,2}\footnote{even crazy things like \texttt{-c 1,2,2,2} work}} +% \optitempgf{-s}{specify the start date (\texttt{YYYY-MM-DD}) in \texttt{cut} and \texttt{average} mode} +% \optitempgf{-e}{specify the end date} +% \optitempgf{-v}{prints version information} +% \optitempgf{-h}{prints help information} +% \end{optionlist} +% +% Furthermore, the script provides the following error codes: +% +% \begin{optionlist} +% \optitempgf{\space0}{as usual, everythings fine!} +% \optitempgf{\space1}{general error} +% \optitempgf{11}{no \texttt{mode} specified} +% \optitempgf{12}{invalid \texttt{mode}} +% \optitempgf{21}{wrong date format (\texttt{YYYY-MM-DD})} +% \end{optionlist} +% +% +% \section{Managing data} +% +% In principal, it's enough to have just one data file, but it might be worth considering to use a seperate data +% file for long term values like $\text{HbA}_{\text{1c}}$. You might also want to have monthly data files for the +% \cmd\diadiatab\ command. These can easily be created with the \texttt{cut} mode of \texttt{diadia.lua}! You can simplify +% your data management for example with a \texttt{makefile}\footnote{This works also on a Windows system with an environment like Cygwin.}: +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +NAME = mydiadia +TODAY = $(shell date +'%Y-%m-%d') +RM = rm -f + +all: doc + +today: + echo "\def\lastdate{$(TODAY)}" >today.dat + +doc: today + pdflatex $(NAME) + pdflatex $(NAME) + openar ./$(NAME).pdf & + +dat: + diadia -m cut -i diadia.data -o diadia.dat -s 2015-02-18 +-e $(TODAY) + diadia -m cut -i longterm.data -o longterm.dat -s 2015-02 +-18 -e $(TODAY) + diadia -m average -i diadia.dat -o ddbsl1avg.dat + diadia -m cut -i diadia.dat -o 201502.dat -s 2015-02-18 - +e 2015-02-28 + diadia -m cut -i diadia.dat -o 201503.dat -s 2015-03-01 - +e 2015-03-31 + diadia -m average -i diadia.dat -o 201504.dat -s 2015-04- +01 -e 2015-04-30 + diadia -m average -i diadia.dat -o 201505.dat -s 2015-05- +01 -e $(TODAY) + +clean: + $(RM) *.aux *.log *.out *.toc + +cleanall: clean + $(RM) $(NAME).pdf *.dat + +.PHONY: all today doc dat clean cleanall +\end{lstlisting} +% \iffalse +% +% \fi +% +% It provides the two major targets \texttt{dat} for data management and \texttt{doc} for +% creating your diary.\footnote{\texttt{openar} is a simple shell script, which opens the resulting \texttt{PDF} file with Adobe Reader.} +% Furthermore, it provides \texttt{today.dat},\footnote{simply \texttt{\cmd\input\{today.dat\}}} +% which provides the \cmd\lastdate\ macro with current date in \texttt{YYYY-MM-DD} format. +% Finally, it provides the cleanup targets \texttt{clean} and \texttt{cleanall}. +% % \section{Presenting data} % \subsection{Tables} % @@ -1008,18 +1261,8 @@ emph={}} % % Unfortunately, the \package{pgfplotstable} package does not offer a simple method to limit the output % of the table to certain dates, as the \package{pgfplots} package offers with the \texttt{xmin} and \texttt{xmax} keys. -% Thus, you have to prepare piecewise data files for monthly reports or so. The following simple \texttt{grep} one-liner -% might be helpful: -% -% \iffalse -%<*example> -% \fi -\begin{lstlisting} -grep -e 'date' -e '2015-04' 201504.dat -\end{lstlisting} -% \iffalse -% -% \fi +% Thus, you have to prepare piecewise data files for monthly reports or so. See section \ref{sec:diadialua} on page +% \pageref{sec:diadialua} for a simple solution! % % Furthermore, \package{diadia} does not support page breaks for tables. The documentation of the \package{pgfplotstable}\cite[p. 21]{bib:pgfplotstable} % package describes a way out by using a \package{longtable}\cite{bib:longtable} if you need to typeset long tables! @@ -1114,6 +1357,9 @@ grep -e 'date' -e '2015-04' 201504.dat % { % xlabel=2015, % tick label style={font=\footnotesize}, +% legend style={at={(0.5,-0.18)}, +% font=\footnotesize,anchor=north, +% legend columns=-1}, % xmin=2015-02-18, % xmax=2015-02-28 % } @@ -1126,6 +1372,54 @@ grep -e 'date' -e '2015-04' 201504.dat % \end{diadiaplot} % % \bigskip +% If you have calculated average values with the \texttt{diadia.lua} script, you can also plot them like this: +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\begin{diadiaplot}[plotstyle=bloodsugar] + { + width=\textwidth, + xlabel=2015, + tick label style={font=\footnotesize}, + legend style={at={(0.5,-0.15)}, + font=\footnotesize,anchor=north, + legend columns=-1}, + xmin=2015-02-18, + xmax=2015-04-30 + } + \diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} + \diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} + \diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} + \diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} + \legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$, + morning} +\end{diadiaplot} +\end{lstlisting} +% \iffalse +% +% \fi +% +% \begin{diadiaplot}[plotstyle=bloodsugar] +% { +% width=\textwidth, +% xlabel=2015, +% tick label style={font=\footnotesize}, +% legend style={at={(0.5,-0.15)}, +% font=\footnotesize,anchor=north, +% legend columns=-1}, +% xmin=2015-02-18, +% xmax=2015-04-30 +% } +% \diadiaaddplot{plot4,nomarks}{x=date,y=avg90}{ddbsl1avg.dat} +% \diadiaaddplot{plot3,nomarks}{x=date,y=avg30}{ddbsl1avg.dat} +% \diadiaaddplot{plot2,nomarks}{x=date,y=avg07}{ddbsl1avg.dat} +% \diadiaaddplot{plot1}{x=date,y=value}{ddbsl1avg.dat} +% \legend{$\varnothing_{90}$,$\varnothing_{30}$,$\varnothing_{7}$,morning} +% \end{diadiaplot} +% +% \bigskip % Here's a list of interesting keys for \marg{pgfplots options}, but there are of course % much more in the \package{pgfplots}\cite{bib:pgfplots} package documentation! % @@ -1146,11 +1440,13 @@ grep -e 'date' -e '2015-04' 201504.dat % environment allows you to typeset a medication chart. That is, a list of your pharmaceuticals and how to take them. Internally, you must use % the standard systax of a 6 column tabular. Or you simply use the \cmd\mcentry\margcs{\cmd\mcentry\marg{pharmaceutical}\marg{morning}\\\marg{noon}\marg{evening}\marg{night}\marg{note}} command. % +% \begin{samepage} % Possible options: % % \begin{optionlist} % \optitem{mcnotewidth}{\underline{3cm}}{} % \end{optionlist} +% \end{samepage} % % \iffalse %<*example> @@ -1275,6 +1571,7 @@ Podiatrist appointment: % % \clearpage % \section{Implementation} +% \subsection{diadia.sty} % \changes{v1.0}{2015/05/11}{CTAN upload} % \begin{macrocode} %<*package> @@ -1282,7 +1579,7 @@ Podiatrist appointment: % First, we provide the \LaTeX\ package \package{diadia}. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{diadia}[2015/05/11 v1.0 diadia.sty - Josef Kleber (C) 2015]% +\ProvidesPackage{diadia}[2015/05/20 v1.1 diadia.sty - Josef Kleber (C) 2015]% % \end{macrocode} % We load the \texttt{xkeyval} package and define a helper macro to define the (global) options. % \begin{macrocode} @@ -1331,6 +1628,7 @@ Podiatrist appointment: \RequirePackage[many]{tcolorbox}% \RequirePackage{environ}% \RequirePackage{multicol}% +\RequirePackage{amssymb}% % \usepgfplotslibrary{dateplot}% % @@ -1369,233 +1667,42 @@ Podiatrist appointment: \def\DD@JK@trans@CU{\GetTranslation{dd-CU}}% \def\DD@JK@trans@Pulse{\GetTranslation{dd-Pulse}}% \def\DD@JK@trans@Hbaonec{\GetTranslation{dd-Hbaonec}}% +\def\DD@JK@trans@Value{\GetTranslation{dd-Value}}% % \end{macrocode} % We define two new tabular types Z (ragged right X type) and Y (ragged right p with \texttt{mcnotewidth} width). % \begin{macrocode} \newcolumntype{Z}{>{\raggedright\let\newline\\\arraybackslash}X}% \newcolumntype{Y}{>{\raggedright\let\newline\\\arraybackslash}p{\DD@JK@mcnotewidth}}% % \end{macrocode} -% We set \texttt{pgfplot} compat mode to 1.12 and the \texttt{date ZERO} key to \texttt{2015-01-01}. -% Sometimes, values are plotted at the wrong date. Then you should adjust the \texttt{date ZERO} key -% to the start date of your data to avoid rounding errors in date calculation. +% We load the \texttt{diadia.cfg} config file. It holds all kind of style definitions. You can copy this +% file to your local \TeX\ tree and alter the definitions or add new ones! % \begin{macrocode} -\pgfplotsset{% - compat=1.12,% - date ZERO=2015-01-01% +\IfFileExists{diadia.cfg}% +{% + \input{diadia.cfg}% +}% +{% + \PackageError{diadia}{diadia.cfg not found}% + {Please install diadia.cfg! The style definitions are missing!}% }% % \end{macrocode} -% We define some \texttt{pgfplots} styles with priority order: \texttt{ddpdefault} $\rightarrow$ \texttt{ddpuser} $\rightarrow$ -% \{\texttt{ddpbloodsugar}\textbar\texttt{insulin}\textbar\texttt{bloodpressure}\textbar\texttt{weight}\textbar\texttt{cu}\textbar\texttt{pulse}\textbar\texttt{hbaonec}\} +% \begin{macro}{\annotation} +% With this command you can annotate your plots. You must use x/y coordinates in the context of your plot. Thus the x coordinate is usually a date. % -% Thus, you can redefine \texttt{ddpuser} to adjust the general design set by \texttt{ddpdefault}. Furthermore, we define -% a \texttt{ddpweightplot} to use our standard design also in weight plots, as area style plots use their own color cycle list. +% \cs{annotation}\oarg{Ti\textit{k}z options}\marg{x}\marg{y}\marg{annotation} % \begin{macrocode} -\pgfplotsset{% - ddpuser/.style=% - {},% - ddpdefault/.style=% - {% - thick,% - date coordinates in=x,% - xticklabel={\day.\month.},% - legend style={at={(0.5,-0.25)},% - font=\footnotesize,% - anchor=north,% - legend columns=-1},% - ddpuser% - },% - ddpweight/.style=% - {% - smooth,% - area style,% - ylabel=\DD@JK@trans@Weight% - },% - ddpweightplot/.style=% - {% - teal,% - fill=teal!50,% - mark=halfcircle*,% - every mark/.append style={solid,fill=.!80!black}% - },% - ddpbloodpressure/.style=% - {% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@BloodPressure% - },% - ddpinsulin/.style=% - {% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Insulin% - },% - ddpbloodsugar/.style=% - {% - smooth,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@BloodSugar% - },% - ddppulse/.style=% - {% - smooth,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Pulse% - },% - ddpcu/.style=% - {% - ybar,% - tick align=inside,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@CU% - },% - ddphbaonec/.style=% - {% - ybar,% - tick align=inside,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Hbaonec% - }% +\newcommand*{\annotation}[4][]% +{% + \node[ddpannotation,#1] at (#2,#3) {#4};% }% % \end{macrocode} -% We set some sensible defaults for \cmd\diadiatab -% -% \begin{itemize} -% \item replace \texttt{nan} with empty string -% \item replace empty cells with -- -% \item define \texttt{date} column as \texttt{date type} -% \item define \texttt{weight} and \texttt{hba1c} columns as \texttt{fixed,fixed zerofill,precision=1} -% \end{itemize} +% \end{macro} +% \begin{macro}{\diadiatab} +% The \cmd\diadiatab\ command allows you to typeset your data in a formatted table. % +% \cs{diadiatab}\oarg{options}\marg{pgfplotstable options}\marg{file} % \begin{macrocode} -\pgfplotstableset% -{% - empty cells with={--},% - columns/date/.style={date type},% - columns/bsl1/.style={string replace={nan}{}},% - columns/bsl2/.style={string replace={nan}{}},% - columns/bsl3/.style={string replace={nan}{}},% - columns/id1/.style={string replace={nan}{}},% - columns/id2/.style={string replace={nan}{}},% - columns/id3/.style={string replace={nan}{}},% - columns/bps/.style={string replace={nan}{}},% - columns/bpd/.style={string replace={nan}{}},% - columns/weight/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% - columns/cu/.style={string replace={nan}{}},% - columns/pul/.style={string replace={nan}{}},% - columns/hba1c/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}}% -}% -% \end{macrocode} -% Now, we append the language dependent column headers to the column style! -% \begin{macrocode} -\pgfplotstableset% -{% - columns/date/.append style={column name={\DD@JK@trans@Date}},% - columns/bsl1/.append style={column name={\DD@JK@trans@BSi}},% - columns/bsl2/.append style={column name={\DD@JK@trans@BSii}},% - columns/bsl3/.append style={column name={\DD@JK@trans@BSiii}},% - columns/id1/.append style={column name={\DD@JK@trans@IDi}},% - columns/id2/.append style={column name={\DD@JK@trans@IDii}},% - columns/id3/.append style={column name={\DD@JK@trans@IDiii}},% - columns/bps/.append style={column name={\DD@JK@trans@BPs}},% - columns/bpd/.append style={column name={\DD@JK@trans@BPd}},% - columns/weight/.append style={column name={\DD@JK@trans@Weight}},% - columns/cu/.append style={column name={\DD@JK@trans@CU}},% - columns/pul/.append style={column name={\DD@JK@trans@Pulse}},% - columns/hba1c/.append style={column name={\DD@JK@trans@Hbaonec}}% -}% -% \end{macrocode} -% We define the \texttt{diadiacyclelist} color cycle list used in plots. You may adjust it to your needs. -% \begin{macrocode} -\pgfplotscreateplotcyclelist{diadiacyclelist}% -{% - {teal,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black}},% - {orange,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black,rotate=180}},% - {cyan,mark=o,every mark/.append style={solid,fill=.!80!black}},% - {yellow,mark=star,every mark/.append style={solid,fill=.!80!black}}% -}% -% \end{macrocode} -% We define the Ti\textit{k}z styles for annotations and limits. -% \begin{macrocode} -\tikzset% -{% - ddpannotation/.style=% - {% - fill=yellow!50!white,% - rectangle,% - rounded corners=3pt,% - font=\tiny% - },% - setlimit/.style=% - {% - red,% - thick% - },% - ddaddplotfill/.style=% - {% - fill=teal!50,% - },% -}% -% \end{macrocode} -% Finally, we define the \texttt{medicationchart} and \texttt{infobox} \texttt{tcolorbox} styles based on \texttt{ddboxdefault}! -% \begin{macrocode} -\tcbset% -{% - ddboxdefault/.style=% - {% - enhanced,% - fonttitle=\bfseries\large,% - coltitle=black,% - center title,% - titlerule=.75mm,% - toprule=1mm,% - bottomrule=1mm,% - toptitle=2mm,% - bottomtitle=2mm% - },% - medicationchart/.style=% - {% - ddboxdefault,% - fontupper=\footnotesize,% - colback=yellow!10!white,% - colframe=yellow!60!black,% - colbacktitle=yellow!20!white,% - left=0mm,% - right=0mm,% - top=0mm,% - bottom=0mm,% - boxsep=0mm,% - },% - infobox/.style=% - {% - ddboxdefault,% - width=\linewidth-10.888pt,% - colback=orange!10!white,% - colframe=orange!60!black,% - colbacktitle=orange!20!white% - },% -}% -% \end{macrocode} -% \begin{macro}{\annotation} -% With this command you can annotate your plots. You must use x/y coordinates in the context of your plot. Thus the x coordinate is usually a date. -% -% \cs{annotation}\oarg{Ti\textit{k}z options}\marg{x}\marg{y}\marg{annotation} -% \begin{macrocode} -\newcommand*{\annotation}[4][]% -{% - \node[ddpannotation,#1] at (#2,#3) {#4};% -}% -% \end{macrocode} -% \end{macro} -% \begin{macro}{\diadiatab} -% The \cmd\diadiatab\ command allows you to typeset your data in a formatted table. -% -% \cs{diadiatab}\oarg{options}\marg{pgfplotstable options}\marg{file} -% \begin{macrocode} -\newcommand*{\diadiatab}[3][]% +\newcommand*{\diadiatab}[3][]% {% \begingroup% % \end{macrocode} @@ -1817,4 +1924,681 @@ Podiatrist appointment: % \begin{macrocode} % % \end{macrocode} +% \subsection{diadia.cfg} +% \label{sec:config} +% \changes{v1.1}{2015/05/17}{added diadia.cfg} +% \begin{macrocode} +%<*cfg> +% \end{macrocode} +% We set \texttt{pgfplot} compat mode to 1.12 and the \texttt{date ZERO} key to \texttt{2015-01-01}. +% Sometimes, values are plotted at the wrong date. Then you should adjust the \texttt{date ZERO} key +% to the start date of your data to avoid rounding errors in date calculation. +% \begin{macrocode} +\pgfplotsset{% + compat=1.12,% + date ZERO=2015-01-01% +}% +% \end{macrocode} +% We define some \texttt{pgfplots} styles with priority order: \texttt{ddpdefault} $\rightarrow$ \texttt{ddpuser} $\rightarrow$ +% \{\texttt{ddpbloodsugar}\textbar\texttt{ddpinsulin}\textbar\texttt{ddpbloodpressure}\textbar\texttt{ddpweight}\textbar\texttt{ddpcu}\textbar\texttt{ddppulse}\textbar\newline\texttt{ddphbaonec}\} +% +% Thus, you can redefine \texttt{ddpuser} to adjust the general design set by \texttt{ddpdefault}. Furthermore, we define +% a \texttt{ddpweightplot} to use our standard design also in weight plots, as area style plots use their own color cycle list. +% \begin{macrocode} +\pgfplotsset{% + ddpuser/.style=% + {},% + ddpdefault/.style=% + {% + thick,% + date coordinates in=x,% + cycle list name=diadiacyclelist,% + tick align=inside,% + unbounded coords=jump,% + xticklabel={\day.\month.},% + legend style={at={(0.5,-0.25)},% + font=\footnotesize,% + anchor=north,% + legend columns=-1},% + ddpuser% + },% + ddpweight/.style=% + {% + smooth,% + area style,% + ylabel=\DD@JK@trans@Weight% + },% + ddpweightplot/.style=% + {% + teal,% + fill=teal!50,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black}% + },% + ddpbloodpressure/.style=% + {% + ylabel=\DD@JK@trans@BloodPressure% + },% + ddpinsulin/.style=% + {% + ylabel=\DD@JK@trans@Insulin% + },% + ddpbloodsugar/.style=% + {% + smooth,% + ylabel=\DD@JK@trans@BloodSugar% + },% + ddppulse/.style=% + {% + smooth,% + ylabel=\DD@JK@trans@Pulse% + },% + ddpcu/.style=% + {% + ybar,% + ylabel=\DD@JK@trans@CU% + },% + ddphbaonec/.style=% + {% + ybar,% + ylabel=\DD@JK@trans@Hbaonec% + }, + nomarks/.style=% + {% + mark={}, + every mark/.style={}% + }% +}% +% \end{macrocode} +% We set some sensible defaults for \cmd\diadiatab +% +% \begin{itemize} +% \item replace \texttt{nan} with empty string +% \item replace empty cells with -- +% \item define \texttt{date} column as \texttt{date type} +% \item define \texttt{weight} and \texttt{hba1c} columns as \texttt{fixed,fixed zerofill,precision=1} +% \end{itemize} +% +% \begin{macrocode} +\pgfplotstableset% +{% + empty cells with={--},% + columns/date/.style={date type},% + columns/bsl1/.style={string replace={nan}{}},% + columns/bsl2/.style={string replace={nan}{}},% + columns/bsl3/.style={string replace={nan}{}},% + columns/id1/.style={string replace={nan}{}},% + columns/id2/.style={string replace={nan}{}},% + columns/id3/.style={string replace={nan}{}},% + columns/bps/.style={string replace={nan}{}},% + columns/bpd/.style={string replace={nan}{}},% + columns/weight/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% + columns/cu/.style={string replace={nan}{}},% + columns/pul/.style={string replace={nan}{}},% + columns/hba1c/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% + columns/value/.style={string replace={nan}{}},% + columns/avg07/.style={string replace={nan}{}},% + columns/avg14/.style={string replace={nan}{}},% + columns/avg30/.style={string replace={nan}{}},% + columns/avg60/.style={string replace={nan}{}},% + columns/avg90/.style={string replace={nan}{}}% +}% +% \end{macrocode} +% Now, we append the language dependent column headers to the column style! +% \begin{macrocode} +\pgfplotstableset% +{% + columns/date/.append style={column name={\DD@JK@trans@Date}},% + columns/bsl1/.append style={column name={\DD@JK@trans@BSi}},% + columns/bsl2/.append style={column name={\DD@JK@trans@BSii}},% + columns/bsl3/.append style={column name={\DD@JK@trans@BSiii}},% + columns/id1/.append style={column name={\DD@JK@trans@IDi}},% + columns/id2/.append style={column name={\DD@JK@trans@IDii}},% + columns/id3/.append style={column name={\DD@JK@trans@IDiii}},% + columns/bps/.append style={column name={\DD@JK@trans@BPs}},% + columns/bpd/.append style={column name={\DD@JK@trans@BPd}},% + columns/weight/.append style={column name={\DD@JK@trans@Weight}},% + columns/cu/.append style={column name={\DD@JK@trans@CU}},% + columns/pul/.append style={column name={\DD@JK@trans@Pulse}},% + columns/hba1c/.append style={column name={\DD@JK@trans@Hbaonec}},% + columns/value/.append style={column name={\DD@JK@trans@Value}},% + columns/avg07/.append style={column name={$\varnothing_{7}$}},% + columns/avg14/.append style={column name={$\varnothing_{14}$}},% + columns/avg30/.append style={column name={$\varnothing_{30}$}},% + columns/avg60/.append style={column name={$\varnothing_{60}$}},% + columns/avg90/.append style={column name={$\varnothing_{90}$}},% +}% +% \end{macrocode} +% We define the \texttt{diadiacyclelist} color cycle list used in plots. You may adjust it to your needs. +% Furthermore, we make these styles available as \texttt{plot1}, ..., \texttt{plot4}. +% \begin{macrocode} +\pgfplotscreateplotcyclelist{diadiacyclelist}% +{% + {teal,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black}},% + {orange,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black,rotate=180}},% + {cyan,mark=o,every mark/.append style={solid,fill=.!80!black}},% + {yellow,mark=star,every mark/.append style={solid,fill=.!80!black}}% +}% +\tikzset% +{% + plot1/.style=% + {% + teal,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black}% + },% + plot2/.style=% + {% + orange,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black,rotate=180}% + },% + plot3/.style=% + {% + cyan,% + mark=o,% + every mark/.append style={solid,fill=.!80!black}% + },% + plot4/.style=% + {% + yellow,% + mark=star,% + every mark/.append style={solid,fill=.!80!black}% + }% +}% +% \end{macrocode} +% We define the Ti\textit{k}z styles for annotations and limits. +% \begin{macrocode} +\tikzset% +{% + ddpannotation/.style=% + {% + fill=yellow!50!white,% + rectangle,% + rounded corners=3pt,% + font=\tiny% + },% + setlimit/.style=% + {% + red,% + thick% + },% + ddaddplotfill/.style=% + {% + fill=teal!50,% + },% +}% +% \end{macrocode} +% Finally, we define the \texttt{medicationchart} and \texttt{infobox} \texttt{tcolorbox} styles based on \texttt{ddboxdefault}! +% \begin{macrocode} +\tcbset% +{% + ddboxdefault/.style=% + {% + enhanced,% + fonttitle=\bfseries\large,% + coltitle=black,% + center title,% + titlerule=.75mm,% + toprule=1mm,% + bottomrule=1mm,% + toptitle=2mm,% + bottomtitle=2mm% + },% + medicationchart/.style=% + {% + ddboxdefault,% + fontupper=\footnotesize,% + colback=yellow!10!white,% + colframe=yellow!60!black,% + colbacktitle=yellow!20!white,% + left=0mm,% + right=0mm,% + top=0mm,% + bottom=0mm,% + boxsep=0mm,% + },% + infobox/.style=% + {% + ddboxdefault,% + width=\linewidth-10.888pt,% + colback=orange!10!white,% + colframe=orange!60!black,% + colbacktitle=orange!20!white% + },% +}% +% \end{macrocode} +% \begin{macrocode} +% +% \end{macrocode} +% \subsection{diadia.lua} +% \changes{v1.1}{2015/05/15}{added diadia.lua} +% \begin{macrocode} +%<*lua> +% \end{macrocode} +% \begin{macrocode} +#!/usr/bin/env texlua +-- +-- diadia [options] +-- +-- loads and processes a diadia data file +-- +-- License: LPPL +-- +% \end{macrocode} +% At first, we define a version variable and variables for the command line options. +% \begin{macrocode} +local version = "v1.0 (2015/05/15)" + +local infile = "" +local outfile = "" +local mode = "*" +local startdate = "" +local enddate = "" +local columns = "" +% \end{macrocode} +% Here, we define the central \texttt{data} variable. +% \begin{macrocode} +local data = {} +% \end{macrocode} +% A simple function to output the version information. +% \begin{macrocode} +function pversion() + print("diadia.lua " .. version) + print("(C) Josef Kleber 2015 License: LPPL") + os.exit(0) +end +% \end{macrocode} +% A function to output the help information. +% \begin{macrocode} +function phelp() + print([[ +diadia.lua [options] + + allows you to + + - cut a chunk out of the data file + e.g.: -i in.dat -o out.dat -s YYYY-MM-DD -e YYYY-MM-DD + + - compose a new data file based on given columns of an + existing data file + e.g.: -i in.dat -o out.dat -c 1,2 + + - create a new data file with date and value (1st and + 2nd column of existing file) and added value average + columns of the last 7, 14, 30, 60 and 90 days + e.g.: -i in.dat -o out.dat [-s YYYY-MM-DD -e YYYY-MM-DD] + + Options: + + -m specify the mode (cut|compose|average) + + -i specify the input file + + -o specify the output file + + -c specify the columns for compose mode + + -s specify the start date (YYYY-MM-DD) in + cut and average mode + + -e specify the end date + + -v prints version information + + -h prints help information + +]]) + pversion() +end +% \end{macrocode} +% This function checks if a given date string matches the YYYY-MM-DD format. +% \begin{macrocode} +function check_date(date) + if string.find(date, "(%d%d%d%d)-(%d%d)-(%d%d)") == nil + then + io.stderr:write ("Error 21: wrong date format (YYYY-MM-DD)\n") + os.exit(11) + end +end +% \end{macrocode} +% This function parses a date string and returns \texttt{year}, \texttt{month} and \texttt{day}. +% \begin{macrocode} +function parse_date(date) + return string.match(date, "(%d%d%d%d)%-(%d%d)%-(%d%d)") +end +% \end{macrocode} +% This function parses a given line (string) and returns a found date. +% \begin{macrocode} +function parse_dateinline(line) + return string.match(line, "(%d%d%d%d%-%d%d%-%d%d)") +end +% \end{macrocode} +% This function takes a Unix time and returns a date string in the YYYY-MM-DD format. +% \begin{macrocode} +function daystring(unixtime) + return os.date("%Y-%m-%d", unixtime) +end +% \end{macrocode} +% This function computes the Unix time of a given date. +% \begin{macrocode} +function unixtime(year,month,day) + return os.time{year=year, month=month, day=day} +end +% \end{macrocode} +% A simple rounding function. +% \begin{macrocode} +function round(number) + return math.floor(number+0.5) +end +% \end{macrocode} +% This function checks the length of a given string and returns a string of length 3. +% \begin{macrocode} +function ptd(value) + local val = tostring(value) + local slen = string.len(val) + if slen == 3 + then + return val + else + return val .. " " + end +end +% \end{macrocode} +% This function calculates the average value of a given \texttt{date} in the last \texttt{days} days in a \texttt{data} table. +% \begin{macrocode} +function calc_avg(data,date,days) + local sum = 0 + local wdays = 0 + local wday +% \end{macrocode} +% We calculate the Unix time of the given day (\texttt{enddate}) and the derived \texttt{startday}. +% \begin{macrocode} + local endday = unixtime(parse_date(date)) + local startday = endday - 60*60*24*(days-1) +% \end{macrocode} +% We loop through our \texttt{data} table until we reach \texttt{endday} +% \begin{macrocode} + while startday <= endday + do +% \end{macrocode} +% We create a date string and check if there is a \texttt{data} entry with this key. +% If so, we sum up the value and increase the \texttt{wdays} counter +% \begin{macrocode} + wday = daystring(startday) + if data[wday] ~= nil + then + sum = sum + data[wday] + wdays = wdays + 1 + end + startday = startday + 60*60*24 + end +% \end{macrocode} +% If entries were found, we return the rounded average value as string. +% \begin{macrocode} + if wdays == 0 + then + return "nan" + else + return tostring(round(sum/wdays)) + end +end +% \end{macrocode} +% This function reads in the first two columns of a given \texttt{file} into a \texttt{data} table. +% \begin{macrocode} +function read_data(file) + local data = {} + local date + local startdate + local enddate + local dat + local firstline = true +% \end{macrocode} +% We itertate over \texttt{file} lines. +% \begin{macrocode} + for line in io.lines(file) + do +% \end{macrocode} +% If we match \enquote{date}, we've found the header row and ignore it. +% \begin{macrocode} + if string.match(line, "date") + then + else +% \end{macrocode} +% Otherwise, we match for a \texttt{date} and a \texttt{value}. +% \begin{macrocode} + date, dat = string.match(line, "(%d%d%d%d%-%d%d%-%d%d)%s+(%S+)") +% \end{macrocode} +% We set \texttt{startdate} with the first \texttt{date} we've found. +% \begin{macrocode} + if firstline == true + then + startdate = date + firstline = false + end +% \end{macrocode} +% Moreover, we write a non-empty and non-\texttt{nan} value in our \texttt{data} table. +% \begin{macrocode} + if dat ~= "nan" and dat ~= "{}" and dat ~= "" + then + data[date] = dat + end + end + end + enddate = date +% \end{macrocode} +% Finally, we return \texttt{data}, \texttt{startdate} and \texttt{enddate}. +% \begin{macrocode} + return data,startdate,enddate +end +% \end{macrocode} +% This function writes a new \texttt{data file} based on given start and end date. +% \begin{macrocode} +function write_avg_file(data,file,startdate,enddate) + local sdate + local edate + local wday +% \end{macrocode} +% First, we compute the Unix times of \texttt{startdate} and \texttt{enddate} for comparisons +% \begin{macrocode} + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) +% \end{macrocode} +% We open a \texttt{file} with write privilege and write the header row. +% \begin{macrocode} + outfile = assert(io.open(file, "w")) + outfile:write("date value avg07 avg14 avg30 avg60 avg90") +% \end{macrocode} +% Then, we loop through our \texttt{data} table. If we do find a \texttt{data} entry, we write the \texttt{date}, +% \texttt{value} and averages into the \texttt{file}. +% \begin{macrocode} + while sdate <= edate+7200 + do + wday = daystring(sdate) + if data[wday] ~= nil + then + outfile:write("\n" .. wday .. " " + .. ptd(data[wday]) .. " " + .. ptd(calc_avg(data,wday,7)) .. " " + .. ptd(calc_avg(data,wday,14)) .. " " + .. ptd(calc_avg(data,wday,30)) .. " " + .. ptd(calc_avg(data,wday,60)) .. " " + .. ptd(calc_avg(data,wday,90))) + end + sdate = sdate + 60*60*24 + end +% \end{macrocode} +% Finally, we close the \texttt{file}. +% \begin{macrocode} + outfile:close() +end +% \end{macrocode} +% It's time to evaluate the commad line options with a \texttt{getopt} routine. +% \begin{macrocode} +do + local newarg = {} + local i, limit = 1, #arg + while (i <= limit) do + if arg[i] == "-i" then + infile = arg[i+1] + i = i + 1 + elseif arg[i] == "-o" then + outfile = arg[i+1] + i = i + 1 + elseif arg[i] == "-s" then + startdate = arg[i+1] + i = i + 1 + elseif arg[i] == "-e" then + enddate = arg[i+1] + i = i + 1 + elseif arg[i] == "-c" then + columns = arg[i+1] + i = i + 1 + elseif arg[i] == "-m" then + mode = arg[i+1] + i = i + 1 + elseif arg[i] == "-v" then + pversion() + elseif arg[i] == "-h" then + phelp() + else + newarg[#newarg+1] = arg[i] + end + i = i + 1 + end + arg = newarg +end +% \end{macrocode} +% In \texttt{average} mode, we first read in the \texttt{infile} and check for given start and end dates and use them if present. +% \begin{macrocode} +if mode == "average" +then + local startd + local endd + + print("set mode to " .. mode) + print("reading data file " .. infile) + data,startd,endd = read_data(infile) + if startdate ~= "" + then + startd = startdate + end + if enddate ~= "" + then + endd = enddate + end + print("writing data file " .. outfile) +% \end{macrocode} +% Finally, we write the new \texttt{outfile}. +% \begin{macrocode} + write_avg_file(data,outfile,startd,endd) + os.exit(0) +end +% \end{macrocode} +% In \texttt{compose} mode, we first read in the \texttt{data file}. +% \begin{macrocode} +if mode == "compose" +then + local row = 0 + local column = 0 + local ofile + local cols + + print("set mode to " .. mode) + print("reading data file " .. infile) + for line in io.lines(infile) + do + row = row + 1 + data[row] = {} + column = 0 + for value in string.gmatch(line, "%S+") + do + column = column + 1 + data[row][column] = value + end + end +% \end{macrocode} +% Then, we evaluate the given list of columns. I have no idea how it works exactly. +% Many thanks to Paul Kulchenko and Egor Skriptunoff\newline +% \href{https://stackoverflow.com/questions/30242212/how-to-output-more-than-one-column/}{https://stackoverflow.com/questions/30242212/how-to-output-more-than-one-column/} +% \begin{macrocode} + cols = assert(load("return table.concat({"..columns:gsub("%d+","(...)[%0]").."},' ')")) + ofile = assert(io.open(outfile, "w")) + print("writing data file " .. outfile) +% \end{macrocode} +% Finally, we loop through the rows of our \texttt{data} table and write the choosen columns. +% We don't issue a new line character in the last row! +% \begin{macrocode} + for irow = 1,row + do + if irow == row + then + ofile:write(cols(data[irow])) + else + ofile:write(cols(data[irow]).."\n") + end + end + ofile:close() + os.exit(0) +end +% \end{macrocode} +% In \texttt{cut} mode we check the format and compute the Unix times of the given start and end dates. +% \begin{macrocode} +if mode == "cut" +then + local ofile + local date + local sdate + local edate + local cdate + + check_date(startdate) + check_date(enddate) + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) + print("set mode to " .. mode) + print("reading data file " .. infile) + print("writing data file " .. outfile) +% \end{macrocode} +% We open the \texttt{outfile} with writing privilege and loop trough \texttt{infile}. +% \begin{macrocode} + ofile = assert(io.open(outfile, "w")) + for line in io.lines(infile) + do +% \end{macrocode} +% Of course, we copy the header row. +% \begin{macrocode} + if string.match(line, "date") + then + ofile:write(line) +% \end{macrocode} +% Furthermore, we check if the date of the current \texttt{line} is within the given dates and write the \texttt{line} to the file. +% \begin{macrocode} + else + date = parse_dateinline(line) + cdate = unixtime(parse_date(date)) + if cdate >= sdate and cdate <= edate + then + ofile:write("\n" .. line) + end + end + end + ofile:close() + os.exit(0) +end +% \end{macrocode} +% Finally, we issue errors for incorrect \texttt{mode}s. +% \begin{macrocode} +if mode == "*" +then + io.stderr:write ("Error 11: no mode specified!") + os.exit(11) +else + io.stderr:write ("Error 12: invalid mode " .. mode) + os.exit(12) +end +% \end{macrocode} +% \begin{macrocode} +% +% \end{macrocode} %\Finale \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/diadia/diadia.pdf b/Master/texmf-dist/doc/latex/diadia/diadia.pdf index bb77998cf74..fb66926d609 100644 Binary files a/Master/texmf-dist/doc/latex/diadia/diadia.pdf and b/Master/texmf-dist/doc/latex/diadia/diadia.pdf differ diff --git a/Master/texmf-dist/doc/latex/diadia/makefile b/Master/texmf-dist/doc/latex/diadia/makefile index 162ddc303f4..c33ed3cc8c9 100644 --- a/Master/texmf-dist/doc/latex/diadia/makefile +++ b/Master/texmf-dist/doc/latex/diadia/makefile @@ -34,19 +34,25 @@ install: doc cp *.dat ${TEXMF}/doc/latex/${PKGNAME}/ cp *.tex ${TEXMF}/doc/latex/${PKGNAME}/ cp *.pdf ${TEXMF}/doc/latex/${PKGNAME}/ + mkdir -p ${TEXMF}/scripts/${PKGNAME} + cp *.lua ${TEXMF}/scripts/${PKGNAME}/ mkdir -p ${TEXMF}/tex/latex/${PKGNAME} cp *.sty ${TEXMF}/tex/latex/${PKGNAME}/ + cp *.cfg ${TEXMF}/tex/latex/${PKGNAME}/ cp *.trsl ${TEXMF}/tex/latex/${PKGNAME}/ texhash uninstall: rm -rf ${TEXMF}/doc/latex/${PKGNAME} + rm -rf ${TEXMF}/scripts/${PKGNAME} rm -rf ${TEXMF}/tex/latex/${PKGNAME} texhash git: package cp *.sty ./../tex/latex/${PKGNAME} + cp *.cfg ./../tex/latex/${PKGNAME} cp *.trsl ./../tex/latex/${PKGNAME} + cp *.lua ./../scripts/${PKGNAME} ctan: ./copyCTAN @@ -57,7 +63,7 @@ clean: *.bbl *.blg *.ins *.txt *.bib cleanall: clean - $(RM) $(PKGNAME).pdf $(PKGNAME)-example.pdf $(PKGNAME)-example.tex $(PKGNAME).sty \ - README *.dat *.trsl *.tex + $(RM) $(PKGNAME).pdf $(PKGNAME)-example.pdf $(PKGNAME)-example.tex \ + $(PKGNAME).sty $(PKGNAME).lua README *.dat *.trsl *.tex .PHONY: all doc package example install uninstall git ctan clean cleanall diff --git a/Master/texmf-dist/doc/latex/diadia/manifest.txt b/Master/texmf-dist/doc/latex/diadia/manifest.txt index 707e36bf8f7..94b5daa0795 100644 --- a/Master/texmf-dist/doc/latex/diadia/manifest.txt +++ b/Master/texmf-dist/doc/latex/diadia/manifest.txt @@ -2,14 +2,14 @@ This work consists of the following files: diadia.pdf diadia.dtx +diadia-example.pdf README makefile Files packaged in diadia.dtx: diadia.sty -diadia-example.tex -> diadia-example.pdf -manifest.txt +diadia.cfg diadia-fallback.trsl diadia-english.trsl diadia-german.trsl @@ -18,3 +18,5 @@ diadia.dat 201503.dat 201504.dat hba1c.dat +diadia-example.tex +manifest.txt diff --git a/Master/texmf-dist/scripts/diadia/diadia.lua b/Master/texmf-dist/scripts/diadia/diadia.lua new file mode 100644 index 00000000000..81d668499e7 --- /dev/null +++ b/Master/texmf-dist/scripts/diadia/diadia.lua @@ -0,0 +1,298 @@ +#!/usr/bin/env texlua +-- +-- diadia [options] +-- +-- loads and processes a diadia data file +-- +-- License: LPPL +-- +local version = "v1.0 (2015/05/15)" + +local infile = "" +local outfile = "" +local mode = "*" +local startdate = "" +local enddate = "" +local columns = "" +local data = {} +function pversion() + print("diadia.lua " .. version) + print("(C) Josef Kleber 2015 License: LPPL") + os.exit(0) +end +function phelp() + print([[ +diadia.lua [options] + + allows you to + + - cut a chunk out of the data file + e.g.: -i in.dat -o out.dat -s YYYY-MM-DD -e YYYY-MM-DD + + - compose a new data file based on given columns of an + existing data file + e.g.: -i in.dat -o out.dat -c 1,2 + + - create a new data file with date and value (1st and + 2nd column of existing file) and added value average + columns of the last 7, 14, 30, 60 and 90 days + e.g.: -i in.dat -o out.dat [-s YYYY-MM-DD -e YYYY-MM-DD] + + Options: + + -m specify the mode (cut|compose|average) + + -i specify the input file + + -o specify the output file + + -c specify the columns for compose mode + + -s specify the start date (YYYY-MM-DD) in + cut and average mode + + -e specify the end date + + -v prints version information + + -h prints help information + +]]) + pversion() +end +function check_date(date) + if string.find(date, "(%d%d%d%d)-(%d%d)-(%d%d)") == nil + then + io.stderr:write ("Error 21: wrong date format (YYYY-MM-DD)\n") + os.exit(11) + end +end +function parse_date(date) + return string.match(date, "(%d%d%d%d)%-(%d%d)%-(%d%d)") +end +function parse_dateinline(line) + return string.match(line, "(%d%d%d%d%-%d%d%-%d%d)") +end +function daystring(unixtime) + return os.date("%Y-%m-%d", unixtime) +end +function unixtime(year,month,day) + return os.time{year=year, month=month, day=day} +end +function round(number) + return math.floor(number+0.5) +end +function ptd(value) + local val = tostring(value) + local slen = string.len(val) + if slen == 3 + then + return val + else + return val .. " " + end +end +function calc_avg(data,date,days) + local sum = 0 + local wdays = 0 + local wday + local endday = unixtime(parse_date(date)) + local startday = endday - 60*60*24*(days-1) + while startday <= endday + do + wday = daystring(startday) + if data[wday] ~= nil + then + sum = sum + data[wday] + wdays = wdays + 1 + end + startday = startday + 60*60*24 + end + if wdays == 0 + then + return "nan" + else + return tostring(round(sum/wdays)) + end +end +function read_data(file) + local data = {} + local date + local startdate + local enddate + local dat + local firstline = true + for line in io.lines(file) + do + if string.match(line, "date") + then + else + date, dat = string.match(line, "(%d%d%d%d%-%d%d%-%d%d)%s+(%S+)") + if firstline == true + then + startdate = date + firstline = false + end + if dat ~= "nan" and dat ~= "{}" and dat ~= "" + then + data[date] = dat + end + end + end + enddate = date + return data,startdate,enddate +end +function write_avg_file(data,file,startdate,enddate) + local sdate + local edate + local wday + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) + outfile = assert(io.open(file, "w")) + outfile:write("date value avg07 avg14 avg30 avg60 avg90") + while sdate <= edate+7200 + do + wday = daystring(sdate) + if data[wday] ~= nil + then + outfile:write("\n" .. wday .. " " + .. ptd(data[wday]) .. " " + .. ptd(calc_avg(data,wday,7)) .. " " + .. ptd(calc_avg(data,wday,14)) .. " " + .. ptd(calc_avg(data,wday,30)) .. " " + .. ptd(calc_avg(data,wday,60)) .. " " + .. ptd(calc_avg(data,wday,90))) + end + sdate = sdate + 60*60*24 + end + outfile:close() +end +do + local newarg = {} + local i, limit = 1, #arg + while (i <= limit) do + if arg[i] == "-i" then + infile = arg[i+1] + i = i + 1 + elseif arg[i] == "-o" then + outfile = arg[i+1] + i = i + 1 + elseif arg[i] == "-s" then + startdate = arg[i+1] + i = i + 1 + elseif arg[i] == "-e" then + enddate = arg[i+1] + i = i + 1 + elseif arg[i] == "-c" then + columns = arg[i+1] + i = i + 1 + elseif arg[i] == "-m" then + mode = arg[i+1] + i = i + 1 + elseif arg[i] == "-v" then + pversion() + elseif arg[i] == "-h" then + phelp() + else + newarg[#newarg+1] = arg[i] + end + i = i + 1 + end + arg = newarg +end +if mode == "average" +then + local startd + local endd + + print("set mode to " .. mode) + print("reading data file " .. infile) + data,startd,endd = read_data(infile) + if startdate ~= "" + then + startd = startdate + end + if enddate ~= "" + then + endd = enddate + end + print("writing data file " .. outfile) + write_avg_file(data,outfile,startd,endd) + os.exit(0) +end +if mode == "compose" +then + local row = 0 + local column = 0 + local ofile + local cols + + print("set mode to " .. mode) + print("reading data file " .. infile) + for line in io.lines(infile) + do + row = row + 1 + data[row] = {} + column = 0 + for value in string.gmatch(line, "%S+") + do + column = column + 1 + data[row][column] = value + end + end + cols = assert(load("return table.concat({"..columns:gsub("%d+","(...)[%0]").."},' ')")) + ofile = assert(io.open(outfile, "w")) + print("writing data file " .. outfile) + for irow = 1,row + do + if irow == row + then + ofile:write(cols(data[irow])) + else + ofile:write(cols(data[irow]).."\n") + end + end + ofile:close() + os.exit(0) +end +if mode == "cut" +then + local ofile + local date + local sdate + local edate + local cdate + + check_date(startdate) + check_date(enddate) + sdate = unixtime(parse_date(startdate)) + edate = unixtime(parse_date(enddate)) + print("set mode to " .. mode) + print("reading data file " .. infile) + print("writing data file " .. outfile) + ofile = assert(io.open(outfile, "w")) + for line in io.lines(infile) + do + if string.match(line, "date") + then + ofile:write(line) + else + date = parse_dateinline(line) + cdate = unixtime(parse_date(date)) + if cdate >= sdate and cdate <= edate + then + ofile:write("\n" .. line) + end + end + end + ofile:close() + os.exit(0) +end +if mode == "*" +then + io.stderr:write ("Error 11: no mode specified!") + os.exit(11) +else + io.stderr:write ("Error 12: invalid mode " .. mode) + os.exit(12) +end diff --git a/Master/texmf-dist/tex/latex/diadia/diadia-english.trsl b/Master/texmf-dist/tex/latex/diadia/diadia-english.trsl index e7ce8601176..de351b24d0c 100644 --- a/Master/texmf-dist/tex/latex/diadia/diadia-english.trsl +++ b/Master/texmf-dist/tex/latex/diadia/diadia-english.trsl @@ -52,6 +52,7 @@ \DeclareTranslation{English}{dd-CU}{CU}% \DeclareTranslation{English}{dd-Pulse}{Pulse}% \DeclareTranslation{English}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslation{English}{dd-Value}{Value}% \endinput %% %% End of file `diadia-english.trsl'. diff --git a/Master/texmf-dist/tex/latex/diadia/diadia-fallback.trsl b/Master/texmf-dist/tex/latex/diadia/diadia-fallback.trsl index 2e004f0dce7..772e9bcb80b 100644 --- a/Master/texmf-dist/tex/latex/diadia/diadia-fallback.trsl +++ b/Master/texmf-dist/tex/latex/diadia/diadia-fallback.trsl @@ -52,6 +52,7 @@ \DeclareTranslationFallback{dd-CU}{CU}% \DeclareTranslationFallback{dd-Pulse}{Pulse}% \DeclareTranslationFallback{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslationFallback{dd-Value}{Value}% \endinput %% %% End of file `diadia-fallback.trsl'. diff --git a/Master/texmf-dist/tex/latex/diadia/diadia-german.trsl b/Master/texmf-dist/tex/latex/diadia/diadia-german.trsl index eff74b88906..3233204b09b 100644 --- a/Master/texmf-dist/tex/latex/diadia/diadia-german.trsl +++ b/Master/texmf-dist/tex/latex/diadia/diadia-german.trsl @@ -52,6 +52,7 @@ \DeclareTranslation{German}{dd-CU}{BE}% \DeclareTranslation{German}{dd-Pulse}{Puls}% \DeclareTranslation{German}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}% +\DeclareTranslation{German}{dd-Value}{Wert}% \endinput %% %% End of file `diadia-german.trsl'. diff --git a/Master/texmf-dist/tex/latex/diadia/diadia.cfg b/Master/texmf-dist/tex/latex/diadia/diadia.cfg new file mode 100644 index 00000000000..12eaf409dd2 --- /dev/null +++ b/Master/texmf-dist/tex/latex/diadia/diadia.cfg @@ -0,0 +1,233 @@ +%% +%% This is file `diadia.cfg', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% diadia.dtx (with options: `cfg') +%% +%% Copyright (C) 2015 by: +%% Josef Kleber +%% +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2003/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +\pgfplotsset{% + compat=1.12,% + date ZERO=2015-01-01% +}% +\pgfplotsset{% + ddpuser/.style=% + {},% + ddpdefault/.style=% + {% + thick,% + date coordinates in=x,% + cycle list name=diadiacyclelist,% + tick align=inside,% + unbounded coords=jump,% + xticklabel={\day.\month.},% + legend style={at={(0.5,-0.25)},% + font=\footnotesize,% + anchor=north,% + legend columns=-1},% + ddpuser% + },% + ddpweight/.style=% + {% + smooth,% + area style,% + ylabel=\DD@JK@trans@Weight% + },% + ddpweightplot/.style=% + {% + teal,% + fill=teal!50,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black}% + },% + ddpbloodpressure/.style=% + {% + ylabel=\DD@JK@trans@BloodPressure% + },% + ddpinsulin/.style=% + {% + ylabel=\DD@JK@trans@Insulin% + },% + ddpbloodsugar/.style=% + {% + smooth,% + ylabel=\DD@JK@trans@BloodSugar% + },% + ddppulse/.style=% + {% + smooth,% + ylabel=\DD@JK@trans@Pulse% + },% + ddpcu/.style=% + {% + ybar,% + ylabel=\DD@JK@trans@CU% + },% + ddphbaonec/.style=% + {% + ybar,% + ylabel=\DD@JK@trans@Hbaonec% + }, + nomarks/.style=% + {% + mark={}, + every mark/.style={}% + }% +}% +\pgfplotstableset% +{% + empty cells with={--},% + columns/date/.style={date type},% + columns/bsl1/.style={string replace={nan}{}},% + columns/bsl2/.style={string replace={nan}{}},% + columns/bsl3/.style={string replace={nan}{}},% + columns/id1/.style={string replace={nan}{}},% + columns/id2/.style={string replace={nan}{}},% + columns/id3/.style={string replace={nan}{}},% + columns/bps/.style={string replace={nan}{}},% + columns/bpd/.style={string replace={nan}{}},% + columns/weight/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% + columns/cu/.style={string replace={nan}{}},% + columns/pul/.style={string replace={nan}{}},% + columns/hba1c/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% + columns/value/.style={string replace={nan}{}},% + columns/avg07/.style={string replace={nan}{}},% + columns/avg14/.style={string replace={nan}{}},% + columns/avg30/.style={string replace={nan}{}},% + columns/avg60/.style={string replace={nan}{}},% + columns/avg90/.style={string replace={nan}{}}% +}% +\pgfplotstableset% +{% + columns/date/.append style={column name={\DD@JK@trans@Date}},% + columns/bsl1/.append style={column name={\DD@JK@trans@BSi}},% + columns/bsl2/.append style={column name={\DD@JK@trans@BSii}},% + columns/bsl3/.append style={column name={\DD@JK@trans@BSiii}},% + columns/id1/.append style={column name={\DD@JK@trans@IDi}},% + columns/id2/.append style={column name={\DD@JK@trans@IDii}},% + columns/id3/.append style={column name={\DD@JK@trans@IDiii}},% + columns/bps/.append style={column name={\DD@JK@trans@BPs}},% + columns/bpd/.append style={column name={\DD@JK@trans@BPd}},% + columns/weight/.append style={column name={\DD@JK@trans@Weight}},% + columns/cu/.append style={column name={\DD@JK@trans@CU}},% + columns/pul/.append style={column name={\DD@JK@trans@Pulse}},% + columns/hba1c/.append style={column name={\DD@JK@trans@Hbaonec}},% + columns/value/.append style={column name={\DD@JK@trans@Value}},% + columns/avg07/.append style={column name={$\varnothing_{7}$}},% + columns/avg14/.append style={column name={$\varnothing_{14}$}},% + columns/avg30/.append style={column name={$\varnothing_{30}$}},% + columns/avg60/.append style={column name={$\varnothing_{60}$}},% + columns/avg90/.append style={column name={$\varnothing_{90}$}},% +}% +\pgfplotscreateplotcyclelist{diadiacyclelist}% +{% + {teal,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black}},% + {orange,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black,rotate=180}},% + {cyan,mark=o,every mark/.append style={solid,fill=.!80!black}},% + {yellow,mark=star,every mark/.append style={solid,fill=.!80!black}}% +}% +\tikzset% +{% + plot1/.style=% + {% + teal,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black}% + },% + plot2/.style=% + {% + orange,% + mark=halfcircle*,% + every mark/.append style={solid,fill=.!80!black,rotate=180}% + },% + plot3/.style=% + {% + cyan,% + mark=o,% + every mark/.append style={solid,fill=.!80!black}% + },% + plot4/.style=% + {% + yellow,% + mark=star,% + every mark/.append style={solid,fill=.!80!black}% + }% +}% +\tikzset% +{% + ddpannotation/.style=% + {% + fill=yellow!50!white,% + rectangle,% + rounded corners=3pt,% + font=\tiny% + },% + setlimit/.style=% + {% + red,% + thick% + },% + ddaddplotfill/.style=% + {% + fill=teal!50,% + },% +}% +\tcbset% +{% + ddboxdefault/.style=% + {% + enhanced,% + fonttitle=\bfseries\large,% + coltitle=black,% + center title,% + titlerule=.75mm,% + toprule=1mm,% + bottomrule=1mm,% + toptitle=2mm,% + bottomtitle=2mm% + },% + medicationchart/.style=% + {% + ddboxdefault,% + fontupper=\footnotesize,% + colback=yellow!10!white,% + colframe=yellow!60!black,% + colbacktitle=yellow!20!white,% + left=0mm,% + right=0mm,% + top=0mm,% + bottom=0mm,% + boxsep=0mm,% + },% + infobox/.style=% + {% + ddboxdefault,% + width=\linewidth-10.888pt,% + colback=orange!10!white,% + colframe=orange!60!black,% + colbacktitle=orange!20!white% + },% +}% +\endinput +%% +%% End of file `diadia.cfg'. diff --git a/Master/texmf-dist/tex/latex/diadia/diadia.sty b/Master/texmf-dist/tex/latex/diadia/diadia.sty index a6e5cf83293..4d4b7af2e23 100644 --- a/Master/texmf-dist/tex/latex/diadia/diadia.sty +++ b/Master/texmf-dist/tex/latex/diadia/diadia.sty @@ -27,7 +27,7 @@ %% This work consists of all files listed in manifest.txt. %% \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{diadia}[2015/05/11 v1.0 diadia.sty - Josef Kleber (C) 2015]% +\ProvidesPackage{diadia}[2015/05/20 v1.1 diadia.sty - Josef Kleber (C) 2015]% \RequirePackage{xkeyval}% \newcommand*\DD@JK@define@key[4]% {% @@ -65,6 +65,7 @@ \RequirePackage[many]{tcolorbox}% \RequirePackage{environ}% \RequirePackage{multicol}% +\RequirePackage{amssymb}% \usepgfplotslibrary{dateplot}% \def\DD@JK@closedcycle{}% \def\DD@JK@addplotdefault{}% @@ -97,176 +98,16 @@ \def\DD@JK@trans@CU{\GetTranslation{dd-CU}}% \def\DD@JK@trans@Pulse{\GetTranslation{dd-Pulse}}% \def\DD@JK@trans@Hbaonec{\GetTranslation{dd-Hbaonec}}% +\def\DD@JK@trans@Value{\GetTranslation{dd-Value}}% \newcolumntype{Z}{>{\raggedright\let\newline\\\arraybackslash}X}% \newcolumntype{Y}{>{\raggedright\let\newline\\\arraybackslash}p{\DD@JK@mcnotewidth}}% -\pgfplotsset{% - compat=1.12,% - date ZERO=2015-01-01% -}% -\pgfplotsset{% - ddpuser/.style=% - {},% - ddpdefault/.style=% - {% - thick,% - date coordinates in=x,% - xticklabel={\day.\month.},% - legend style={at={(0.5,-0.25)},% - font=\footnotesize,% - anchor=north,% - legend columns=-1},% - ddpuser% - },% - ddpweight/.style=% - {% - smooth,% - area style,% - ylabel=\DD@JK@trans@Weight% - },% - ddpweightplot/.style=% - {% - teal,% - fill=teal!50,% - mark=halfcircle*,% - every mark/.append style={solid,fill=.!80!black}% - },% - ddpbloodpressure/.style=% - {% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@BloodPressure% - },% - ddpinsulin/.style=% - {% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Insulin% - },% - ddpbloodsugar/.style=% - {% - smooth,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@BloodSugar% - },% - ddppulse/.style=% - {% - smooth,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Pulse% - },% - ddpcu/.style=% - {% - ybar,% - tick align=inside,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@CU% - },% - ddphbaonec/.style=% - {% - ybar,% - tick align=inside,% - cycle list name=diadiacyclelist,% - unbounded coords=jump,% - ylabel=\DD@JK@trans@Hbaonec% - }% -}% -\pgfplotstableset% +\IfFileExists{diadia.cfg}% {% - empty cells with={--},% - columns/date/.style={date type},% - columns/bsl1/.style={string replace={nan}{}},% - columns/bsl2/.style={string replace={nan}{}},% - columns/bsl3/.style={string replace={nan}{}},% - columns/id1/.style={string replace={nan}{}},% - columns/id2/.style={string replace={nan}{}},% - columns/id3/.style={string replace={nan}{}},% - columns/bps/.style={string replace={nan}{}},% - columns/bpd/.style={string replace={nan}{}},% - columns/weight/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},% - columns/cu/.style={string replace={nan}{}},% - columns/pul/.style={string replace={nan}{}},% - columns/hba1c/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}}% + \input{diadia.cfg}% }% -\pgfplotstableset% {% - columns/date/.append style={column name={\DD@JK@trans@Date}},% - columns/bsl1/.append style={column name={\DD@JK@trans@BSi}},% - columns/bsl2/.append style={column name={\DD@JK@trans@BSii}},% - columns/bsl3/.append style={column name={\DD@JK@trans@BSiii}},% - columns/id1/.append style={column name={\DD@JK@trans@IDi}},% - columns/id2/.append style={column name={\DD@JK@trans@IDii}},% - columns/id3/.append style={column name={\DD@JK@trans@IDiii}},% - columns/bps/.append style={column name={\DD@JK@trans@BPs}},% - columns/bpd/.append style={column name={\DD@JK@trans@BPd}},% - columns/weight/.append style={column name={\DD@JK@trans@Weight}},% - columns/cu/.append style={column name={\DD@JK@trans@CU}},% - columns/pul/.append style={column name={\DD@JK@trans@Pulse}},% - columns/hba1c/.append style={column name={\DD@JK@trans@Hbaonec}}% -}% -\pgfplotscreateplotcyclelist{diadiacyclelist}% -{% - {teal,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black}},% - {orange,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black,rotate=180}},% - {cyan,mark=o,every mark/.append style={solid,fill=.!80!black}},% - {yellow,mark=star,every mark/.append style={solid,fill=.!80!black}}% -}% -\tikzset% -{% - ddpannotation/.style=% - {% - fill=yellow!50!white,% - rectangle,% - rounded corners=3pt,% - font=\tiny% - },% - setlimit/.style=% - {% - red,% - thick% - },% - ddaddplotfill/.style=% - {% - fill=teal!50,% - },% -}% -\tcbset% -{% - ddboxdefault/.style=% - {% - enhanced,% - fonttitle=\bfseries\large,% - coltitle=black,% - center title,% - titlerule=.75mm,% - toprule=1mm,% - bottomrule=1mm,% - toptitle=2mm,% - bottomtitle=2mm% - },% - medicationchart/.style=% - {% - ddboxdefault,% - fontupper=\footnotesize,% - colback=yellow!10!white,% - colframe=yellow!60!black,% - colbacktitle=yellow!20!white,% - left=0mm,% - right=0mm,% - top=0mm,% - bottom=0mm,% - boxsep=0mm,% - },% - infobox/.style=% - {% - ddboxdefault,% - width=\linewidth-10.888pt,% - colback=orange!10!white,% - colframe=orange!60!black,% - colbacktitle=orange!20!white% - },% + \PackageError{diadia}{diadia.cfg not found}% + {Please install diadia.cfg! The style definitions are missing!}% }% \newcommand*{\annotation}[4][]% {% -- cgit v1.2.3