; ; This procedure calculates the start time of a CME from coefficients ; generated by POLYFITW or some other polynomial fitting routine. ; coeffs are the returned coefficients from the fitting routine, ; ; FUNCTION df_starttimes,coeffs ; Get coeffs for cubic polynomial c1=coeffs(0) ; constant term c2=coeffs(1) ; linear term c3=coeffs(2) ; quadratic term c4=coeffs(3) ; cubic term starttimes=fltarr(2) ht=[c1-1,c2,c3,c4] ; Need to set h(t)=1 and then find the roots. dhdt=[c2,2*c3,3*c4] ; first derivative of h(t) d2hdt2=[2*c3,6*c4] ; second derivative of h(t) ; ; Now, lets get the roots we need. We need to know where h(t)=1 and ; where dh/dt=0 and where second derivative, d2hdt2=0. This will tell ; us what we have to do. ; Here are the solutions to h(t)=1 roots=FZ_ROOTS(ht) ht_roots=FLOAT(roots) ; Get the solutions from h(t)=1 tmp=SIZE(ht_roots) num_roots_ht=tmp(1) ; here are the number of solutions to h(t)=1 ; Here is where dh/dt=0 roots=FZ_ROOTS(dhdt) dhdt_roots=FLOAT(roots) ; Get the roots of dh/dt=0 tmp=SIZE(dhdt_roots) num_roots_dhdt=tmp(1) ; Get the number of real roots from dh/dt ; Here is where d2hdt2=0 roots=FZ_ROOTS(d2hdt2) d2hdt2_roots=FLOAT(roots) ; get the roots of second derivative tmp=SIZE(d2hdt2_roots) num_roots_d2hdt2=tmp(1) ; number of roots from d2h/dt2 ; ;--- Start times for a Cubic Polynomial ; ; Start with the case that c4 > 0, rate of acceleration is increasing ; There are three possibilities: ; 1. dh/dt has no roots. ; 2. dh/dt has one root. ; 3. dh/dt has two roots. ; ; We also want to look at the possibility that h(t) may have 1 solution ; at r=1 or it may have 3 solutions at r=1. For 1 solution, take it, for ; 3 solutions, take the latest one. ; IF (c4 GT 0) THEN BEGIN ;{ Begin case 1 IF (num_roots_dhdt EQ 0) THEN BEGIN starttimes[0]=ht_roots[0] ; one time is where h(t)=1 starttimes[1]=d2hdt2_roots[0] ; the other is where d2h/dt2=0 RETURN,starttimes ENDIF IF (num_roots_dhdt EQ 1) THEN BEGIN starttimes[0]=d2hdt2_roots[0] ;one time is where second derivative=0 starttimes[1]=ht_roots[0] ; The other is where h(t)=1 RETURN,starttimes ENDIF IF (num_roots_dhdt EQ 2) THEN BEGIN starttimes[0]=(dhdt_roots(0) > dhdt_roots(1)) ;take largest root of dh/dt IF (num_roots_ht EQ 1) THEN $ starttimes[1]=ht_roots[0] ;take the only root IF (num_roots_ht EQ 3) THEN $ starttimes[1]=ht_roots[2] ;take the latest one RETURN,starttimes ENDIF ENDIF ;} end case 1 ; ; Now, if c4 < 0 there is only one physically meaningful situation, that ; of dh/dt having two roots. Anythings else (no roots or one root), ; means that the velocity of the CME never became positive. ; IF (c4 LT 0) THEN BEGIN ;{ begin case 2 IF (num_roots_dhdt EQ 2) THEN BEGIN ;IF (num_roots_ht EQ 1) THEN starttimes[0]=d2hdt2[0] ;pick earliest time ;IF (num_roots_ht EQ 3) THEN starttimes[0]=d2hdt2[1] ;pick middle time IF (num_roots_ht EQ 1) THEN starttimes[0]=dhdt_roots[0] ;pick v=0 starttime IF (num_roots_ht EQ 3) THEN starttimes[0]=ht_roots[1] ;pick middle time starttimes[1]=-1 RETURN,starttimes ENDIF ELSE BEGIN print,'There are not two roots here, not physically meaningful." RETURN,starttimes=[-1,-1] ENDELSE ENDIF ;} end case 2 END