Based on Alan Munn's comment, I tried the conditionals from fancyhdr. These worked well. There are three conditionals, iftopfloat\iftopfloat, \ifbottomfloat, \iffloatpage.
To conditionally draw the line using TikZ,
\iftopfloat{% \draw [dim,|<->|] (1in+\innermargin-0.3cm, \paperheight-1in-\topmargin-\headheight-\headsep)-- ++(0,-\topfraction\textheight) node[left,text width=1.5cm,text ragged] at ++ (0,0.4\textheight) {top\\ fraction\\ \topfraction}}{}; \draw[dim,|-|] ( (1in+\innermargin+0.3cm,\paperheight-1in-\topmargin-\headheight-\headsep-\topfraction\textheight) -- ++(0,-\textfloatsep);