NAVADMC / ISPStandard

Storage for the configuration files for the Standard Model process using InterSpread +
0 stars 0 forks source link

Dealer locations - Steps to create #3

Open missyschoenbaum opened 10 years ago

missyschoenbaum commented 10 years ago

Make notes here

RobPNth commented 10 years ago

Tim Boyer found a listing of registered dealers. There were 3541. These were assumed to be livestock owners already in the US farm file, from amongst the following farm classes: ['cow_calf_small','feedlot_small','goats','sheep','stockers','swine_enterprise_small','swine_grower_finisher_small','swine_nursery_small','swine_other_small']. There were a total of 1807435 such farms in the file. Therefore, the proportion of these that were dealers was 0.00195913. A python script was written to randomly convert this proportion of the above farm classes to dealers.

Here is the Python code:

import sys, os, string, random

fclassl = ['cow_calf_small','feedlot_small','goats','sheep','stockers','swine_enterprise_small','swine_grower_finisher_small','swine_nursery_small','swine_other_small']

ifile = open("C:\FMD_Modelling\USA\data\us_farm_file4.txt","r") #input file ofile = open("C:\FMD_Modelling\USA\data\us_farm_file5.txt","w") #output file for line in ifile: #each record line = line.strip() id,fclass,cattle,goats,sheep,swine,coords = line.split() if fclass in fclassl: rand = random.random() if rand <= 0.00195913: fclass = "dealer" ofile.write(id+" "+fclass+" "+cattle+" "+goats+" "+sheep+" "+swine+" "+coords+"\n") else: ofile.write(line+"\n") else: ofile.write(line+"\n") ifile.close() ofile.close()

RobPNth commented 10 years ago

I have now uploaded the proc_ffile_dealers.py file. The actual numbers of "dealer" farm class properties in the US farm file is: 3557