;;read original model input file;;n choose i = n!/(n-i)!*i!;;;; for i= 3-> n_images ;;	for j= 1-> (n-choose-i / n) do;;		pick i random files and run model ;;		store output in folder k with metadata & k+=1;;;;	eventually evaluate all output;;function N_choose_m, N, m	top = factorial(N)	bottom = factorial(N-m) * factorial(m)	return, float(top)/bottomendfunction pick_m_of_N, m, N, seed	list = indgen(N)	results = intarr(m)	for i=0, m-1 do begin		index = round(randomu(seed) *(N-1-i));		print, list;		print, index		results(i) = list(index)		if index eq 0 then begin 			list = list(1:n_elements(list)-1)		endif else if index eq n_elements(list)-1 then begin			list = list(0:index-1)		endif else begin			list= [list(0:index-1), list(index+1:n_elements(list)-1)]		endelse	endfor	return, resultsend;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	Parses the input file into a structure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;function readInputFile, inputfile	if not file_test(inputfile) then return, {n_images:-1}	openr, un, /get, inputfile	n_images=0	readf, un, n_images;;Read all of the image file names	filenames=strarr(n_images)		for i=0, n_images-1 do begin		tmp=''		readf, un, tmp		filenames(i) = tmp	endfor	;;Read all of the image dates	dates=intarr(3,n_images)		for i=0, n_images-1 do begin		j=0		tmp=''		readf, un, tmp		tmp=strsplit(tmp, /extract)		if n_elements(tmp) lt 3 then return, {n_images:-2}		for k=0, 2 do begin			reads, tmp(k),j			dates(k,i) = j		endfor	endfor;;read in the remaining file names	sandfile=''	readf, un, sandfile		rangefile=''	readf, un, rangefile		centdir=''	readf, un, centdir		winddir=''	readf, un, winddir		c3c4file=''	readf, un, c3c4file	close, un	free_lun, un;;return the result in a simple structure	return, {n_images:n_images,filenames:filenames, dates:dates, $		sandfile:sandfile, rangefile:rangefile, centdir:centdir,$		winddir:winddir, c3c4file:c3c4file}endpro writeNewInput, info, newFilename	openw, oun, /get, newFilename	printf, oun, info.n_images	for i=0, info.n_images-1 do begin		printf, oun, info.filenames(i)	endfor	printf, oun, info.dates(*,0:info.n_images-1)	printf, oun, info.sandfile	printf, oun, info.rangefile	printf, oun, info.centdir	printf, oun, info.winddir	printf, oun, info.c3c4file	close, oun	free_lun, ounendpro N_Image_Test    totalInfo = readInputFile('ModelInput')  n_images = totalInfo.n_images  seed = 2754  for Cur_N = 7, n_images do begin     sectionResults = strcompress(Cur_N, /remove_all)+'of'+strcompress(n_images, /remove_all);		file_mkdir, sectionResults     n_tries = min([10, round(N_choose_m(n_images, Cur_N) / float(n_images))])     IF (Cur_N EQ n_images-1) OR (Cur_N EQ n_images-2) THEN n_tries=10     print, 'n_tries ', n_tries, cur_N, n_images     for i=0, n_tries-1 do begin        curResults = 'Try-'+strcompress(i,/remove_all);			cd, sectionResults;			file_mkdir, curResults;			up                index = pick_m_of_N(cur_N, n_images, seed)        seed = seed+i                files = totalInfo.filenames(index)        dates = totalInfo.dates(*,index)                print, dates        newInfo = totalInfo        newInfo.dates = dates        newInfo.filenames=files        newInfo.n_images = Cur_N                modelinput = 'tmpModelInput'+strcompress(i+(cur_N*100l), /remove_all)        writeNewInput, newInfo, modelinput                print, files        print, modelinput        print, 'starting model...'                HighPlainsDuneModel, modelinput, /nocent, /daycent, $                              logname=strcompress(i+(cur_N*100l), /remove_all), $                             fullMask='fullMasktmp', windFile='windMap.out';; these can't be used because every year has a SLIGHTLY different shape! should I fix that?;				fullMask='fullMasktmp', $;				windFile='windMap.out', $        spawn, 'rm SandTransport*'        spawn, 'rm resizedSand*'        spawn, 'rm NDVIvsCentMeta*.out'        spawn, 'mv *.ps realnewpsfiles/'        spawn, 'mv NDVI*.out* realnewoutfiles/'        spawn, 'mv OUTPUT* realnewlogfiles/'             endfor  endforend