;
  examples file for the PFSS model

	; using SolarSoft 
        ;SolarSoft PFSS package

        ;If this is your first time using for_drive, then read
        ;Setup instructions 

	; If this is your first time using the PFSSMOD model with FORWARD, you can read
	;PFSS_README.TXT
	; to learn how to make a a pfss extrapolation to suit your needs. 

	; NOTE FOR CoMP CALCULATIONS MUST USE FULL PATH IN PFSSFILE
	; BECAUSE DIRECTORIES ARE CHANGED DURING COMP ANALYSIS

	; pfssfiles only contain the magnetic field information, not the
	; density or temperature information. The examples below only use the
	; defaults. To put in specific density and temperature information,
	; use the keywords explained in 
	;pfssmodprams.pro

	;
	; KEYWORDS
	;
	; if you want you can use your own PFSSFILE if its already made
	; or make one given a DATE (will grab from web - make sure you have PFSS package
	; on solarsoft)
	; if you have already run the LOS CoMP integration, you can use READMAP
	; 
	; Also can change bscale,pscale to optimize to data
	; remember negative is constant length, positive scales by magnitude of vector
	;
	; CMERID allows you to change the central meridian being shown for
	; the PFSS Carrington map eextrapolation
	; if /date is set then it will be centered on that date
	; otherwise it defaults to zero

default,cmerid,0
default,bscale,0
default,pscale,0

if keyword_set(pfssfile) then print,'make sure you have entered the full path name for pfssfile!'

default,pfssfile,'$FORWARD_DB/Bfield_20051030_120400.sav'

if keyword_set(readmap) then begin
  if readmap eq 1 then readmap = pfssfile+'_fullint'
endif

	;plot field -- plane of sky as vectors and line of sight as contour

for_drive, 'pfssmod', pfssfile=pfssfile, ngrid=128,nwinx=1028,nwiny=1028, line='bx',/verbose,winnum=1,yymin=-1.1,yymax=1.1,xxmin=0,/fieldlines,bscale=bscale

	;do a pos integrated slice of CoMP P/I

for_drive, 'pfssmod', pfssfile=pfssfile, ngrid=128,nwinx=1028,nwiny=1028, line='loi',/comp,/pos,/plotlog,/stklines,xxmin=0,yymin=-1.1,yymax=1.1,/fieldlines,/verbose,winnum=2,bscale=bscale,pscale=pscale


	;make a series of images as the sun spins

nframes=15

FOR i=0,nframes-1 DO $
  for_drive, 'pfssmod', pfssfile=pfssfile, $
  ngrid=128,nwinx=1024,nwiny=1024,/verbose, $
  line='loi',/comp,/pos,/plotlog,$
  cmer=cmerid+i*10,extratitle='cmer='+strtrim(fix(cmerid+i*10),2),$
  imin=-3.5,imax=-0.4,/tif,$
  /stklines,pscale=pscale,/fieldlines,bscale=bscale,narrow=25,/jpeg

	; see note about orientation in 
	;PFSS_README
	; to get your central meridian correct if you want to look at an image
	; that corresponds to a specific day. 
	;do a full integration, save the map if not already there

if keyword_set(readmap) eq 0 then for_drive, 'pfssmod', pfssfile=pfssfile, ngrid=128,nwinx=1028,nwiny=1028, line='loi',/comp,/plotlog,/stklines,xxmin=0,yymin=-1.1,yymax=1.1,pscale=pscale,/fieldlines,bscale=bscale,/verbose,/savemap,mapname=pfssfile+'_fullint',winnum=3 $

else for_drive, 'pfssmod', pfssfile=pfssfile, ngrid=128,nwinx=1028,nwiny=1028, line='loi',/comp,/plotlog,/stklines,xxmin=0,yymin=-1.1,yymax=1.1,pscale=pscale,/fieldlines,bscale=bscale,/verbose,readmap=readmap,winnum=3

;
; Expansion factor and open-closed field weighted density, pb,intensity
;

for_drive,'pfssmod',line='bmag',/topology,winnum=0,xxmin=-3.,xxmax=3.,yymin=-3.,yymax=3.,/fieldlines,bscale=0,/tiff
for_drive,'pfssmod',line='expfac',/topology,winnum=1,xxmin=-3.,xxmax=3.,yymin=-3.,yymax=3.,/fieldlines,bscale=0,/tiff
for_drive,'pfssmod',line='dens',/topology,winnum=2,xxmin=-3.,xxmax=3.,yymin=-3.,yymax=3.,/tiff
for_drive,'pfssmod',/topology,winnum=3,xxmin=-3.,xxmax=3.,yymin=-3.,yymax=3.,/tiff
for_drive,'pfssmod',/aia,/topology,winnum=4,xxmin=-3.,xxmax=3.,yymin=-3.,yymax=3.,/tiff

end
;