text
stringlengths
12
1.05M
repo_name
stringlengths
5
86
path
stringlengths
4
191
language
stringclasses
1 value
license
stringclasses
15 values
size
int32
12
1.05M
keyword
listlengths
1
23
text_hash
stringlengths
64
64
#!/usr/bin/env python import os try: __IPYTHON__ import sys del sys.argv[1:] except: pass import srwl_bl import srwlib import srwlpy import math import srwl_uti_smp def set_optics(v=None): el = [] pp = [] names = ['M1', 'M1_Grating', 'Grating', 'GA', 'GA_M3A', 'M3A', 'M3', 'M3_SSA', 'SSA', 'SSA_KBAperture', 'KBAperture', 'KBh', 'KBh_KBv', 'KBv', 'KBv_Sample', 'Sample'] for el_name in names: if el_name == 'M1': # M1: mirror 34.366m mirror_file = v.op_M1_hfn assert os.path.isfile(mirror_file), \ 'Missing input file {}, required by M1 beamline element'.format(mirror_file) el.append(srwlib.srwl_opt_setup_surf_height_1d( srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1), _dim=v.op_M1_dim, _ang=abs(v.op_M1_ang), _amp_coef=v.op_M1_amp_coef, _size_x=v.op_M1_size_x, _size_y=v.op_M1_size_y, )) pp.append(v.op_M1_pp) elif el_name == 'M1_Grating': # M1_Grating: drift 34.366m el.append(srwlib.SRWLOptD( _L=v.op_M1_Grating_L, )) pp.append(v.op_M1_Grating_pp) elif el_name == 'Grating': # Grating: grating 55.0m mirror = srwlib.SRWLOptMirPl( _size_tang=v.op_Grating_size_tang, _size_sag=v.op_Grating_size_sag, _nvx=v.op_Grating_nvx, _nvy=v.op_Grating_nvy, _nvz=v.op_Grating_nvz, _tvx=v.op_Grating_tvx, _tvy=v.op_Grating_tvy, _x=v.op_Grating_x, _y=v.op_Grating_y, ) opEl=srwlib.SRWLOptG( _mirSub=mirror, _m=v.op_Grating_m, _grDen=v.op_Grating_grDen, _grDen1=v.op_Grating_grDen1, _grDen2=v.op_Grating_grDen2, _grDen3=v.op_Grating_grDen3, _grDen4=v.op_Grating_grDen4, _e_avg=v.op_Grating_e_avg, _cff=v.op_Grating_cff, _ang_graz=v.op_Grating_ang, _ang_roll=v.op_Grating_rollAngle, ) el.append(opEl) pp.append(v.op_Grating_pp) elif el_name == 'GA': # GA: aperture 55.0m el.append(srwlib.SRWLOptA( _shape=v.op_GA_shape, _ap_or_ob='a', _Dx=v.op_GA_Dx, _Dy=v.op_GA_Dy, _x=v.op_GA_x, _y=v.op_GA_y, )) pp.append(v.op_GA_pp) elif el_name == 'GA_M3A': # GA_M3A: drift 55.0m el.append(srwlib.SRWLOptD( _L=v.op_GA_M3A_L, )) pp.append(v.op_GA_M3A_pp) elif el_name == 'M3A': # M3A: aperture 89.63m el.append(srwlib.SRWLOptA( _shape=v.op_M3A_shape, _ap_or_ob='a', _Dx=v.op_M3A_Dx, _Dy=v.op_M3A_Dy, _x=v.op_M3A_x, _y=v.op_M3A_y, )) pp.append(v.op_M3A_pp) elif el_name == 'M3': # M3: ellipsoidMirror 89.63m el.append(srwlib.SRWLOptMirEl( _p=v.op_M3_p, _q=v.op_M3_q, _ang_graz=v.op_M3_ang, _size_tang=v.op_M3_size_tang, _size_sag=v.op_M3_size_sag, _nvx=v.op_M3_nvx, _nvy=v.op_M3_nvy, _nvz=v.op_M3_nvz, _tvx=v.op_M3_tvx, _tvy=v.op_M3_tvy, _x=v.op_M3_x, _y=v.op_M3_y, )) pp.append(v.op_M3_pp) elif el_name == 'M3_SSA': # M3_SSA: drift 89.63m el.append(srwlib.SRWLOptD( _L=v.op_M3_SSA_L, )) pp.append(v.op_M3_SSA_pp) elif el_name == 'SSA': # SSA: aperture 97.636m el.append(srwlib.SRWLOptA( _shape=v.op_SSA_shape, _ap_or_ob='a', _Dx=v.op_SSA_Dx, _Dy=v.op_SSA_Dy, _x=v.op_SSA_x, _y=v.op_SSA_y, )) pp.append(v.op_SSA_pp) elif el_name == 'SSA_KBAperture': # SSA_KBAperture: drift 97.636m el.append(srwlib.SRWLOptD( _L=v.op_SSA_KBAperture_L, )) pp.append(v.op_SSA_KBAperture_pp) elif el_name == 'KBAperture': # KBAperture: aperture 103.646m el.append(srwlib.SRWLOptA( _shape=v.op_KBAperture_shape, _ap_or_ob='a', _Dx=v.op_KBAperture_Dx, _Dy=v.op_KBAperture_Dy, _x=v.op_KBAperture_x, _y=v.op_KBAperture_y, )) pp.append(v.op_KBAperture_pp) elif el_name == 'KBh': # KBh: ellipsoidMirror 103.646m el.append(srwlib.SRWLOptMirEl( _p=v.op_KBh_p, _q=v.op_KBh_q, _ang_graz=v.op_KBh_ang, _size_tang=v.op_KBh_size_tang, _size_sag=v.op_KBh_size_sag, _nvx=v.op_KBh_nvx, _nvy=v.op_KBh_nvy, _nvz=v.op_KBh_nvz, _tvx=v.op_KBh_tvx, _tvy=v.op_KBh_tvy, _x=v.op_KBh_x, _y=v.op_KBh_y, )) pp.append(v.op_KBh_pp) elif el_name == 'KBh_KBv': # KBh_KBv: drift 103.646m el.append(srwlib.SRWLOptD( _L=v.op_KBh_KBv_L, )) pp.append(v.op_KBh_KBv_pp) elif el_name == 'KBv': # KBv: ellipsoidMirror 104.146m el.append(srwlib.SRWLOptMirEl( _p=v.op_KBv_p, _q=v.op_KBv_q, _ang_graz=v.op_KBv_ang, _size_tang=v.op_KBv_size_tang, _size_sag=v.op_KBv_size_sag, _nvx=v.op_KBv_nvx, _nvy=v.op_KBv_nvy, _nvz=v.op_KBv_nvz, _tvx=v.op_KBv_tvx, _tvy=v.op_KBv_tvy, _x=v.op_KBv_x, _y=v.op_KBv_y, )) pp.append(v.op_KBv_pp) elif el_name == 'KBv_Sample': # KBv_Sample: drift 104.146m el.append(srwlib.SRWLOptD( _L=v.op_KBv_Sample_L, )) pp.append(v.op_KBv_Sample_pp) elif el_name == 'Sample': # Sample: watch 104.557m pass pp.append(v.op_fin_pp) return srwlib.SRWLOptC(el, pp) varParam = [ ['name', 's', 'NSLS-II ESM beamline', 'simulation name'], #---Data Folder ['fdir', 's', '', 'folder (directory) name for reading-in input and saving output data files'], #---Electron Beam ['ebm_nm', 's', '', 'standard electron beam name'], ['ebm_nms', 's', '', 'standard electron beam name suffix: e.g. can be Day1, Final'], ['ebm_i', 'f', 0.5, 'electron beam current [A]'], ['ebm_e', 'f', 3.0, 'electron beam avarage energy [GeV]'], ['ebm_de', 'f', 0.0, 'electron beam average energy deviation [GeV]'], ['ebm_x', 'f', 0.0, 'electron beam initial average horizontal position [m]'], ['ebm_y', 'f', 0.0, 'electron beam initial average vertical position [m]'], ['ebm_xp', 'f', 0.0, 'electron beam initial average horizontal angle [rad]'], ['ebm_yp', 'f', 0.0, 'electron beam initial average vertical angle [rad]'], ['ebm_z', 'f', 0., 'electron beam initial average longitudinal position [m]'], ['ebm_dr', 'f', -1.8667500000000001, 'electron beam longitudinal drift [m] to be performed before a required calculation'], ['ebm_ens', 'f', 0.00089, 'electron beam relative energy spread'], ['ebm_emx', 'f', 5.500000000000001e-10, 'electron beam horizontal emittance [m]'], ['ebm_emy', 'f', 8e-12, 'electron beam vertical emittance [m]'], # Definition of the beam through Twiss: ['ebm_betax', 'f', 2.02, 'horizontal beta-function [m]'], ['ebm_betay', 'f', 1.06, 'vertical beta-function [m]'], ['ebm_alphax', 'f', 0.0, 'horizontal alpha-function [rad]'], ['ebm_alphay', 'f', 0.0, 'vertical alpha-function [rad]'], ['ebm_etax', 'f', 0.0, 'horizontal dispersion function [m]'], ['ebm_etay', 'f', 0.0, 'vertical dispersion function [m]'], ['ebm_etaxp', 'f', 0.0, 'horizontal dispersion function derivative [rad]'], ['ebm_etayp', 'f', 0.0, 'vertical dispersion function derivative [rad]'], #---Undulator ['und_bx', 'f', 0.0, 'undulator horizontal peak magnetic field [T]'], ['und_by', 'f', 0.187782, 'undulator vertical peak magnetic field [T]'], ['und_phx', 'f', 0.0, 'initial phase of the horizontal magnetic field [rad]'], ['und_phy', 'f', 0.0, 'initial phase of the vertical magnetic field [rad]'], ['und_b2e', '', '', 'estimate undulator fundamental photon energy (in [eV]) for the amplitude of sinusoidal magnetic field defined by und_b or und_bx, und_by', 'store_true'], ['und_e2b', '', '', 'estimate undulator field amplitude (in [T]) for the photon energy defined by w_e', 'store_true'], ['und_per', 'f', 0.057, 'undulator period [m]'], ['und_len', 'f', 3.5055, 'undulator length [m]'], ['und_zc', 'f', 0.0, 'undulator center longitudinal position [m]'], ['und_sx', 'i', 1, 'undulator horizontal magnetic field symmetry vs longitudinal position'], ['und_sy', 'i', 1, 'undulator vertical magnetic field symmetry vs longitudinal position'], ['und_g', 'f', 6.72, 'undulator gap [mm] (assumes availability of magnetic measurement or simulation data)'], ['und_ph', 'f', 0.0, 'shift of magnet arrays [mm] for which the field should be set up'], ['und_mdir', 's', '', 'name of magnetic measurements sub-folder'], ['und_mfs', 's', '', 'name of magnetic measurements for different gaps summary file'], #---Calculation Types # Electron Trajectory ['tr', '', '', 'calculate electron trajectory', 'store_true'], ['tr_cti', 'f', 0.0, 'initial time moment (c*t) for electron trajectory calculation [m]'], ['tr_ctf', 'f', 0.0, 'final time moment (c*t) for electron trajectory calculation [m]'], ['tr_np', 'f', 10000, 'number of points for trajectory calculation'], ['tr_mag', 'i', 1, 'magnetic field to be used for trajectory calculation: 1- approximate, 2- accurate'], ['tr_fn', 's', 'res_trj.dat', 'file name for saving calculated trajectory data'], ['tr_pl', 's', '', 'plot the resulting trajectiry in graph(s): ""- dont plot, otherwise the string should list the trajectory components to plot'], #Single-Electron Spectrum vs Photon Energy ['ss', '', '', 'calculate single-e spectrum vs photon energy', 'store_true'], ['ss_ei', 'f', 100.0, 'initial photon energy [eV] for single-e spectrum vs photon energy calculation'], ['ss_ef', 'f', 20000.0, 'final photon energy [eV] for single-e spectrum vs photon energy calculation'], ['ss_ne', 'i', 10000, 'number of points vs photon energy for single-e spectrum vs photon energy calculation'], ['ss_x', 'f', 0.0, 'horizontal position [m] for single-e spectrum vs photon energy calculation'], ['ss_y', 'f', 0.0, 'vertical position [m] for single-e spectrum vs photon energy calculation'], ['ss_meth', 'i', 1, 'method to use for single-e spectrum vs photon energy calculation: 0- "manual", 1- "auto-undulator", 2- "auto-wiggler"'], ['ss_prec', 'f', 0.01, 'relative precision for single-e spectrum vs photon energy calculation (nominal value is 0.01)'], ['ss_pol', 'i', 6, 'polarization component to extract after spectrum vs photon energy calculation: 0- Linear Horizontal, 1- Linear Vertical, 2- Linear 45 degrees, 3- Linear 135 degrees, 4- Circular Right, 5- Circular Left, 6- Total'], ['ss_mag', 'i', 1, 'magnetic field to be used for single-e spectrum vs photon energy calculation: 1- approximate, 2- accurate'], ['ss_ft', 's', 'f', 'presentation/domain: "f"- frequency (photon energy), "t"- time'], ['ss_u', 'i', 1, 'electric field units: 0- arbitrary, 1- sqrt(Phot/s/0.1%bw/mm^2), 2- sqrt(J/eV/mm^2) or sqrt(W/mm^2), depending on representation (freq. or time)'], ['ss_fn', 's', 'res_spec_se.dat', 'file name for saving calculated single-e spectrum vs photon energy'], ['ss_pl', 's', '', 'plot the resulting single-e spectrum in a graph: ""- dont plot, "e"- show plot vs photon energy'], #Multi-Electron Spectrum vs Photon Energy (taking into account e-beam emittance, energy spread and collection aperture size) ['sm', '', '', 'calculate multi-e spectrum vs photon energy', 'store_true'], ['sm_ei', 'f', 100.0, 'initial photon energy [eV] for multi-e spectrum vs photon energy calculation'], ['sm_ef', 'f', 20000.0, 'final photon energy [eV] for multi-e spectrum vs photon energy calculation'], ['sm_ne', 'i', 10000, 'number of points vs photon energy for multi-e spectrum vs photon energy calculation'], ['sm_x', 'f', 0.0, 'horizontal center position [m] for multi-e spectrum vs photon energy calculation'], ['sm_rx', 'f', 0.001, 'range of horizontal position / horizontal aperture size [m] for multi-e spectrum vs photon energy calculation'], ['sm_nx', 'i', 1, 'number of points vs horizontal position for multi-e spectrum vs photon energy calculation'], ['sm_y', 'f', 0.0, 'vertical center position [m] for multi-e spectrum vs photon energy calculation'], ['sm_ry', 'f', 0.001, 'range of vertical position / vertical aperture size [m] for multi-e spectrum vs photon energy calculation'], ['sm_ny', 'i', 1, 'number of points vs vertical position for multi-e spectrum vs photon energy calculation'], ['sm_mag', 'i', 1, 'magnetic field to be used for calculation of multi-e spectrum spectrum or intensity distribution: 1- approximate, 2- accurate'], ['sm_hi', 'i', 1, 'initial UR spectral harmonic to be taken into account for multi-e spectrum vs photon energy calculation'], ['sm_hf', 'i', 15, 'final UR spectral harmonic to be taken into account for multi-e spectrum vs photon energy calculation'], ['sm_prl', 'f', 1.0, 'longitudinal integration precision parameter for multi-e spectrum vs photon energy calculation'], ['sm_pra', 'f', 1.0, 'azimuthal integration precision parameter for multi-e spectrum vs photon energy calculation'], ['sm_meth', 'i', -1, 'method to use for spectrum vs photon energy calculation in case of arbitrary input magnetic field: 0- "manual", 1- "auto-undulator", 2- "auto-wiggler", -1- dont use this accurate integration method (rather use approximate if possible)'], ['sm_prec', 'f', 0.01, 'relative precision for spectrum vs photon energy calculation in case of arbitrary input magnetic field (nominal value is 0.01)'], ['sm_nm', 'i', 1, 'number of macro-electrons for calculation of spectrum in case of arbitrary input magnetic field'], ['sm_na', 'i', 5, 'number of macro-electrons to average on each node at parallel (MPI-based) calculation of spectrum in case of arbitrary input magnetic field'], ['sm_ns', 'i', 5, 'saving periodicity (in terms of macro-electrons) for intermediate intensity at calculation of multi-electron spectrum in case of arbitrary input magnetic field'], ['sm_type', 'i', 1, 'calculate flux (=1) or flux per unit surface (=2)'], ['sm_pol', 'i', 6, 'polarization component to extract after calculation of multi-e flux or intensity: 0- Linear Horizontal, 1- Linear Vertical, 2- Linear 45 degrees, 3- Linear 135 degrees, 4- Circular Right, 5- Circular Left, 6- Total'], ['sm_rm', 'i', 1, 'method for generation of pseudo-random numbers for e-beam phase-space integration: 1- standard pseudo-random number generator, 2- Halton sequences, 3- LPtau sequences (to be implemented)'], ['sm_fn', 's', 'res_spec_me.dat', 'file name for saving calculated milti-e spectrum vs photon energy'], ['sm_pl', 's', '', 'plot the resulting spectrum-e spectrum in a graph: ""- dont plot, "e"- show plot vs photon energy'], #to add options for the multi-e calculation from "accurate" magnetic field #Power Density Distribution vs horizontal and vertical position ['pw', '', '', 'calculate SR power density distribution', 'store_true'], ['pw_x', 'f', 0.0, 'central horizontal position [m] for calculation of power density distribution vs horizontal and vertical position'], ['pw_rx', 'f', 0.015, 'range of horizontal position [m] for calculation of power density distribution vs horizontal and vertical position'], ['pw_nx', 'i', 100, 'number of points vs horizontal position for calculation of power density distribution'], ['pw_y', 'f', 0.0, 'central vertical position [m] for calculation of power density distribution vs horizontal and vertical position'], ['pw_ry', 'f', 0.015, 'range of vertical position [m] for calculation of power density distribution vs horizontal and vertical position'], ['pw_ny', 'i', 100, 'number of points vs vertical position for calculation of power density distribution'], ['pw_pr', 'f', 1.0, 'precision factor for calculation of power density distribution'], ['pw_meth', 'i', 1, 'power density computation method (1- "near field", 2- "far field")'], ['pw_zst', 'f', 0., 'initial longitudinal position along electron trajectory of power density distribution (effective if pow_sst < pow_sfi)'], ['pw_zfi', 'f', 0., 'final longitudinal position along electron trajectory of power density distribution (effective if pow_sst < pow_sfi)'], ['pw_mag', 'i', 1, 'magnetic field to be used for power density calculation: 1- approximate, 2- accurate'], ['pw_fn', 's', 'res_pow.dat', 'file name for saving calculated power density distribution'], ['pw_pl', 's', '', 'plot the resulting power density distribution in a graph: ""- dont plot, "x"- vs horizontal position, "y"- vs vertical position, "xy"- vs horizontal and vertical position'], #Single-Electron Intensity distribution vs horizontal and vertical position ['si', '', '', 'calculate single-e intensity distribution (without wavefront propagation through a beamline) vs horizontal and vertical position', 'store_true'], #Single-Electron Wavefront Propagation ['ws', '', '', 'calculate single-electron (/ fully coherent) wavefront propagation', 'store_true'], #Multi-Electron (partially-coherent) Wavefront Propagation ['wm', '', '', 'calculate multi-electron (/ partially coherent) wavefront propagation', 'store_true'], ['w_e', 'f', 1000.0, 'photon energy [eV] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ef', 'f', -1.0, 'final photon energy [eV] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ne', 'i', 1, 'number of points vs photon energy for calculation of intensity distribution'], ['w_x', 'f', 0.0, 'central horizontal position [m] for calculation of intensity distribution'], ['w_rx', 'f', 0.002, 'range of horizontal position [m] for calculation of intensity distribution'], ['w_nx', 'i', 100, 'number of points vs horizontal position for calculation of intensity distribution'], ['w_y', 'f', 0.0, 'central vertical position [m] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ry', 'f', 0.002, 'range of vertical position [m] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ny', 'i', 100, 'number of points vs vertical position for calculation of intensity distribution'], ['w_smpf', 'f', 1.0, 'sampling factor for calculation of intensity distribution vs horizontal and vertical position'], ['w_meth', 'i', 1, 'method to use for calculation of intensity distribution vs horizontal and vertical position: 0- "manual", 1- "auto-undulator", 2- "auto-wiggler"'], ['w_prec', 'f', 0.01, 'relative precision for calculation of intensity distribution vs horizontal and vertical position'], ['w_u', 'i', 1, 'electric field units: 0- arbitrary, 1- sqrt(Phot/s/0.1%bw/mm^2), 2- sqrt(J/eV/mm^2) or sqrt(W/mm^2), depending on representation (freq. or time)'], ['si_pol', 'i', 6, 'polarization component to extract after calculation of intensity distribution: 0- Linear Horizontal, 1- Linear Vertical, 2- Linear 45 degrees, 3- Linear 135 degrees, 4- Circular Right, 5- Circular Left, 6- Total'], ['si_type', 'i', 0, 'type of a characteristic to be extracted after calculation of intensity distribution: 0- Single-Electron Intensity, 1- Multi-Electron Intensity, 2- Single-Electron Flux, 3- Multi-Electron Flux, 4- Single-Electron Radiation Phase, 5- Re(E): Real part of Single-Electron Electric Field, 6- Im(E): Imaginary part of Single-Electron Electric Field, 7- Single-Electron Intensity, integrated over Time or Photon Energy'], ['w_mag', 'i', 1, 'magnetic field to be used for calculation of intensity distribution vs horizontal and vertical position: 1- approximate, 2- accurate'], ['si_fn', 's', 'res_int_se.dat', 'file name for saving calculated single-e intensity distribution (without wavefront propagation through a beamline) vs horizontal and vertical position'], ['si_pl', 's', '', 'plot the input intensity distributions in graph(s): ""- dont plot, "x"- vs horizontal position, "y"- vs vertical position, "xy"- vs horizontal and vertical position'], ['ws_fni', 's', 'res_int_pr_se.dat', 'file name for saving propagated single-e intensity distribution vs horizontal and vertical position'], ['ws_pl', 's', '', 'plot the resulting intensity distributions in graph(s): ""- dont plot, "x"- vs horizontal position, "y"- vs vertical position, "xy"- vs horizontal and vertical position'], ['wm_nm', 'i', 1000, 'number of macro-electrons (coherent wavefronts) for calculation of multi-electron wavefront propagation'], ['wm_na', 'i', 5, 'number of macro-electrons (coherent wavefronts) to average on each node for parallel (MPI-based) calculation of multi-electron wavefront propagation'], ['wm_ns', 'i', 5, 'saving periodicity (in terms of macro-electrons / coherent wavefronts) for intermediate intensity at multi-electron wavefront propagation calculation'], ['wm_ch', 'i', 0, 'type of a characteristic to be extracted after calculation of multi-electron wavefront propagation: #0- intensity (s0); 1- four Stokes components; 2- mutual intensity cut vs x; 3- mutual intensity cut vs y; 40- intensity(s0), mutual intensity cuts and degree of coherence vs X & Y'], ['wm_ap', 'i', 0, 'switch specifying representation of the resulting Stokes parameters: coordinate (0) or angular (1)'], ['wm_x0', 'f', 0.0, 'horizontal center position for mutual intensity cut calculation'], ['wm_y0', 'f', 0.0, 'vertical center position for mutual intensity cut calculation'], ['wm_ei', 'i', 0, 'integration over photon energy is required (1) or not (0); if the integration is required, the limits are taken from w_e, w_ef'], ['wm_rm', 'i', 1, 'method for generation of pseudo-random numbers for e-beam phase-space integration: 1- standard pseudo-random number generator, 2- Halton sequences, 3- LPtau sequences (to be implemented)'], ['wm_am', 'i', 0, 'multi-electron integration approximation method: 0- no approximation (use the standard 5D integration method), 1- integrate numerically only over e-beam energy spread and use convolution to treat transverse emittance'], ['wm_fni', 's', 'res_int_pr_me.dat', 'file name for saving propagated multi-e intensity distribution vs horizontal and vertical position'], ['wm_fbk', '', '', 'create backup file(s) with propagated multi-e intensity distribution vs horizontal and vertical position and other radiation characteristics', 'store_true'], #to add options ['op_r', 'f', 20.0, 'longitudinal position of the first optical element [m]'], # Former appParam: ['rs_type', 's', 'u', 'source type, (u) idealized undulator, (t), tabulated undulator, (m) multipole, (g) gaussian beam'], #---Beamline optics: # M1: mirror ['op_M1_hfn', 's', 'mirror_1d.dat', 'heightProfileFile'], ['op_M1_dim', 's', 'x', 'orientation'], ['op_M1_ang', 'f', 0.043633200000000004, 'grazingAngle'], ['op_M1_amp_coef', 'f', 1.0, 'heightAmplification'], ['op_M1_size_x', 'f', 0.001, 'horizontalTransverseSize'], ['op_M1_size_y', 'f', 0.001, 'verticalTransverseSize'], # M1_Grating: drift ['op_M1_Grating_L', 'f', 20.634, 'length'], # Grating: grating ['op_Grating_hfn', 's', '', 'heightProfileFile'], ['op_Grating_dim', 's', 'y', 'orientation'], ['op_Grating_size_tang', 'f', 0.2, 'tangentialSize'], ['op_Grating_size_sag', 'f', 0.015, 'sagittalSize'], ['op_Grating_nvx', 'f', 0.0, 'nvx'], ['op_Grating_nvy', 'f', 0.9999160776602402, 'nvy'], ['op_Grating_nvz', 'f', -0.012955216577139016, 'nvz'], ['op_Grating_tvx', 'f', 0.0, 'tvx'], ['op_Grating_tvy', 'f', 0.012955216577139016, 'tvy'], ['op_Grating_x', 'f', 0.0, 'horizontalOffset'], ['op_Grating_y', 'f', 0.0, 'verticalOffset'], ['op_Grating_m', 'f', 1.0, 'diffractionOrder'], ['op_Grating_grDen', 'f', 1800.0, 'grooveDensity0'], ['op_Grating_grDen1', 'f', 0.08997, 'grooveDensity1'], ['op_Grating_grDen2', 'f', 3.004e-06, 'grooveDensity2'], ['op_Grating_grDen3', 'f', 9.73e-11, 'grooveDensity3'], ['op_Grating_grDen4', 'f', 0.0, 'grooveDensity4'], ['op_Grating_e_avg', 'f', 1000.0, 'energyAvg'], ['op_Grating_cff', 'f', 5.249936863206202, 'cff'], ['op_Grating_ang', 'f', 0.012955579, 'grazingAngle'], ['op_Grating_rollAngle', 'f', 0.0, 'rollAngle'], ['op_Grating_outoptvx', 'f', 0.0, 'outoptvx'], ['op_Grating_outoptvy', 'f', 0.08093357816613847, 'outoptvy'], ['op_Grating_outoptvz', 'f', 0.996719497113017, 'outoptvz'], ['op_Grating_outframevx', 'f', 1.0, 'outframevx'], ['op_Grating_outframevy', 'f', 0.0, 'outframevy'], ['op_Grating_computeParametersFrom', 'f', 2, 'computeParametersFrom'], ['op_Grating_amp_coef', 'f', 0.001, 'heightAmplification'], # GA: aperture ['op_GA_shape', 's', 'r', 'shape'], ['op_GA_Dx', 'f', 0.015, 'horizontalSize'], ['op_GA_Dy', 'f', 0.0025910433154276145, 'verticalSize'], ['op_GA_x', 'f', 0.0, 'horizontalOffset'], ['op_GA_y', 'f', 0.0, 'verticalOffset'], # GA_M3A: drift ['op_GA_M3A_L', 'f', 34.629999999999995, 'length'], # M3A: aperture ['op_M3A_shape', 's', 'r', 'shape'], ['op_M3A_Dx', 'f', 0.018320129560012673, 'horizontalSize'], ['op_M3A_Dy', 'f', 0.02, 'verticalSize'], ['op_M3A_x', 'f', 0.0, 'horizontalOffset'], ['op_M3A_y', 'f', 0.0, 'verticalOffset'], # M3: ellipsoidMirror ['op_M3_hfn', 's', 'None', 'heightProfileFile'], ['op_M3_dim', 's', 'x', 'orientation'], ['op_M3_p', 'f', 89.63, 'firstFocusLength'], ['op_M3_q', 'f', 8.006, 'focalLength'], ['op_M3_ang', 'f', 0.043633200000000004, 'grazingAngle'], ['op_M3_amp_coef', 'f', 1.0, 'heightAmplification'], ['op_M3_size_tang', 'f', 0.42, 'tangentialSize'], ['op_M3_size_sag', 'f', 0.02, 'sagittalSize'], ['op_M3_nvx', 'f', 0.9990482229471379, 'normalVectorX'], ['op_M3_nvy', 'f', 0.0, 'normalVectorY'], ['op_M3_nvz', 'f', -0.04361935609526827, 'normalVectorZ'], ['op_M3_tvx', 'f', -0.04361935609526827, 'tangentialVectorX'], ['op_M3_tvy', 'f', 0.0, 'tangentialVectorY'], ['op_M3_x', 'f', 0.0, 'horizontalOffset'], ['op_M3_y', 'f', 0.0, 'verticalOffset'], # M3_SSA: drift ['op_M3_SSA_L', 'f', 8.006, 'length'], # SSA: aperture ['op_SSA_shape', 's', 'r', 'shape'], ['op_SSA_Dx', 'f', 0.0015, 'horizontalSize'], ['op_SSA_Dy', 'f', 0.0015, 'verticalSize'], ['op_SSA_x', 'f', 0.0, 'horizontalOffset'], ['op_SSA_y', 'f', 0.0, 'verticalOffset'], # SSA_KBAperture: drift ['op_SSA_KBAperture_L', 'f', 6.010000000000005, 'length'], # KBAperture: aperture ['op_KBAperture_shape', 's', 'r', 'shape'], ['op_KBAperture_Dx', 'f', 0.01308580682858048, 'horizontalSize'], ['op_KBAperture_Dy', 'f', 0.003, 'verticalSize'], ['op_KBAperture_x', 'f', 0.0, 'horizontalOffset'], ['op_KBAperture_y', 'f', 0.0, 'verticalOffset'], # KBh: ellipsoidMirror ['op_KBh_hfn', 's', 'None', 'heightProfileFile'], ['op_KBh_dim', 's', 'x', 'orientation'], ['op_KBh_p', 'f', 6.01, 'firstFocusLength'], ['op_KBh_q', 'f', 0.911, 'focalLength'], ['op_KBh_ang', 'f', 0.0872665, 'grazingAngle'], ['op_KBh_amp_coef', 'f', 1.0, 'heightAmplification'], ['op_KBh_size_tang', 'f', 0.3, 'tangentialSize'], ['op_KBh_size_sag', 'f', 0.05, 'sagittalSize'], ['op_KBh_nvx', 'f', 0.9961946948320953, 'normalVectorX'], ['op_KBh_nvy', 'f', 0.0, 'normalVectorY'], ['op_KBh_nvz', 'f', -0.08715578000562225, 'normalVectorZ'], ['op_KBh_tvx', 'f', -0.08715578000562225, 'tangentialVectorX'], ['op_KBh_tvy', 'f', 0.0, 'tangentialVectorY'], ['op_KBh_x', 'f', 0.0, 'horizontalOffset'], ['op_KBh_y', 'f', 0.0, 'verticalOffset'], # KBh_KBv: drift ['op_KBh_KBv_L', 'f', 0.5, 'length'], # KBv: ellipsoidMirror ['op_KBv_hfn', 's', 'None', 'heightProfileFile'], ['op_KBv_dim', 's', 'x', 'orientation'], ['op_KBv_p', 'f', 6.51, 'firstFocusLength'], ['op_KBv_q', 'f', 0.411, 'focalLength'], ['op_KBv_ang', 'f', 0.0872665, 'grazingAngle'], ['op_KBv_amp_coef', 'f', 1.0, 'heightAmplification'], ['op_KBv_size_tang', 'f', 0.3, 'tangentialSize'], ['op_KBv_size_sag', 'f', 0.05, 'sagittalSize'], ['op_KBv_nvx', 'f', 0.0, 'normalVectorX'], ['op_KBv_nvy', 'f', 0.9961946948320953, 'normalVectorY'], ['op_KBv_nvz', 'f', -0.08715578000562225, 'normalVectorZ'], ['op_KBv_tvx', 'f', 0.0, 'tangentialVectorX'], ['op_KBv_tvy', 'f', -0.08715578000562225, 'tangentialVectorY'], ['op_KBv_x', 'f', 0.0, 'horizontalOffset'], ['op_KBv_y', 'f', 0.0, 'verticalOffset'], # KBv_Sample: drift ['op_KBv_Sample_L', 'f', 0.41100000000000136, 'length'], #---Propagation parameters ['op_M1_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'M1'], ['op_M1_Grating_pp', 'f', [0, 0, 1.0, 1, 0, 1.2, 3.5, 1.2, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'M1_Grating'], ['op_Grating_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'Grating'], ['op_GA_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'GA'], ['op_GA_M3A_pp', 'f', [0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'GA_M3A'], ['op_M3A_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'M3A'], ['op_M3_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'M3'], ['op_M3_SSA_pp', 'f', [0, 0, 1.0, 1, 0, 3.0, 1.0, 3.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'M3_SSA'], ['op_SSA_pp', 'f', [0, 0, 1.0, 0, 0, 0.4, 1.0, 0.4, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'SSA'], ['op_SSA_KBAperture_pp', 'f', [0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'SSA_KBAperture'], ['op_KBAperture_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'KBAperture'], ['op_KBh_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'KBh'], ['op_KBh_KBv_pp', 'f', [0, 0, 1.0, 1, 0, 2.0, 1.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'KBh_KBv'], ['op_KBv_pp', 'f', [0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'KBv'], ['op_KBv_Sample_pp', 'f', [0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'KBv_Sample'], ['op_fin_pp', 'f', [0, 0, 1.0, 0, 1, 0.07, 1.5, 0.07, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'final post-propagation (resize) parameters'], #[ 0]: Auto-Resize (1) or not (0) Before propagation #[ 1]: Auto-Resize (1) or not (0) After propagation #[ 2]: Relative Precision for propagation with Auto-Resizing (1. is nominal) #[ 3]: Allow (1) or not (0) for semi-analytical treatment of the quadratic (leading) phase terms at the propagation #[ 4]: Do any Resizing on Fourier side, using FFT, (1) or not (0) #[ 5]: Horizontal Range modification factor at Resizing (1. means no modification) #[ 6]: Horizontal Resolution modification factor at Resizing #[ 7]: Vertical Range modification factor at Resizing #[ 8]: Vertical Resolution modification factor at Resizing #[ 9]: Type of wavefront Shift before Resizing (not yet implemented) #[10]: New Horizontal wavefront Center position after Shift (not yet implemented) #[11]: New Vertical wavefront Center position after Shift (not yet implemented) #[12]: Optional: Orientation of the Output Optical Axis vector in the Incident Beam Frame: Horizontal Coordinate #[13]: Optional: Orientation of the Output Optical Axis vector in the Incident Beam Frame: Vertical Coordinate #[14]: Optional: Orientation of the Output Optical Axis vector in the Incident Beam Frame: Longitudinal Coordinate #[15]: Optional: Orientation of the Horizontal Base vector of the Output Frame in the Incident Beam Frame: Horizontal Coordinate #[16]: Optional: Orientation of the Horizontal Base vector of the Output Frame in the Incident Beam Frame: Vertical Coordinate ] def main(): v = srwl_bl.srwl_uti_parse_options(srwl_bl.srwl_uti_ext_options(varParam), use_sys_argv=True) op = set_optics(v) v.ss = True v.ss_pl = 'e' v.sm = True v.sm_pl = 'e' v.pw = True v.pw_pl = 'xy' v.si = True v.si_pl = 'xy' v.tr = True v.tr_pl = 'xz' v.ws = True v.ws_pl = 'xy' mag = None if v.rs_type == 'm': mag = srwlib.SRWLMagFldC() mag.arXc.append(0) mag.arYc.append(0) mag.arMagFld.append(srwlib.SRWLMagFldM(v.mp_field, v.mp_order, v.mp_distribution, v.mp_len)) mag.arZc.append(v.mp_zc) srwl_bl.SRWLBeamline(_name=v.name, _mag_approx=mag).calc_all(v, op) main()
mkeilman/sirepo
tests/template/srw_generate_data/nsls-ii-esm-beamline.py
Python
apache-2.0
34,340
[ "Gaussian" ]
190e5af7d9ff833b84526c66f1a2bc09565eb41617c2a74f1532ba27f87ab851
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Live variable analysis. This analysis attaches a set containing the live symbols that are live at the exit of control flow statements. Requires activity analysis. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import gast from tensorflow.python.autograph.pyct import anno from tensorflow.python.autograph.pyct import cfg from tensorflow.python.autograph.pyct import transformer from tensorflow.python.autograph.pyct.static_analysis import annos class Analyzer(cfg.GraphVisitor): """CFG visitor that performs liveness analysis at statement level.""" def __init__(self, graph): super(Analyzer, self).__init__(graph) # This allows communicating that nodes generate extra symbols, # e.g. those that a function definition closes over. self.extra_gen = {} def init_state(self, _): return set() def visit_node(self, node): prev_live_in = self.in_[node] if anno.hasanno(node.ast_node, anno.Static.SCOPE): node_scope = anno.getanno(node.ast_node, anno.Static.SCOPE) gen = node_scope.used | self.extra_gen.get(node.ast_node, frozenset()) # TODO(mdan): verify whether composites' parents need to be added. # E.g. if x.y is live whether x needs to be added. Theoretically the # activity analysis should have both so that wouldn't be needed. kill = node_scope.modified live_out = set() for n in node.next: live_out |= self.in_[n] live_in = gen | (live_out - kill) else: # Nodes that don't have a scope annotation are assumed not to touch any # symbols. # This Name node below is a literal name, e.g. False assert isinstance(node.ast_node, (gast.Name, gast.Continue, gast.Break)), type( node.ast_node) live_in = prev_live_in live_out = live_in self.in_[node] = live_in self.out[node] = live_out # TODO(mdan): Move this to the superclass? return prev_live_in != live_in class WholeTreeAnalyzer(transformer.Base): """Runs liveness analysis on each of the functions defined in the AST. If a function defined other local functions, those will have separate CFGs. However, dataflow analysis needs to tie up these CFGs to properly emulate the effect of closures. In the case of liveness, the parent function's live variables must account for the variables that are live at the entry of each subfunction. For example: def foo(): # baz is live here def bar(): print(baz) This analyzer runs liveness analysis on each individual function, accounting for the effect above. """ def __init__(self, source_info, graphs): super(WholeTreeAnalyzer, self).__init__(source_info) self.graphs = graphs self.current_analyzer = None self.analyzers = {} def visit_FunctionDef(self, node): parent_analyzer = self.current_analyzer subgraph = self.graphs[node] # Postorder tree processing makes this a bit complicated: # 1. construct an analyzer object and put it on stack # 2. recursively walk the subtree; this will initialize the analyzer's # in_ state properly (done in a block below) # 3. run the final analysis analyzer = Analyzer(subgraph) self.current_analyzer = analyzer node = self.generic_visit(node) analyzer.visit_reverse() if parent_analyzer is not None: # Wire the state between the two subgraphs' analyzers. child_in_state = analyzer.in_[subgraph.entry] # Exception: symbols modified in the child function are local to it body_scope = anno.getanno(node, annos.NodeAnno.BODY_SCOPE) for qn in body_scope.modified: # Note: a function modifying the symbol doesn't make that symbol # live at the function's entry. In fact when that happens it is # probably a case of undefined assignment, like this: # # bar = 0 # def foo(): # print(bar) # bar is undefined here! # bar = 1 # # Hence we use discard and not remove below. child_in_state.discard(qn) parent_analyzer.extra_gen[node] = frozenset(child_in_state,) self.analyzers[node] = analyzer self.current_analyzer = parent_analyzer return node def visit_nonlocal(self, node): raise NotImplementedError() def visit_global(self, node): raise NotImplementedError() class Annotator(transformer.Base): """AST visitor that annotates each control flow block with live symbols.""" # Note: additional nodes may be added as needed. def __init__(self, source_info, cross_function_analyzer): super(Annotator, self).__init__(source_info) self.cross_function_analyzer = cross_function_analyzer self.current_analyzer = None def visit_FunctionDef(self, node): parent_analyzer = self.current_analyzer self.current_analyzer = self.cross_function_analyzer.analyzers[node] node = self.generic_visit(node) self.current_analyzer = parent_analyzer return node def _aggregate_successors_live_in(self, node): successors = self.current_analyzer.graph.stmt_next[node] node_live_out = set() for s in successors: node_live_out.update(self.current_analyzer.in_[s]) anno.setanno(node, anno.Static.LIVE_VARS_OUT, frozenset(node_live_out)) node = self.generic_visit(node) return node def visit_If(self, node): return self._aggregate_successors_live_in(node) def visit_For(self, node): return self._aggregate_successors_live_in(node) def visit_While(self, node): return self._aggregate_successors_live_in(node) def resolve(node, source_info, graphs): """Resolves the live symbols at the exit of control flow statements. Args: node: ast.AST source_info: transformer.SourceInfo graphs: Dict[ast.FunctionDef, cfg.Graph] Returns: ast.AST """ cross_function_analyzer = WholeTreeAnalyzer(source_info, graphs) node = cross_function_analyzer.visit(node) visitor = Annotator(source_info, cross_function_analyzer) node = visitor.visit(node) return node
kobejean/tensorflow
tensorflow/python/autograph/pyct/static_analysis/liveness.py
Python
apache-2.0
6,834
[ "VisIt" ]
819784f7da68d2d0ee7232831e52004de243c6ccb9fd020997f13edb898b7a0c
"""Implementation of the WebSocket protocol. `WebSockets <http://dev.w3.org/html5/websockets/>`_ allow for bidirectional communication between the browser and server. WebSockets are supported in the current versions of all major browsers, although older versions that do not support WebSockets are still in use (refer to http://caniuse.com/websockets for details). This module implements the final version of the WebSocket protocol as defined in `RFC 6455 <http://tools.ietf.org/html/rfc6455>`_. Certain browser versions (notably Safari 5.x) implemented an earlier draft of the protocol (known as "draft 76") and are not compatible with this module. .. versionchanged:: 4.0 Removed support for the draft 76 protocol version. """ import abc import asyncio import base64 import hashlib import os import sys import struct import tornado.escape import tornado.web from urllib.parse import urlparse import zlib from tornado.concurrent import Future, future_set_result_unless_cancelled from tornado.escape import utf8, native_str, to_unicode from tornado import gen, httpclient, httputil from tornado.ioloop import IOLoop, PeriodicCallback from tornado.iostream import StreamClosedError, IOStream from tornado.log import gen_log, app_log from tornado import simple_httpclient from tornado.queues import Queue from tornado.tcpclient import TCPClient from tornado.util import _websocket_mask from typing import ( TYPE_CHECKING, cast, Any, Optional, Dict, Union, List, Awaitable, Callable, Tuple, Type, ) from types import TracebackType if TYPE_CHECKING: from typing_extensions import Protocol # The zlib compressor types aren't actually exposed anywhere # publicly, so declare protocols for the portions we use. class _Compressor(Protocol): def compress(self, data: bytes) -> bytes: pass def flush(self, mode: int) -> bytes: pass class _Decompressor(Protocol): unconsumed_tail = b"" # type: bytes def decompress(self, data: bytes, max_length: int) -> bytes: pass class _WebSocketDelegate(Protocol): # The common base interface implemented by WebSocketHandler on # the server side and WebSocketClientConnection on the client # side. def on_ws_connection_close( self, close_code: Optional[int] = None, close_reason: Optional[str] = None ) -> None: pass def on_message(self, message: Union[str, bytes]) -> Optional["Awaitable[None]"]: pass def on_ping(self, data: bytes) -> None: pass def on_pong(self, data: bytes) -> None: pass def log_exception( self, typ: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType], ) -> None: pass _default_max_message_size = 10 * 1024 * 1024 class WebSocketError(Exception): pass class WebSocketClosedError(WebSocketError): """Raised by operations on a closed connection. .. versionadded:: 3.2 """ pass class _DecompressTooLargeError(Exception): pass class _WebSocketParams(object): def __init__( self, ping_interval: Optional[float] = None, ping_timeout: Optional[float] = None, max_message_size: int = _default_max_message_size, compression_options: Optional[Dict[str, Any]] = None, ) -> None: self.ping_interval = ping_interval self.ping_timeout = ping_timeout self.max_message_size = max_message_size self.compression_options = compression_options class WebSocketHandler(tornado.web.RequestHandler): """Subclass this class to create a basic WebSocket handler. Override `on_message` to handle incoming messages, and use `write_message` to send messages to the client. You can also override `open` and `on_close` to handle opened and closed connections. Custom upgrade response headers can be sent by overriding `~tornado.web.RequestHandler.set_default_headers` or `~tornado.web.RequestHandler.prepare`. See http://dev.w3.org/html5/websockets/ for details on the JavaScript interface. The protocol is specified at http://tools.ietf.org/html/rfc6455. Here is an example WebSocket handler that echos back all received messages back to the client: .. testcode:: class EchoWebSocket(tornado.websocket.WebSocketHandler): def open(self): print("WebSocket opened") def on_message(self, message): self.write_message(u"You said: " + message) def on_close(self): print("WebSocket closed") .. testoutput:: :hide: WebSockets are not standard HTTP connections. The "handshake" is HTTP, but after the handshake, the protocol is message-based. Consequently, most of the Tornado HTTP facilities are not available in handlers of this type. The only communication methods available to you are `write_message()`, `ping()`, and `close()`. Likewise, your request handler class should implement `open()` method rather than ``get()`` or ``post()``. If you map the handler above to ``/websocket`` in your application, you can invoke it in JavaScript with:: var ws = new WebSocket("ws://localhost:8888/websocket"); ws.onopen = function() { ws.send("Hello, world"); }; ws.onmessage = function (evt) { alert(evt.data); }; This script pops up an alert box that says "You said: Hello, world". Web browsers allow any site to open a websocket connection to any other, instead of using the same-origin policy that governs other network access from JavaScript. This can be surprising and is a potential security hole, so since Tornado 4.0 `WebSocketHandler` requires applications that wish to receive cross-origin websockets to opt in by overriding the `~WebSocketHandler.check_origin` method (see that method's docs for details). Failure to do so is the most likely cause of 403 errors when making a websocket connection. When using a secure websocket connection (``wss://``) with a self-signed certificate, the connection from a browser may fail because it wants to show the "accept this certificate" dialog but has nowhere to show it. You must first visit a regular HTML page using the same certificate to accept it before the websocket connection will succeed. If the application setting ``websocket_ping_interval`` has a non-zero value, a ping will be sent periodically, and the connection will be closed if a response is not received before the ``websocket_ping_timeout``. Messages larger than the ``websocket_max_message_size`` application setting (default 10MiB) will not be accepted. .. versionchanged:: 4.5 Added ``websocket_ping_interval``, ``websocket_ping_timeout``, and ``websocket_max_message_size``. """ def __init__( self, application: tornado.web.Application, request: httputil.HTTPServerRequest, **kwargs: Any ) -> None: super(WebSocketHandler, self).__init__(application, request, **kwargs) self.ws_connection = None # type: Optional[WebSocketProtocol] self.close_code = None # type: Optional[int] self.close_reason = None # type: Optional[str] self.stream = None # type: Optional[IOStream] self._on_close_called = False async def get(self, *args: Any, **kwargs: Any) -> None: self.open_args = args self.open_kwargs = kwargs # Upgrade header should be present and should be equal to WebSocket if self.request.headers.get("Upgrade", "").lower() != "websocket": self.set_status(400) log_msg = 'Can "Upgrade" only to "WebSocket".' self.finish(log_msg) gen_log.debug(log_msg) return # Connection header should be upgrade. # Some proxy servers/load balancers # might mess with it. headers = self.request.headers connection = map( lambda s: s.strip().lower(), headers.get("Connection", "").split(",") ) if "upgrade" not in connection: self.set_status(400) log_msg = '"Connection" must be "Upgrade".' self.finish(log_msg) gen_log.debug(log_msg) return # Handle WebSocket Origin naming convention differences # The difference between version 8 and 13 is that in 8 the # client sends a "Sec-Websocket-Origin" header and in 13 it's # simply "Origin". if "Origin" in self.request.headers: origin = self.request.headers.get("Origin") else: origin = self.request.headers.get("Sec-Websocket-Origin", None) # If there was an origin header, check to make sure it matches # according to check_origin. When the origin is None, we assume it # did not come from a browser and that it can be passed on. if origin is not None and not self.check_origin(origin): self.set_status(403) log_msg = "Cross origin websockets not allowed" self.finish(log_msg) gen_log.debug(log_msg) return self.ws_connection = self.get_websocket_protocol() if self.ws_connection: await self.ws_connection.accept_connection(self) else: self.set_status(426, "Upgrade Required") self.set_header("Sec-WebSocket-Version", "7, 8, 13") @property def ping_interval(self) -> Optional[float]: """The interval for websocket keep-alive pings. Set websocket_ping_interval = 0 to disable pings. """ return self.settings.get("websocket_ping_interval", None) @property def ping_timeout(self) -> Optional[float]: """If no ping is received in this many seconds, close the websocket connection (VPNs, etc. can fail to cleanly close ws connections). Default is max of 3 pings or 30 seconds. """ return self.settings.get("websocket_ping_timeout", None) @property def max_message_size(self) -> int: """Maximum allowed message size. If the remote peer sends a message larger than this, the connection will be closed. Default is 10MiB. """ return self.settings.get( "websocket_max_message_size", _default_max_message_size ) def write_message( self, message: Union[bytes, str, Dict[str, Any]], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket. The message may be either a string or a dict (which will be encoded as json). If the ``binary`` argument is false, the message will be sent as utf8; in binary mode any byte string is allowed. If the connection is already closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 3.2 `WebSocketClosedError` was added (previously a closed connection would raise an `AttributeError`) .. versionchanged:: 4.3 Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0 Consistently raises `WebSocketClosedError`. Previously could sometimes raise `.StreamClosedError`. """ if self.ws_connection is None or self.ws_connection.is_closing(): raise WebSocketClosedError() if isinstance(message, dict): message = tornado.escape.json_encode(message) return self.ws_connection.write_message(message, binary=binary) def select_subprotocol(self, subprotocols: List[str]) -> Optional[str]: """Override to implement subprotocol negotiation. ``subprotocols`` is a list of strings identifying the subprotocols proposed by the client. This method may be overridden to return one of those strings to select it, or ``None`` to not select a subprotocol. Failure to select a subprotocol does not automatically abort the connection, although clients may close the connection if none of their proposed subprotocols was selected. The list may be empty, in which case this method must return None. This method is always called exactly once even if no subprotocols were proposed so that the handler can be advised of this fact. .. versionchanged:: 5.1 Previously, this method was called with a list containing an empty string instead of an empty list if no subprotocols were proposed by the client. """ return None @property def selected_subprotocol(self) -> Optional[str]: """The subprotocol returned by `select_subprotocol`. .. versionadded:: 5.1 """ assert self.ws_connection is not None return self.ws_connection.selected_subprotocol def get_compression_options(self) -> Optional[Dict[str, Any]]: """Override to return compression options for the connection. If this method returns None (the default), compression will be disabled. If it returns a dict (even an empty one), it will be enabled. The contents of the dict may be used to control the following compression options: ``compression_level`` specifies the compression level. ``mem_level`` specifies the amount of memory used for the internal compression state. These parameters are documented in details here: https://docs.python.org/3.6/library/zlib.html#zlib.compressobj .. versionadded:: 4.1 .. versionchanged:: 4.5 Added ``compression_level`` and ``mem_level``. """ # TODO: Add wbits option. return None def open(self, *args: str, **kwargs: str) -> Optional[Awaitable[None]]: """Invoked when a new WebSocket is opened. The arguments to `open` are extracted from the `tornado.web.URLSpec` regular expression, just like the arguments to `tornado.web.RequestHandler.get`. `open` may be a coroutine. `on_message` will not be called until `open` has returned. .. versionchanged:: 5.1 ``open`` may be a coroutine. """ pass def on_message(self, message: Union[str, bytes]) -> Optional[Awaitable[None]]: """Handle incoming messages on the WebSocket This method must be overridden. .. versionchanged:: 4.5 ``on_message`` can be a coroutine. """ raise NotImplementedError def ping(self, data: Union[str, bytes] = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Consider using the ``websocket_ping_interval`` application setting instead of sending pings manually. .. versionchanged:: 5.1 The data argument is now optional. """ data = utf8(data) if self.ws_connection is None or self.ws_connection.is_closing(): raise WebSocketClosedError() self.ws_connection.write_ping(data) def on_pong(self, data: bytes) -> None: """Invoked when the response to a ping frame is received.""" pass def on_ping(self, data: bytes) -> None: """Invoked when the a ping frame is received.""" pass def on_close(self) -> None: """Invoked when the WebSocket is closed. If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes ``self.close_code`` and ``self.close_reason``. .. versionchanged:: 4.0 Added ``close_code`` and ``close_reason`` attributes. """ pass def close(self, code: Optional[int] = None, reason: Optional[str] = None) -> None: """Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/html/rfc6455#section-7.4.1>`_. ``reason`` may be a textual message about why the connection is closing. These values are made available to the client, but are not otherwise interpreted by the websocket protocol. .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments. """ if self.ws_connection: self.ws_connection.close(code, reason) self.ws_connection = None def check_origin(self, origin: str) -> bool: """Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this header; such requests are always allowed (because all browsers that implement WebSockets support this header, and non-browser clients do not have the same cross-site security concerns). Should return ``True`` to accept the request or ``False`` to reject it. By default, rejects all requests with an origin on a host other than this one. This is a security protection against cross site scripting attacks on browsers, since WebSockets are allowed to bypass the usual same-origin policies and don't use CORS headers. .. warning:: This is an important security measure; don't disable it without understanding the security implications. In particular, if your authentication is cookie-based, you must either restrict the origins allowed by ``check_origin()`` or implement your own XSRF-like protection for websocket connections. See `these <https://www.christian-schneider.net/CrossSiteWebSocketHijacking.html>`_ `articles <https://devcenter.heroku.com/articles/websocket-security>`_ for more. To accept all cross-origin traffic (which was the default prior to Tornado 4.0), simply override this method to always return ``True``:: def check_origin(self, origin): return True To allow connections from any subdomain of your site, you might do something like:: def check_origin(self, origin): parsed_origin = urllib.parse.urlparse(origin) return parsed_origin.netloc.endswith(".mydomain.com") .. versionadded:: 4.0 """ parsed_origin = urlparse(origin) origin = parsed_origin.netloc origin = origin.lower() host = self.request.headers.get("Host") # Check to see that origin matches host directly, including ports return origin == host def set_nodelay(self, value: bool) -> None: """Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP delayed ACKs. To reduce this delay (at the expense of possibly increasing bandwidth usage), call ``self.set_nodelay(True)`` once the websocket connection is established. See `.BaseIOStream.set_nodelay` for additional details. .. versionadded:: 3.1 """ assert self.ws_connection is not None self.ws_connection.set_nodelay(value) def on_connection_close(self) -> None: if self.ws_connection: self.ws_connection.on_connection_close() self.ws_connection = None if not self._on_close_called: self._on_close_called = True self.on_close() self._break_cycles() def on_ws_connection_close( self, close_code: Optional[int] = None, close_reason: Optional[str] = None ) -> None: self.close_code = close_code self.close_reason = close_reason self.on_connection_close() def _break_cycles(self) -> None: # WebSocketHandlers call finish() early, but we don't want to # break up reference cycles (which makes it impossible to call # self.render_string) until after we've really closed the # connection (if it was established in the first place, # indicated by status code 101). if self.get_status() != 101 or self._on_close_called: super(WebSocketHandler, self)._break_cycles() def send_error(self, *args: Any, **kwargs: Any) -> None: if self.stream is None: super(WebSocketHandler, self).send_error(*args, **kwargs) else: # If we get an uncaught exception during the handshake, # we have no choice but to abruptly close the connection. # TODO: for uncaught exceptions after the handshake, # we can close the connection more gracefully. self.stream.close() def get_websocket_protocol(self) -> Optional["WebSocketProtocol"]: websocket_version = self.request.headers.get("Sec-WebSocket-Version") if websocket_version in ("7", "8", "13"): params = _WebSocketParams( ping_interval=self.ping_interval, ping_timeout=self.ping_timeout, max_message_size=self.max_message_size, compression_options=self.get_compression_options(), ) return WebSocketProtocol13(self, False, params) return None def _detach_stream(self) -> IOStream: # disable non-WS methods for method in [ "write", "redirect", "set_header", "set_cookie", "set_status", "flush", "finish", ]: setattr(self, method, _raise_not_supported_for_websockets) return self.detach() def _raise_not_supported_for_websockets(*args: Any, **kwargs: Any) -> None: raise RuntimeError("Method not supported for Web Sockets") class WebSocketProtocol(abc.ABC): """Base class for WebSocket protocol versions. """ def __init__(self, handler: "_WebSocketDelegate") -> None: self.handler = handler self.stream = None # type: Optional[IOStream] self.client_terminated = False self.server_terminated = False def _run_callback( self, callback: Callable, *args: Any, **kwargs: Any ) -> "Optional[Future[Any]]": """Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None. """ try: result = callback(*args, **kwargs) except Exception: self.handler.log_exception(*sys.exc_info()) self._abort() return None else: if result is not None: result = gen.convert_yielded(result) assert self.stream is not None self.stream.io_loop.add_future(result, lambda f: f.result()) return result def on_connection_close(self) -> None: self._abort() def _abort(self) -> None: """Instantly aborts the WebSocket connection by closing the socket""" self.client_terminated = True self.server_terminated = True if self.stream is not None: self.stream.close() # forcibly tear down the connection self.close() # let the subclass cleanup @abc.abstractmethod def close(self, code: Optional[int] = None, reason: Optional[str] = None) -> None: raise NotImplementedError() @abc.abstractmethod def is_closing(self) -> bool: raise NotImplementedError() @abc.abstractmethod async def accept_connection(self, handler: WebSocketHandler) -> None: raise NotImplementedError() @abc.abstractmethod def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": raise NotImplementedError() @property @abc.abstractmethod def selected_subprotocol(self) -> Optional[str]: raise NotImplementedError() @abc.abstractmethod def write_ping(self, data: bytes) -> None: raise NotImplementedError() # The entry points below are used by WebSocketClientConnection, # which was introduced after we only supported a single version of # WebSocketProtocol. The WebSocketProtocol/WebSocketProtocol13 # boundary is currently pretty ad-hoc. @abc.abstractmethod def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: raise NotImplementedError() @abc.abstractmethod def start_pinging(self) -> None: raise NotImplementedError() @abc.abstractmethod async def _receive_frame_loop(self) -> None: raise NotImplementedError() @abc.abstractmethod def set_nodelay(self, x: bool) -> None: raise NotImplementedError() class _PerMessageDeflateCompressor(object): def __init__( self, persistent: bool, max_wbits: Optional[int], compression_options: Optional[Dict[str, Any]] = None, ) -> None: if max_wbits is None: max_wbits = zlib.MAX_WBITS # There is no symbolic constant for the minimum wbits value. if not (8 <= max_wbits <= zlib.MAX_WBITS): raise ValueError( "Invalid max_wbits value %r; allowed range 8-%d", max_wbits, zlib.MAX_WBITS, ) self._max_wbits = max_wbits if ( compression_options is None or "compression_level" not in compression_options ): self._compression_level = tornado.web.GZipContentEncoding.GZIP_LEVEL else: self._compression_level = compression_options["compression_level"] if compression_options is None or "mem_level" not in compression_options: self._mem_level = 8 else: self._mem_level = compression_options["mem_level"] if persistent: self._compressor = self._create_compressor() # type: Optional[_Compressor] else: self._compressor = None def _create_compressor(self) -> "_Compressor": return zlib.compressobj( self._compression_level, zlib.DEFLATED, -self._max_wbits, self._mem_level ) def compress(self, data: bytes) -> bytes: compressor = self._compressor or self._create_compressor() data = compressor.compress(data) + compressor.flush(zlib.Z_SYNC_FLUSH) assert data.endswith(b"\x00\x00\xff\xff") return data[:-4] class _PerMessageDeflateDecompressor(object): def __init__( self, persistent: bool, max_wbits: Optional[int], max_message_size: int, compression_options: Optional[Dict[str, Any]] = None, ) -> None: self._max_message_size = max_message_size if max_wbits is None: max_wbits = zlib.MAX_WBITS if not (8 <= max_wbits <= zlib.MAX_WBITS): raise ValueError( "Invalid max_wbits value %r; allowed range 8-%d", max_wbits, zlib.MAX_WBITS, ) self._max_wbits = max_wbits if persistent: self._decompressor = ( self._create_decompressor() ) # type: Optional[_Decompressor] else: self._decompressor = None def _create_decompressor(self) -> "_Decompressor": return zlib.decompressobj(-self._max_wbits) def decompress(self, data: bytes) -> bytes: decompressor = self._decompressor or self._create_decompressor() result = decompressor.decompress( data + b"\x00\x00\xff\xff", self._max_message_size ) if decompressor.unconsumed_tail: raise _DecompressTooLargeError() return result class WebSocketProtocol13(WebSocketProtocol): """Implementation of the WebSocket protocol from RFC 6455. This class supports versions 7 and 8 of the protocol in addition to the final version 13. """ # Bit masks for the first byte of a frame. FIN = 0x80 RSV1 = 0x40 RSV2 = 0x20 RSV3 = 0x10 RSV_MASK = RSV1 | RSV2 | RSV3 OPCODE_MASK = 0x0F stream = None # type: IOStream def __init__( self, handler: "_WebSocketDelegate", mask_outgoing: bool, params: _WebSocketParams, ) -> None: WebSocketProtocol.__init__(self, handler) self.mask_outgoing = mask_outgoing self.params = params self._final_frame = False self._frame_opcode = None self._masked_frame = None self._frame_mask = None # type: Optional[bytes] self._frame_length = None self._fragmented_message_buffer = None # type: Optional[bytes] self._fragmented_message_opcode = None self._waiting = None # type: object self._compression_options = params.compression_options self._decompressor = None # type: Optional[_PerMessageDeflateDecompressor] self._compressor = None # type: Optional[_PerMessageDeflateCompressor] self._frame_compressed = None # type: Optional[bool] # The total uncompressed size of all messages received or sent. # Unicode messages are encoded to utf8. # Only for testing; subject to change. self._message_bytes_in = 0 self._message_bytes_out = 0 # The total size of all packets received or sent. Includes # the effect of compression, frame overhead, and control frames. self._wire_bytes_in = 0 self._wire_bytes_out = 0 self.ping_callback = None # type: Optional[PeriodicCallback] self.last_ping = 0.0 self.last_pong = 0.0 self.close_code = None # type: Optional[int] self.close_reason = None # type: Optional[str] # Use a property for this to satisfy the abc. @property def selected_subprotocol(self) -> Optional[str]: return self._selected_subprotocol @selected_subprotocol.setter def selected_subprotocol(self, value: Optional[str]) -> None: self._selected_subprotocol = value async def accept_connection(self, handler: WebSocketHandler) -> None: try: self._handle_websocket_headers(handler) except ValueError: handler.set_status(400) log_msg = "Missing/Invalid WebSocket headers" handler.finish(log_msg) gen_log.debug(log_msg) return try: await self._accept_connection(handler) except asyncio.CancelledError: self._abort() return except ValueError: gen_log.debug("Malformed WebSocket request received", exc_info=True) self._abort() return def _handle_websocket_headers(self, handler: WebSocketHandler) -> None: """Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised """ fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version") if not all(map(lambda f: handler.request.headers.get(f), fields)): raise ValueError("Missing/Invalid WebSocket headers") @staticmethod def compute_accept_value(key: Union[str, bytes]) -> str: """Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key. """ sha1 = hashlib.sha1() sha1.update(utf8(key)) sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value return native_str(base64.b64encode(sha1.digest())) def _challenge_response(self, handler: WebSocketHandler) -> str: return WebSocketProtocol13.compute_accept_value( cast(str, handler.request.headers.get("Sec-Websocket-Key")) ) async def _accept_connection(self, handler: WebSocketHandler) -> None: subprotocol_header = handler.request.headers.get("Sec-WebSocket-Protocol") if subprotocol_header: subprotocols = [s.strip() for s in subprotocol_header.split(",")] else: subprotocols = [] self.selected_subprotocol = handler.select_subprotocol(subprotocols) if self.selected_subprotocol: assert self.selected_subprotocol in subprotocols handler.set_header("Sec-WebSocket-Protocol", self.selected_subprotocol) extensions = self._parse_extensions_header(handler.request.headers) for ext in extensions: if ext[0] == "permessage-deflate" and self._compression_options is not None: # TODO: negotiate parameters if compression_options # specifies limits. self._create_compressors("server", ext[1], self._compression_options) if ( "client_max_window_bits" in ext[1] and ext[1]["client_max_window_bits"] is None ): # Don't echo an offered client_max_window_bits # parameter with no value. del ext[1]["client_max_window_bits"] handler.set_header( "Sec-WebSocket-Extensions", httputil._encode_header("permessage-deflate", ext[1]), ) break handler.clear_header("Content-Type") handler.set_status(101) handler.set_header("Upgrade", "websocket") handler.set_header("Connection", "Upgrade") handler.set_header("Sec-WebSocket-Accept", self._challenge_response(handler)) handler.finish() self.stream = handler._detach_stream() self.start_pinging() try: open_result = handler.open(*handler.open_args, **handler.open_kwargs) if open_result is not None: await open_result except Exception: handler.log_exception(*sys.exc_info()) self._abort() return await self._receive_frame_loop() def _parse_extensions_header( self, headers: httputil.HTTPHeaders ) -> List[Tuple[str, Dict[str, str]]]: extensions = headers.get("Sec-WebSocket-Extensions", "") if extensions: return [httputil._parse_header(e.strip()) for e in extensions.split(",")] return [] def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websocket" assert headers["Connection"].lower() == "upgrade" accept = self.compute_accept_value(key) assert headers["Sec-Websocket-Accept"] == accept extensions = self._parse_extensions_header(headers) for ext in extensions: if ext[0] == "permessage-deflate" and self._compression_options is not None: self._create_compressors("client", ext[1]) else: raise ValueError("unsupported extension %r", ext) self.selected_subprotocol = headers.get("Sec-WebSocket-Protocol", None) def _get_compressor_options( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options = dict( persistent=(side + "_no_context_takeover") not in agreed_parameters ) # type: Dict[str, Any] wbits_header = agreed_parameters.get(side + "_max_window_bits", None) if wbits_header is None: options["max_wbits"] = zlib.MAX_WBITS else: options["max_wbits"] = int(wbits_header) options["compression_options"] = compression_options return options def _create_compressors( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Optional[Dict[str, Any]] = None, ) -> None: # TODO: handle invalid parameters gracefully allowed_keys = set( [ "server_no_context_takeover", "client_no_context_takeover", "server_max_window_bits", "client_max_window_bits", ] ) for key in agreed_parameters: if key not in allowed_keys: raise ValueError("unsupported compression parameter %r" % key) other_side = "client" if (side == "server") else "server" self._compressor = _PerMessageDeflateCompressor( **self._get_compressor_options(side, agreed_parameters, compression_options) ) self._decompressor = _PerMessageDeflateDecompressor( max_message_size=self.params.max_message_size, **self._get_compressor_options( other_side, agreed_parameters, compression_options ) ) def _write_frame( self, fin: bool, opcode: int, data: bytes, flags: int = 0 ) -> "Future[None]": data_len = len(data) if opcode & 0x8: # All control frames MUST have a payload length of 125 # bytes or less and MUST NOT be fragmented. if not fin: raise ValueError("control frames may not be fragmented") if data_len > 125: raise ValueError("control frame payloads may not exceed 125 bytes") if fin: finbit = self.FIN else: finbit = 0 frame = struct.pack("B", finbit | opcode | flags) if self.mask_outgoing: mask_bit = 0x80 else: mask_bit = 0 if data_len < 126: frame += struct.pack("B", data_len | mask_bit) elif data_len <= 0xFFFF: frame += struct.pack("!BH", 126 | mask_bit, data_len) else: frame += struct.pack("!BQ", 127 | mask_bit, data_len) if self.mask_outgoing: mask = os.urandom(4) data = mask + _websocket_mask(mask, data) frame += data self._wire_bytes_out += len(frame) return self.stream.write(frame) def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket.""" if binary: opcode = 0x2 else: opcode = 0x1 message = tornado.escape.utf8(message) assert isinstance(message, bytes) self._message_bytes_out += len(message) flags = 0 if self._compressor: message = self._compressor.compress(message) flags |= self.RSV1 # For historical reasons, write methods in Tornado operate in a semi-synchronous # mode in which awaiting the Future they return is optional (But errors can # still be raised). This requires us to go through an awkward dance here # to transform the errors that may be returned while presenting the same # semi-synchronous interface. try: fut = self._write_frame(True, opcode, message, flags=flags) except StreamClosedError: raise WebSocketClosedError() async def wrapper() -> None: try: await fut except StreamClosedError: raise WebSocketClosedError() return asyncio.ensure_future(wrapper()) def write_ping(self, data: bytes) -> None: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data) async def _receive_frame_loop(self) -> None: try: while not self.client_terminated: await self._receive_frame() except StreamClosedError: self._abort() self.handler.on_ws_connection_close(self.close_code, self.close_reason) async def _read_bytes(self, n: int) -> bytes: data = await self.stream.read_bytes(n) self._wire_bytes_in += n return data async def _receive_frame(self) -> None: # Read the frame header. data = await self._read_bytes(2) header, mask_payloadlen = struct.unpack("BB", data) is_final_frame = header & self.FIN reserved_bits = header & self.RSV_MASK opcode = header & self.OPCODE_MASK opcode_is_control = opcode & 0x8 if self._decompressor is not None and opcode != 0: # Compression flag is present in the first frame's header, # but we can't decompress until we have all the frames of # the message. self._frame_compressed = bool(reserved_bits & self.RSV1) reserved_bits &= ~self.RSV1 if reserved_bits: # client is using as-yet-undefined extensions; abort self._abort() return is_masked = bool(mask_payloadlen & 0x80) payloadlen = mask_payloadlen & 0x7F # Parse and validate the length. if opcode_is_control and payloadlen >= 126: # control frames must have payload < 126 self._abort() return if payloadlen < 126: self._frame_length = payloadlen elif payloadlen == 126: data = await self._read_bytes(2) payloadlen = struct.unpack("!H", data)[0] elif payloadlen == 127: data = await self._read_bytes(8) payloadlen = struct.unpack("!Q", data)[0] new_len = payloadlen if self._fragmented_message_buffer is not None: new_len += len(self._fragmented_message_buffer) if new_len > self.params.max_message_size: self.close(1009, "message too big") self._abort() return # Read the payload, unmasking if necessary. if is_masked: self._frame_mask = await self._read_bytes(4) data = await self._read_bytes(payloadlen) if is_masked: assert self._frame_mask is not None data = _websocket_mask(self._frame_mask, data) # Decide what to do with this frame. if opcode_is_control: # control frames may be interleaved with a series of fragmented # data frames, so control frames must not interact with # self._fragmented_* if not is_final_frame: # control frames must not be fragmented self._abort() return elif opcode == 0: # continuation frame if self._fragmented_message_buffer is None: # nothing to continue self._abort() return self._fragmented_message_buffer += data if is_final_frame: opcode = self._fragmented_message_opcode data = self._fragmented_message_buffer self._fragmented_message_buffer = None else: # start of new data message if self._fragmented_message_buffer is not None: # can't start new message until the old one is finished self._abort() return if not is_final_frame: self._fragmented_message_opcode = opcode self._fragmented_message_buffer = data if is_final_frame: handled_future = self._handle_message(opcode, data) if handled_future is not None: await handled_future def _handle_message(self, opcode: int, data: bytes) -> "Optional[Future[None]]": """Execute on_message, returning its Future if it is a coroutine.""" if self.client_terminated: return None if self._frame_compressed: assert self._decompressor is not None try: data = self._decompressor.decompress(data) except _DecompressTooLargeError: self.close(1009, "message too big after decompression") self._abort() return None if opcode == 0x1: # UTF-8 data self._message_bytes_in += len(data) try: decoded = data.decode("utf-8") except UnicodeDecodeError: self._abort() return None return self._run_callback(self.handler.on_message, decoded) elif opcode == 0x2: # Binary data self._message_bytes_in += len(data) return self._run_callback(self.handler.on_message, data) elif opcode == 0x8: # Close self.client_terminated = True if len(data) >= 2: self.close_code = struct.unpack(">H", data[:2])[0] if len(data) > 2: self.close_reason = to_unicode(data[2:]) # Echo the received close code, if any (RFC 6455 section 5.5.1). self.close(self.close_code) elif opcode == 0x9: # Ping try: self._write_frame(True, 0xA, data) except StreamClosedError: self._abort() self._run_callback(self.handler.on_ping, data) elif opcode == 0xA: # Pong self.last_pong = IOLoop.current().time() return self._run_callback(self.handler.on_pong, data) else: self._abort() return None def close(self, code: Optional[int] = None, reason: Optional[str] = None) -> None: """Closes the WebSocket connection.""" if not self.server_terminated: if not self.stream.closed(): if code is None and reason is not None: code = 1000 # "normal closure" status code if code is None: close_data = b"" else: close_data = struct.pack(">H", code) if reason is not None: close_data += utf8(reason) try: self._write_frame(True, 0x8, close_data) except StreamClosedError: self._abort() self.server_terminated = True if self.client_terminated: if self._waiting is not None: self.stream.io_loop.remove_timeout(self._waiting) self._waiting = None self.stream.close() elif self._waiting is None: # Give the client a few seconds to complete a clean shutdown, # otherwise just close the connection. self._waiting = self.stream.io_loop.add_timeout( self.stream.io_loop.time() + 5, self._abort ) def is_closing(self) -> bool: """Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly. """ return self.stream.closed() or self.client_terminated or self.server_terminated @property def ping_interval(self) -> Optional[float]: interval = self.params.ping_interval if interval is not None: return interval return 0 @property def ping_timeout(self) -> Optional[float]: timeout = self.params.ping_timeout if timeout is not None: return timeout assert self.ping_interval is not None return max(3 * self.ping_interval, 30) def start_pinging(self) -> None: """Start sending periodic pings to keep the connection alive""" assert self.ping_interval is not None if self.ping_interval > 0: self.last_ping = self.last_pong = IOLoop.current().time() self.ping_callback = PeriodicCallback( self.periodic_ping, self.ping_interval * 1000 ) self.ping_callback.start() def periodic_ping(self) -> None: """Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero. """ if self.is_closing() and self.ping_callback is not None: self.ping_callback.stop() return # Check for timeout on pong. Make sure that we really have # sent a recent ping in case the machine with both server and # client has been suspended since the last ping. now = IOLoop.current().time() since_last_pong = now - self.last_pong since_last_ping = now - self.last_ping assert self.ping_interval is not None assert self.ping_timeout is not None if ( since_last_ping < 2 * self.ping_interval and since_last_pong > self.ping_timeout ): self.close() return self.write_ping(b"") self.last_ping = now def set_nodelay(self, x: bool) -> None: self.stream.set_nodelay(x) class WebSocketClientConnection(simple_httpclient._HTTPConnection): """WebSocket client connection. This class should not be instantiated directly; use the `websocket_connect` function instead. """ protocol = None # type: WebSocketProtocol def __init__( self, request: httpclient.HTTPRequest, on_message_callback: Optional[Callable[[Union[None, str, bytes]], None]] = None, compression_options: Optional[Dict[str, Any]] = None, ping_interval: Optional[float] = None, ping_timeout: Optional[float] = None, max_message_size: int = _default_max_message_size, subprotocols: Optional[List[str]] = [], ) -> None: self.connect_future = Future() # type: Future[WebSocketClientConnection] self.read_queue = Queue(1) # type: Queue[Union[None, str, bytes]] self.key = base64.b64encode(os.urandom(16)) self._on_message_callback = on_message_callback self.close_code = None # type: Optional[int] self.close_reason = None # type: Optional[str] self.params = _WebSocketParams( ping_interval=ping_interval, ping_timeout=ping_timeout, max_message_size=max_message_size, compression_options=compression_options, ) scheme, sep, rest = request.url.partition(":") scheme = {"ws": "http", "wss": "https"}[scheme] request.url = scheme + sep + rest request.headers.update( { "Upgrade": "websocket", "Connection": "Upgrade", "Sec-WebSocket-Key": self.key, "Sec-WebSocket-Version": "13", } ) if subprotocols is not None: request.headers["Sec-WebSocket-Protocol"] = ",".join(subprotocols) if compression_options is not None: # Always offer to let the server set our max_wbits (and even though # we don't offer it, we will accept a client_no_context_takeover # from the server). # TODO: set server parameters for deflate extension # if requested in self.compression_options. request.headers[ "Sec-WebSocket-Extensions" ] = "permessage-deflate; client_max_window_bits" self.tcp_client = TCPClient() super(WebSocketClientConnection, self).__init__( None, request, lambda: None, self._on_http_response, 104857600, self.tcp_client, 65536, 104857600, ) def close(self, code: Optional[int] = None, reason: Optional[str] = None) -> None: """Closes the websocket connection. ``code`` and ``reason`` are documented under `WebSocketHandler.close`. .. versionadded:: 3.2 .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments. """ if self.protocol is not None: self.protocol.close(code, reason) self.protocol = None # type: ignore def on_connection_close(self) -> None: if not self.connect_future.done(): self.connect_future.set_exception(StreamClosedError()) self._on_message(None) self.tcp_client.close() super(WebSocketClientConnection, self).on_connection_close() def on_ws_connection_close( self, close_code: Optional[int] = None, close_reason: Optional[str] = None ) -> None: self.close_code = close_code self.close_reason = close_reason self.on_connection_close() def _on_http_response(self, response: httpclient.HTTPResponse) -> None: if not self.connect_future.done(): if response.error: self.connect_future.set_exception(response.error) else: self.connect_future.set_exception( WebSocketError("Non-websocket response") ) async def headers_received( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, ) -> None: assert isinstance(start_line, httputil.ResponseStartLine) if start_line.code != 101: await super(WebSocketClientConnection, self).headers_received( start_line, headers ) return if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = None self.headers = headers self.protocol = self.get_websocket_protocol() self.protocol._process_server_headers(self.key, self.headers) self.protocol.stream = self.connection.detach() IOLoop.current().add_callback(self.protocol._receive_frame_loop) self.protocol.start_pinging() # Once we've taken over the connection, clear the final callback # we set on the http request. This deactivates the error handling # in simple_httpclient that would otherwise interfere with our # ability to see exceptions. self.final_callback = None # type: ignore future_set_result_unless_cancelled(self.connect_future, self) def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0 Exception raised on a closed stream changed from `.StreamClosedError` to `WebSocketClosedError`. """ return self.protocol.write_message(message, binary=binary) def read_message( self, callback: Optional[Callable[["Future[Union[None, str, bytes]]"], None]] = None, ) -> Awaitable[Union[None, str, bytes]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messages Returns a future whose result is the message, or None if the connection is closed. If a callback argument is given it will be called with the future when it is ready. """ awaitable = self.read_queue.get() if callback is not None: self.io_loop.add_future(asyncio.ensure_future(awaitable), callback) return awaitable def on_message(self, message: Union[str, bytes]) -> Optional[Awaitable[None]]: return self._on_message(message) def _on_message( self, message: Union[None, str, bytes] ) -> Optional[Awaitable[None]]: if self._on_message_callback: self._on_message_callback(message) return None else: return self.read_queue.put(message) def ping(self, data: bytes = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Consider using the ``ping_interval`` argument to `websocket_connect` instead of sending pings manually. .. versionadded:: 5.1 """ data = utf8(data) if self.protocol is None: raise WebSocketClosedError() self.protocol.write_ping(data) def on_pong(self, data: bytes) -> None: pass def on_ping(self, data: bytes) -> None: pass def get_websocket_protocol(self) -> WebSocketProtocol: return WebSocketProtocol13(self, mask_outgoing=True, params=self.params) @property def selected_subprotocol(self) -> Optional[str]: """The subprotocol selected by the server. .. versionadded:: 5.1 """ return self.protocol.selected_subprotocol def log_exception( self, typ: "Optional[Type[BaseException]]", value: Optional[BaseException], tb: Optional[TracebackType], ) -> None: assert typ is not None assert value is not None app_log.error("Uncaught exception %s", value, exc_info=(typ, value, tb)) def websocket_connect( url: Union[str, httpclient.HTTPRequest], callback: Optional[Callable[["Future[WebSocketClientConnection]"], None]] = None, connect_timeout: Optional[float] = None, on_message_callback: Optional[Callable[[Union[None, str, bytes]], None]] = None, compression_options: Optional[Dict[str, Any]] = None, ping_interval: Optional[float] = None, ping_timeout: Optional[float] = None, max_message_size: int = _default_max_message_size, subprotocols: Optional[List[str]] = None, ) -> "Awaitable[WebSocketClientConnection]": """Client-side websocket support. Takes a url and returns a Future whose result is a `WebSocketClientConnection`. ``compression_options`` is interpreted in the same way as the return value of `.WebSocketHandler.get_compression_options`. The connection supports two styles of operation. In the coroutine style, the application typically calls `~.WebSocketClientConnection.read_message` in a loop:: conn = yield websocket_connect(url) while True: msg = yield conn.read_message() if msg is None: break # Do something with msg In the callback style, pass an ``on_message_callback`` to ``websocket_connect``. In both styles, a message of ``None`` indicates that the connection has been closed. ``subprotocols`` may be a list of strings specifying proposed subprotocols. The selected protocol may be found on the ``selected_subprotocol`` attribute of the connection object when the connection is complete. .. versionchanged:: 3.2 Also accepts ``HTTPRequest`` objects in place of urls. .. versionchanged:: 4.1 Added ``compression_options`` and ``on_message_callback``. .. versionchanged:: 4.5 Added the ``ping_interval``, ``ping_timeout``, and ``max_message_size`` arguments, which have the same meaning as in `WebSocketHandler`. .. versionchanged:: 5.0 The ``io_loop`` argument (deprecated since version 4.1) has been removed. .. versionchanged:: 5.1 Added the ``subprotocols`` argument. """ if isinstance(url, httpclient.HTTPRequest): assert connect_timeout is None request = url # Copy and convert the headers dict/object (see comments in # AsyncHTTPClient.fetch) request.headers = httputil.HTTPHeaders(request.headers) else: request = httpclient.HTTPRequest(url, connect_timeout=connect_timeout) request = cast( httpclient.HTTPRequest, httpclient._RequestProxy(request, httpclient.HTTPRequest._DEFAULTS), ) conn = WebSocketClientConnection( request, on_message_callback=on_message_callback, compression_options=compression_options, ping_interval=ping_interval, ping_timeout=ping_timeout, max_message_size=max_message_size, subprotocols=subprotocols, ) if callback is not None: IOLoop.current().add_future(conn.connect_future, callback) return conn.connect_future
bdarnell/tornado
tornado/websocket.py
Python
apache-2.0
61,445
[ "VisIt" ]
b8199ae17902138442004db013c0ba9831c32fde51dce3cd98f5c5eac8b48163
# Copyright 2008-2009 Brian Boyer, Ryan Mark, Angela Nitzke, Joshua Pollock, # Stuart Tiffen, Kayla Webley and the Medill School of Journalism, Northwestern # University. # # This file is part of django-facebookconnect. # # django-facebookconnect is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # django-facebookconnect is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with django-facebookconnect. If not, see <http://www.gnu.org/licenses/>. from django.conf import settings from django.core.management import BaseCommand from django.core.exceptions import ImproperlyConfigured class Command(BaseCommand): def handle(self,*args,**options): """change the database schema to except big email addresses""" from django.db import connection, transaction cursor = connection.cursor() # Data modifying operation - commit required cursor.execute("ALTER TABLE `auth_user` CHANGE `email` `email` VARCHAR(255);") transaction.commit()
mapmyfitness/django-facebookconnect
facebookconnect/management/commands/fixemailfieldsize.py
Python
gpl-3.0
1,428
[ "Brian" ]
f47c8655b232f76c36792ee119413489bae8e7939bf985895bcbbf2bde8e1a7f
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Multivariate Normal distribution classes.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import math from tensorflow.contrib.distributions.python.ops import distribution from tensorflow.contrib.distributions.python.ops import distribution_util from tensorflow.contrib.distributions.python.ops import kullback_leibler from tensorflow.contrib.distributions.python.ops import operator_pd_cholesky from tensorflow.contrib.distributions.python.ops import operator_pd_diag from tensorflow.contrib.distributions.python.ops import operator_pd_full from tensorflow.contrib.distributions.python.ops import operator_pd_vdvt_update from tensorflow.contrib.framework.python.framework import tensor_util as contrib_tensor_util from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import check_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import random_ops __all__ = [ "MultivariateNormalDiag", "MultivariateNormalDiagWithSoftplusStDev", "MultivariateNormalCholesky", "MultivariateNormalFull", "MultivariateNormalDiagPlusVDVT", ] _mvn_prob_note = """ `x` is a batch vector with compatible shape if `x` is a `Tensor` whose shape can be broadcast up to either: ``` self.batch_shape + self.event_shape ``` or ``` [M1,...,Mm] + self.batch_shape + self.event_shape ``` """ class _MultivariateNormalOperatorPD(distribution.Distribution): """The multivariate normal distribution on `R^k`. This distribution is defined by a 1-D mean `mu` and an instance of `OperatorPDBase`, which provides access to a symmetric positive definite operator, which defines the covariance. #### Mathematical details With `C` the covariance matrix represented by the operator, the PDF of this distribution is: ``` f(x) = (2 pi)^(-k/2) |det(C)|^(-1/2) exp(-1/2 (x - mu)^T C^{-1} (x - mu)) ``` #### Examples A single multi-variate Gaussian distribution is defined by a vector of means of length `k`, and a covariance matrix of shape `k x k`. Extra leading dimensions, if provided, allow for batches. ```python # Initialize a single 3-variate Gaussian. mu = [1, 2, 3] chol = [[1, 0, 0.], [1, 3, 0], [1, 2, 3]] cov = tf.contrib.distributions.OperatorPDCholesky(chol) dist = tf.contrib.distributions._MultivariateNormalOperatorPD(mu, cov) # Evaluate this on an observation in R^3, returning a scalar. dist.pdf([-1, 0, 1.]) # Initialize a batch of two 3-variate Gaussians. mu = [[1, 2, 3], [11, 22, 33.]] chol = ... # shape 2 x 3 x 3, lower triangular, positive diagonal. cov = tf.contrib.distributions.OperatorPDCholesky(chol) dist = tf.contrib.distributions._MultivariateNormalOperatorPD(mu, cov) # Evaluate this on a two observations, each in R^3, returning a length two # tensor. x = [[-1, 0, 1], [-11, 0, 11.]] # Shape 2 x 3. dist.pdf(x) ``` """ def __init__(self, mu, cov, validate_args=False, allow_nan_stats=True, name="MultivariateNormalCov"): """Multivariate Normal distributions on `R^k`. User must provide means `mu`, and an instance of `OperatorPDBase`, `cov`, which determines the covariance. Args: mu: Floating point tensor with shape `[N1,...,Nb, k]`, `b >= 0`. cov: Instance of `OperatorPDBase` with same `dtype` as `mu` and shape `[N1,...,Nb, k, k]`. validate_args: `Boolean`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed. allow_nan_stats: `Boolean`, default `True`. If `False`, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member If `True`, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. name: The name to give Ops created by the initializer. Raises: TypeError: If `mu` and `cov` are different dtypes. """ parameters = locals() parameters.pop("self") with ops.name_scope(name) as ns: with ops.name_scope("init", values=[mu] + cov.inputs): self._mu = array_ops.identity(mu, name="mu") self._cov = cov self._validate_args = validate_args # Needed by _assert_valid_mu. self._mu = self._assert_valid_mu(self._mu) super(_MultivariateNormalOperatorPD, self).__init__( dtype=self._mu.dtype, is_reparameterized=True, is_continuous=True, validate_args=validate_args, allow_nan_stats=allow_nan_stats, parameters=parameters, graph_parents=[self._mu] + cov.inputs, name=ns) def _assert_valid_mu(self, mu): """Return `mu` after validity checks and possibly with assertations.""" cov = self._cov if mu.dtype != cov.dtype: raise TypeError( "mu and cov must have the same dtype. Found mu.dtype = %s, " "cov.dtype = %s" % (mu.dtype, cov.dtype)) # Try to validate with static checks. mu_shape = mu.get_shape() cov_shape = cov.get_shape() if mu_shape.is_fully_defined() and cov_shape.is_fully_defined(): if mu_shape != cov_shape[:-1]: raise ValueError( "mu.shape and cov.shape[:-1] should match. Found: mu.shape=%s, " "cov.shape=%s" % (mu_shape, cov_shape)) else: return mu # Static checks could not be run, so possibly do dynamic checks. if not self.validate_args: return mu else: assert_same_rank = check_ops.assert_equal( array_ops.rank(mu) + 1, cov.rank(), data=["mu should have rank 1 less than cov. Found: rank(mu) = ", array_ops.rank(mu), " rank(cov) = ", cov.rank()], ) with ops.control_dependencies([assert_same_rank]): assert_same_shape = check_ops.assert_equal( array_ops.shape(mu), cov.vector_shape(), data=["mu.shape and cov.shape[:-1] should match. " "Found: shape(mu) = " , array_ops.shape(mu), " shape(cov) = ", cov.shape()], ) return control_flow_ops.with_dependencies([assert_same_shape], mu) @property def mu(self): return self._mu @property def sigma(self): """Dense (batch) covariance matrix, if available.""" with ops.name_scope(self.name): return self._cov.to_dense() def log_sigma_det(self, name="log_sigma_det"): """Log of determinant of covariance matrix.""" with ops.name_scope(self.name): with ops.name_scope(name, values=self._cov.inputs): return self._cov.log_det() def sigma_det(self, name="sigma_det"): """Determinant of covariance matrix.""" with ops.name_scope(self.name): with ops.name_scope(name, values=self._cov.inputs): return math_ops.exp(self._cov.log_det()) def _batch_shape(self): return self._cov.batch_shape() def _get_batch_shape(self): return self._cov.get_batch_shape() def _event_shape(self): return array_ops.stack([self._cov.vector_space_dimension()]) def _get_event_shape(self): return self._cov.get_shape()[-1:] def _sample_n(self, n, seed=None): # Recall _assert_valid_mu ensures mu and self._cov have same batch shape. shape = array_ops.concat([self._cov.vector_shape(), [n]], 0) white_samples = random_ops.random_normal(shape=shape, mean=0., stddev=1., dtype=self.dtype, seed=seed) correlated_samples = self._cov.sqrt_matmul(white_samples) # Move the last dimension to the front perm = array_ops.concat( (array_ops.stack([array_ops.rank(correlated_samples) - 1]), math_ops.range(0, array_ops.rank(correlated_samples) - 1)), 0) # TODO(ebrevdo): Once we get a proper tensor contraction op, # perform the inner product using that instead of batch_matmul # and this slow transpose can go away! correlated_samples = array_ops.transpose(correlated_samples, perm) samples = correlated_samples + self.mu return samples @distribution_util.AppendDocstring(_mvn_prob_note) def _log_prob(self, x): # Q: Why are shape requirements as stated above? # A: The compatible shapes are precisely the ones that will broadcast to # a shape compatible with self._cov. # See Operator base class for notes about shapes compatible with self._cov. x = ops.convert_to_tensor(x) contrib_tensor_util.assert_same_float_dtype((self._mu, x)) # _assert_valid_mu asserts that self.mu has same batch shape as self.cov. # so batch shape of self.mu = that of self._cov and self, and the # batch shape of x_centered is a broadcast version of these. If this # broadcast results in a shape like # [M1,...,Mm] + self.batch_shape + self.event_shape # OR # self.batch_shape + self.event_shape # then subsequent operator calls are guaranteed to work. x_centered = x - self.mu # Compute the term x^{-1} sigma^{-1} x which appears in the exponent of # the pdf. x_whitened_norm = self._cov.inv_quadratic_form_on_vectors(x_centered) k = math_ops.cast(self._cov.vector_space_dimension(), self.dtype) log_prob_value = -0.5 * (self.log_sigma_det() + k * math.log(2. * math.pi) + x_whitened_norm) output_static_shape = x_centered.get_shape()[:-1] log_prob_value.set_shape(output_static_shape) return log_prob_value @distribution_util.AppendDocstring(_mvn_prob_note) def _prob(self, x): return math_ops.exp(self.log_prob(x)) def _entropy(self): log_sigma_det = self.log_sigma_det() one_plus_log_two_pi = constant_op.constant(1 + math.log(2 * math.pi), dtype=self.dtype) # Use broadcasting rules to calculate the full broadcast sigma. k = math_ops.cast(self._cov.vector_space_dimension(), dtype=self.dtype) entropy_value = (k * one_plus_log_two_pi + log_sigma_det) / 2 entropy_value.set_shape(log_sigma_det.get_shape()) return entropy_value def _mean(self): return array_ops.identity(self._mu) def _variance(self): return self.sigma def _mode(self): return array_ops.identity(self._mu) class MultivariateNormalDiag(_MultivariateNormalOperatorPD): """The multivariate normal distribution on `R^k`. This distribution is defined by a 1-D mean `mu` and a 1-D diagonal `diag_stdev`, representing the standard deviations. This distribution assumes the random variables, `(X_1,...,X_k)` are independent, thus no non-diagonal terms of the covariance matrix are needed. This allows for `O(k)` pdf evaluation, sampling, and storage. #### Mathematical details The PDF of this distribution is defined in terms of the diagonal covariance determined by `diag_stdev`: `C_{ii} = diag_stdev[i]**2`. ``` f(x) = (2 pi)^(-k/2) |det(C)|^(-1/2) exp(-1/2 (x - mu)^T C^{-1} (x - mu)) ``` #### Examples A single multi-variate Gaussian distribution is defined by a vector of means of length `k`, and the square roots of the (independent) random variables. Extra leading dimensions, if provided, allow for batches. ```python # Initialize a single 3-variate Gaussian with diagonal standard deviation. mu = [1, 2, 3.] diag_stdev = [4, 5, 6.] dist = tf.contrib.distributions.MultivariateNormalDiag(mu, diag_stdev) # Evaluate this on an observation in R^3, returning a scalar. dist.pdf([-1, 0, 1]) # Initialize a batch of two 3-variate Gaussians. mu = [[1, 2, 3], [11, 22, 33]] # shape 2 x 3 diag_stdev = ... # shape 2 x 3, positive. dist = tf.contrib.distributions.MultivariateNormalDiag(mu, diag_stdev) # Evaluate this on a two observations, each in R^3, returning a length two # tensor. x = [[-1, 0, 1], [-11, 0, 11]] # Shape 2 x 3. dist.pdf(x) ``` """ def __init__( self, mu, diag_stdev, validate_args=False, allow_nan_stats=True, name="MultivariateNormalDiag"): """Multivariate Normal distributions on `R^k`. User must provide means `mu` and standard deviations `diag_stdev`. Each batch member represents a random vector `(X_1,...,X_k)` of independent random normals. The mean of `X_i` is `mu[i]`, and the standard deviation is `diag_stdev[i]`. Args: mu: Rank `N + 1` floating point tensor with shape `[N1,...,Nb, k]`, `b >= 0`. diag_stdev: Rank `N + 1` `Tensor` with same `dtype` and shape as `mu`, representing the standard deviations. Must be positive. validate_args: `Boolean`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed. allow_nan_stats: `Boolean`, default `True`. If `False`, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member If `True`, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. name: The name to give Ops created by the initializer. Raises: TypeError: If `mu` and `diag_stdev` are different dtypes. """ parameters = locals() parameters.pop("self") with ops.name_scope(name, values=[diag_stdev]) as ns: cov = operator_pd_diag.OperatorPDSqrtDiag(diag_stdev, verify_pd=validate_args) super(MultivariateNormalDiag, self).__init__( mu, cov, allow_nan_stats=allow_nan_stats, validate_args=validate_args, name=ns) self._parameters = parameters class MultivariateNormalDiagWithSoftplusStDev(MultivariateNormalDiag): """MultivariateNormalDiag with `diag_stddev = softplus(diag_stddev)`.""" def __init__(self, mu, diag_stdev, validate_args=False, allow_nan_stats=True, name="MultivariateNormalDiagWithSoftplusStdDev"): parameters = locals() parameters.pop("self") with ops.name_scope(name, values=[diag_stdev]) as ns: super(MultivariateNormalDiagWithSoftplusStDev, self).__init__( mu=mu, diag_stdev=nn.softplus(diag_stdev), validate_args=validate_args, allow_nan_stats=allow_nan_stats, name=ns) self._parameters = parameters class MultivariateNormalDiagPlusVDVT(_MultivariateNormalOperatorPD): """The multivariate normal distribution on `R^k`. Every batch member of this distribution is defined by a mean and a lightweight covariance matrix `C`. #### Mathematical details The PDF of this distribution in terms of the mean `mu` and covariance `C` is: ``` f(x) = (2 pi)^(-k/2) |det(C)|^(-1/2) exp(-1/2 (x - mu)^T C^{-1} (x - mu)) ``` For every batch member, this distribution represents `k` random variables `(X_1,...,X_k)`, with mean `E[X_i] = mu[i]`, and covariance matrix `C_{ij} := E[(X_i - mu[i])(X_j - mu[j])]` The user initializes this class by providing the mean `mu`, and a lightweight definition of `C`: ``` C = SS^T = SS = (M + V D V^T) (M + V D V^T) M is diagonal (k x k) V = is shape (k x r), typically r << k D = is diagonal (r x r), optional (defaults to identity). ``` This allows for `O(kr + r^3)` pdf evaluation and determinant, and `O(kr)` sampling and storage (per batch member). #### Examples A single multi-variate Gaussian distribution is defined by a vector of means of length `k`, and square root of the covariance `S = M + V D V^T`. Extra leading dimensions, if provided, allow for batches. ```python # Initialize a single 3-variate Gaussian with covariance square root # S = M + V D V^T, where V D V^T is a matrix-rank 2 update. mu = [1, 2, 3.] diag_large = [1.1, 2.2, 3.3] v = ... # shape 3 x 2 diag_small = [4., 5.] dist = tf.contrib.distributions.MultivariateNormalDiagPlusVDVT( mu, diag_large, v, diag_small=diag_small) # Evaluate this on an observation in R^3, returning a scalar. dist.pdf([-1, 0, 1]) # Initialize a batch of two 3-variate Gaussians. This time, don't provide # diag_small. This means S = M + V V^T. mu = [[1, 2, 3], [11, 22, 33]] # shape 2 x 3 diag_large = ... # shape 2 x 3 v = ... # shape 2 x 3 x 1, a matrix-rank 1 update. dist = tf.contrib.distributions.MultivariateNormalDiagPlusVDVT( mu, diag_large, v) # Evaluate this on a two observations, each in R^3, returning a length two # tensor. x = [[-1, 0, 1], [-11, 0, 11]] # Shape 2 x 3. dist.pdf(x) ``` """ def __init__( self, mu, diag_large, v, diag_small=None, validate_args=False, allow_nan_stats=True, name="MultivariateNormalDiagPlusVDVT"): """Multivariate Normal distributions on `R^k`. For every batch member, this distribution represents `k` random variables `(X_1,...,X_k)`, with mean `E[X_i] = mu[i]`, and covariance matrix `C_{ij} := E[(X_i - mu[i])(X_j - mu[j])]` The user initializes this class by providing the mean `mu`, and a lightweight definition of `C`: ``` C = SS^T = SS = (M + V D V^T) (M + V D V^T) M is diagonal (k x k) V = is shape (k x r), typically r << k D = is diagonal (r x r), optional (defaults to identity). ``` Args: mu: Rank `n + 1` floating point tensor with shape `[N1,...,Nn, k]`, `n >= 0`. The means. diag_large: Optional rank `n + 1` floating point tensor, shape `[N1,...,Nn, k]` `n >= 0`. Defines the diagonal matrix `M`. v: Rank `n + 1` floating point tensor, shape `[N1,...,Nn, k, r]` `n >= 0`. Defines the matrix `V`. diag_small: Rank `n + 1` floating point tensor, shape `[N1,...,Nn, k]` `n >= 0`. Defines the diagonal matrix `D`. Default is `None`, which means `D` will be the identity matrix. validate_args: `Boolean`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed. allow_nan_stats: `Boolean`, default `True`. If `False`, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member If `True`, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. name: The name to give Ops created by the initializer. """ parameters = locals() parameters.pop("self") with ops.name_scope(name, values=[diag_large, v, diag_small]) as ns: cov = operator_pd_vdvt_update.OperatorPDSqrtVDVTUpdate( operator_pd_diag.OperatorPDDiag( diag_large, verify_pd=validate_args), v, diag=diag_small, verify_pd=validate_args, verify_shapes=validate_args) super(MultivariateNormalDiagPlusVDVT, self).__init__( mu, cov, allow_nan_stats=allow_nan_stats, validate_args=validate_args, name=ns) self._parameters = parameters class MultivariateNormalCholesky(_MultivariateNormalOperatorPD): """The multivariate normal distribution on `R^k`. This distribution is defined by a 1-D mean `mu` and a Cholesky factor `chol`. Providing the Cholesky factor allows for `O(k^2)` pdf evaluation and sampling, and requires `O(k^2)` storage. #### Mathematical details The Cholesky factor `chol` defines the covariance matrix: `C = chol chol^T`. The PDF of this distribution is then: ``` f(x) = (2 pi)^(-k/2) |det(C)|^(-1/2) exp(-1/2 (x - mu)^T C^{-1} (x - mu)) ``` #### Examples A single multi-variate Gaussian distribution is defined by a vector of means of length `k`, and a covariance matrix of shape `k x k`. Extra leading dimensions, if provided, allow for batches. ```python # Initialize a single 3-variate Gaussian with diagonal covariance. # Note, this would be more efficient with MultivariateNormalDiag. mu = [1, 2, 3.] chol = [[1, 0, 0], [0, 3, 0], [0, 0, 2]] dist = tf.contrib.distributions.MultivariateNormalCholesky(mu, chol) # Evaluate this on an observation in R^3, returning a scalar. dist.pdf([-1, 0, 1]) # Initialize a batch of two 3-variate Gaussians. mu = [[1, 2, 3], [11, 22, 33]] chol = ... # shape 2 x 3 x 3, lower triangular, positive diagonal. dist = tf.contrib.distributions.MultivariateNormalCholesky(mu, chol) # Evaluate this on a two observations, each in R^3, returning a length two # tensor. x = [[-1, 0, 1], [-11, 0, 11]] # Shape 2 x 3. dist.pdf(x) ``` Trainable (batch) Cholesky matrices can be created with `tf.contrib.distributions.matrix_diag_transform()` """ def __init__(self, mu, chol, validate_args=False, allow_nan_stats=True, name="MultivariateNormalCholesky"): """Multivariate Normal distributions on `R^k`. User must provide means `mu` and `chol` which holds the (batch) Cholesky factors, such that the covariance of each batch member is `chol chol^T`. Args: mu: `(N+1)-D` floating point tensor with shape `[N1,...,Nb, k]`, `b >= 0`. chol: `(N+2)-D` `Tensor` with same `dtype` as `mu` and shape `[N1,...,Nb, k, k]`. The upper triangular part is ignored (treated as though it is zero), and the diagonal must be positive. validate_args: `Boolean`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed. allow_nan_stats: `Boolean`, default `True`. If `False`, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member If `True`, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. name: The name to give Ops created by the initializer. Raises: TypeError: If `mu` and `chol` are different dtypes. """ parameters = locals() parameters.pop("self") with ops.name_scope(name, values=[chol]) as ns: cov = operator_pd_cholesky.OperatorPDCholesky(chol, verify_pd=validate_args) super(MultivariateNormalCholesky, self).__init__( mu, cov, allow_nan_stats=allow_nan_stats, validate_args=validate_args, name=ns) self._parameters = parameters class MultivariateNormalFull(_MultivariateNormalOperatorPD): """The multivariate normal distribution on `R^k`. This distribution is defined by a 1-D mean `mu` and covariance matrix `sigma`. Evaluation of the pdf, determinant, and sampling are all `O(k^3)` operations. #### Mathematical details With `C = sigma`, the PDF of this distribution is: ``` f(x) = (2 pi)^(-k/2) |det(C)|^(-1/2) exp(-1/2 (x - mu)^T C^{-1} (x - mu)) ``` #### Examples A single multi-variate Gaussian distribution is defined by a vector of means of length `k`, and a covariance matrix of shape `k x k`. Extra leading dimensions, if provided, allow for batches. ```python # Initialize a single 3-variate Gaussian with diagonal covariance. mu = [1, 2, 3.] sigma = [[1, 0, 0], [0, 3, 0], [0, 0, 2.]] dist = tf.contrib.distributions.MultivariateNormalFull(mu, chol) # Evaluate this on an observation in R^3, returning a scalar. dist.pdf([-1, 0, 1]) # Initialize a batch of two 3-variate Gaussians. mu = [[1, 2, 3], [11, 22, 33.]] sigma = ... # shape 2 x 3 x 3, positive definite. dist = tf.contrib.distributions.MultivariateNormalFull(mu, sigma) # Evaluate this on a two observations, each in R^3, returning a length two # tensor. x = [[-1, 0, 1], [-11, 0, 11.]] # Shape 2 x 3. dist.pdf(x) ``` """ def __init__(self, mu, sigma, validate_args=False, allow_nan_stats=True, name="MultivariateNormalFull"): """Multivariate Normal distributions on `R^k`. User must provide means `mu` and `sigma`, the mean and covariance. Args: mu: `(N+1)-D` floating point tensor with shape `[N1,...,Nb, k]`, `b >= 0`. sigma: `(N+2)-D` `Tensor` with same `dtype` as `mu` and shape `[N1,...,Nb, k, k]`. Each batch member must be positive definite. validate_args: `Boolean`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed. allow_nan_stats: `Boolean`, default `True`. If `False`, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member If `True`, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. name: The name to give Ops created by the initializer. Raises: TypeError: If `mu` and `sigma` are different dtypes. """ parameters = locals() parameters.pop("self") with ops.name_scope(name, values=[sigma]) as ns: cov = operator_pd_full.OperatorPDFull(sigma, verify_pd=validate_args) super(MultivariateNormalFull, self).__init__( mu, cov, allow_nan_stats=allow_nan_stats, validate_args=validate_args, name=ns) self._parameters = parameters @kullback_leibler.RegisterKL( _MultivariateNormalOperatorPD, _MultivariateNormalOperatorPD) def _kl_mvn_mvn_brute_force(mvn_a, mvn_b, name=None): """Batched KL divergence `KL(mvn_a || mvn_b)` for multivariate normals. With `X`, `Y` both multivariate normals in `R^k` with means `mu_x`, `mu_y` and covariance `C_x`, `C_y` respectively, ``` KL(X || Y) = 0.5 * ( T + Q + - k + L ), T := trace(C_b^{-1} C_a), Q := (mu_b - mu_a)^T C_b^{-1} (mu_b - mu_a), L := Log[Det(C_b)] - Log[Det(C_a)] ``` This `Op` computes the trace by solving `C_b^{-1} C_a`. Although efficient methods for solving systems with `C_b` may be available, a dense version of (the square root of) `C_a` is used, so performance is `O(B s k^2)` where `B` is the batch size, and `s` is the cost of solving `C_b x = y` for vectors `x` and `y`. Args: mvn_a: Instance of subclass of `_MultivariateNormalOperatorPD`. mvn_b: Instance of subclass of `_MultivariateNormalOperatorPD`. name: (optional) name to use for created ops. Default "kl_mvn_mvn". Returns: Batchwise `KL(mvn_a || mvn_b)`. """ # Access the "private" OperatorPD that each mvn is built from. cov_a = mvn_a._cov # pylint: disable=protected-access cov_b = mvn_b._cov # pylint: disable=protected-access mu_a = mvn_a.mu mu_b = mvn_b.mu inputs = [mu_a, mu_b] + cov_a.inputs + cov_b.inputs with ops.name_scope(name, "kl_mvn_mvn", inputs): # If Ca = AA', Cb = BB', then # tr[inv(Cb) Ca] = tr[inv(B)' inv(B) A A'] # = tr[inv(B) A A' inv(B)'] # = tr[(inv(B) A) (inv(B) A)'] # = sum_{ik} (inv(B) A)_{ik}^2 # The second equality follows from the cyclic permutation property. b_inv_a = cov_b.sqrt_solve(cov_a.sqrt_to_dense()) t = math_ops.reduce_sum( math_ops.square(b_inv_a), reduction_indices=[-1, -2]) q = cov_b.inv_quadratic_form_on_vectors(mu_b - mu_a) k = math_ops.cast(cov_a.vector_space_dimension(), mvn_a.dtype) one_half_l = cov_b.sqrt_log_det() - cov_a.sqrt_log_det() return 0.5 * (t + q - k) + one_half_l
jjas0nn/solvem
tensorflow/lib/python2.7/site-packages/tensorflow/contrib/distributions/python/ops/mvn.py
Python
mit
28,680
[ "Gaussian" ]
b51dd3d97c1f705ada4dd969a57e8f94f360186ac56d4ba0179b8f22e2c98028
import gc import sys import unittest import warnings import weakref import inspect import types from test import support class FinalizationTest(unittest.TestCase): def test_frame_resurrect(self): # A generator frame can be resurrected by a generator's finalization. def gen(): nonlocal frame try: yield finally: frame = sys._getframe() g = gen() wr = weakref.ref(g) next(g) del g support.gc_collect() self.assertIs(wr(), None) self.assertTrue(frame) del frame support.gc_collect() def test_refcycle(self): # A generator caught in a refcycle gets finalized anyway. old_garbage = gc.garbage[:] finalized = False def gen(): nonlocal finalized try: g = yield yield 1 finally: finalized = True g = gen() next(g) g.send(g) self.assertGreater(sys.getrefcount(g), 2) self.assertFalse(finalized) del g support.gc_collect() self.assertTrue(finalized) self.assertEqual(gc.garbage, old_garbage) def test_lambda_generator(self): # Issue #23192: Test that a lambda returning a generator behaves # like the equivalent function f = lambda: (yield 1) def g(): return (yield 1) # test 'yield from' f2 = lambda: (yield from g()) def g2(): return (yield from g()) f3 = lambda: (yield from f()) def g3(): return (yield from f()) for gen_fun in (f, g, f2, g2, f3, g3): gen = gen_fun() self.assertEqual(next(gen), 1) with self.assertRaises(StopIteration) as cm: gen.send(2) self.assertEqual(cm.exception.value, 2) class GeneratorTest(unittest.TestCase): def test_name(self): def func(): yield 1 # check generator names gen = func() self.assertEqual(gen.__name__, "func") self.assertEqual(gen.__qualname__, "GeneratorTest.test_name.<locals>.func") # modify generator names gen.__name__ = "name" gen.__qualname__ = "qualname" self.assertEqual(gen.__name__, "name") self.assertEqual(gen.__qualname__, "qualname") # generator names must be a string and cannot be deleted self.assertRaises(TypeError, setattr, gen, '__name__', 123) self.assertRaises(TypeError, setattr, gen, '__qualname__', 123) self.assertRaises(TypeError, delattr, gen, '__name__') self.assertRaises(TypeError, delattr, gen, '__qualname__') # modify names of the function creating the generator func.__qualname__ = "func_qualname" func.__name__ = "func_name" gen = func() self.assertEqual(gen.__name__, "func_name") self.assertEqual(gen.__qualname__, "func_qualname") # unnamed generator gen = (x for x in range(10)) self.assertEqual(gen.__name__, "<genexpr>") self.assertEqual(gen.__qualname__, "GeneratorTest.test_name.<locals>.<genexpr>") class ExceptionTest(unittest.TestCase): # Tests for the issue #23353: check that the currently handled exception # is correctly saved/restored in PyEval_EvalFrameEx(). def test_except_throw(self): def store_raise_exc_generator(): try: self.assertEqual(sys.exc_info()[0], None) yield except Exception as exc: # exception raised by gen.throw(exc) self.assertEqual(sys.exc_info()[0], ValueError) self.assertIsNone(exc.__context__) yield # ensure that the exception is not lost self.assertEqual(sys.exc_info()[0], ValueError) yield # we should be able to raise back the ValueError raise make = store_raise_exc_generator() next(make) try: raise ValueError() except Exception as exc: try: make.throw(exc) except Exception: pass next(make) with self.assertRaises(ValueError) as cm: next(make) self.assertIsNone(cm.exception.__context__) self.assertEqual(sys.exc_info(), (None, None, None)) def test_except_next(self): def gen(): self.assertEqual(sys.exc_info()[0], ValueError) yield "done" g = gen() try: raise ValueError except Exception: self.assertEqual(next(g), "done") self.assertEqual(sys.exc_info(), (None, None, None)) def test_except_gen_except(self): def gen(): try: self.assertEqual(sys.exc_info()[0], None) yield # we are called from "except ValueError:", TypeError must # inherit ValueError in its context raise TypeError() except TypeError as exc: self.assertEqual(sys.exc_info()[0], TypeError) self.assertEqual(type(exc.__context__), ValueError) # here we are still called from the "except ValueError:" self.assertEqual(sys.exc_info()[0], ValueError) yield self.assertIsNone(sys.exc_info()[0]) yield "done" g = gen() next(g) try: raise ValueError except Exception: next(g) self.assertEqual(next(g), "done") self.assertEqual(sys.exc_info(), (None, None, None)) def test_except_throw_exception_context(self): def gen(): try: try: self.assertEqual(sys.exc_info()[0], None) yield except ValueError: # we are called from "except ValueError:" self.assertEqual(sys.exc_info()[0], ValueError) raise TypeError() except Exception as exc: self.assertEqual(sys.exc_info()[0], TypeError) self.assertEqual(type(exc.__context__), ValueError) # we are still called from "except ValueError:" self.assertEqual(sys.exc_info()[0], ValueError) yield self.assertIsNone(sys.exc_info()[0]) yield "done" g = gen() next(g) try: raise ValueError except Exception as exc: g.throw(exc) self.assertEqual(next(g), "done") self.assertEqual(sys.exc_info(), (None, None, None)) def test_stopiteration_warning(self): # See also PEP 479. def gen(): raise StopIteration yield with self.assertRaises(StopIteration), \ self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): next(gen()) with self.assertRaisesRegex(PendingDeprecationWarning, "generator .* raised StopIteration"), \ warnings.catch_warnings(): warnings.simplefilter('error') next(gen()) def test_tutorial_stopiteration(self): # Raise StopIteration" stops the generator too: def f(): yield 1 raise StopIteration yield 2 # never reached g = f() self.assertEqual(next(g), 1) with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): with self.assertRaises(StopIteration): next(g) with self.assertRaises(StopIteration): # This time StopIteration isn't raised from the generator's body, # hence no warning. next(g) class YieldFromTests(unittest.TestCase): def test_generator_gi_yieldfrom(self): def a(): self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_RUNNING) self.assertIsNone(gen_b.gi_yieldfrom) yield self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_RUNNING) self.assertIsNone(gen_b.gi_yieldfrom) def b(): self.assertIsNone(gen_b.gi_yieldfrom) yield from a() self.assertIsNone(gen_b.gi_yieldfrom) yield self.assertIsNone(gen_b.gi_yieldfrom) gen_b = b() self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_CREATED) self.assertIsNone(gen_b.gi_yieldfrom) gen_b.send(None) self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_SUSPENDED) self.assertEqual(gen_b.gi_yieldfrom.gi_code.co_name, 'a') gen_b.send(None) self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_SUSPENDED) self.assertIsNone(gen_b.gi_yieldfrom) [] = gen_b # Exhaust generator self.assertEqual(inspect.getgeneratorstate(gen_b), inspect.GEN_CLOSED) self.assertIsNone(gen_b.gi_yieldfrom) tutorial_tests = """ Let's try a simple generator: >>> def f(): ... yield 1 ... yield 2 >>> for i in f(): ... print(i) 1 2 >>> g = f() >>> next(g) 1 >>> next(g) 2 "Falling off the end" stops the generator: >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in g StopIteration "return" also stops the generator: >>> def f(): ... yield 1 ... return ... yield 2 # never reached ... >>> g = f() >>> next(g) 1 >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 3, in f StopIteration >>> next(g) # once stopped, can't be resumed Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration However, "return" and StopIteration are not exactly equivalent: >>> def g1(): ... try: ... return ... except: ... yield 1 ... >>> list(g1()) [] >>> def g2(): ... try: ... raise StopIteration ... except: ... yield 42 >>> print(list(g2())) [42] This may be surprising at first: >>> def g3(): ... try: ... return ... finally: ... yield 1 ... >>> list(g3()) [1] Let's create an alternate range() function implemented as a generator: >>> def yrange(n): ... for i in range(n): ... yield i ... >>> list(yrange(5)) [0, 1, 2, 3, 4] Generators always return to the most recent caller: >>> def creator(): ... r = yrange(5) ... print("creator", next(r)) ... return r ... >>> def caller(): ... r = creator() ... for i in r: ... print("caller", i) ... >>> caller() creator 0 caller 1 caller 2 caller 3 caller 4 Generators can call other generators: >>> def zrange(n): ... for i in yrange(n): ... yield i ... >>> list(zrange(5)) [0, 1, 2, 3, 4] """ # The examples from PEP 255. pep_tests = """ Specification: Yield Restriction: A generator cannot be resumed while it is actively running: >>> def g(): ... i = next(me) ... yield i >>> me = g() >>> next(me) Traceback (most recent call last): ... File "<string>", line 2, in g ValueError: generator already executing Specification: Return Note that return isn't always equivalent to raising StopIteration: the difference lies in how enclosing try/except constructs are treated. For example, >>> def f1(): ... try: ... return ... except: ... yield 1 >>> print(list(f1())) [] because, as in any function, return simply exits, but >>> def f2(): ... try: ... raise StopIteration ... except: ... yield 42 >>> print(list(f2())) [42] because StopIteration is captured by a bare "except", as is any exception. Specification: Generators and Exception Propagation >>> def f(): ... return 1//0 >>> def g(): ... yield f() # the zero division exception propagates ... yield 42 # and we'll never get here >>> k = g() >>> next(k) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in g File "<stdin>", line 2, in f ZeroDivisionError: integer division or modulo by zero >>> next(k) # and the generator cannot be resumed Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration >>> Specification: Try/Except/Finally >>> def f(): ... try: ... yield 1 ... try: ... yield 2 ... 1//0 ... yield 3 # never get here ... except ZeroDivisionError: ... yield 4 ... yield 5 ... raise ... except: ... yield 6 ... yield 7 # the "raise" above stops this ... except: ... yield 8 ... yield 9 ... try: ... x = 12 ... finally: ... yield 10 ... yield 11 >>> print(list(f())) [1, 2, 4, 5, 8, 9, 10, 11] >>> Guido's binary tree example. >>> # A binary tree class. >>> class Tree: ... ... def __init__(self, label, left=None, right=None): ... self.label = label ... self.left = left ... self.right = right ... ... def __repr__(self, level=0, indent=" "): ... s = level*indent + repr(self.label) ... if self.left: ... s = s + "\\n" + self.left.__repr__(level+1, indent) ... if self.right: ... s = s + "\\n" + self.right.__repr__(level+1, indent) ... return s ... ... def __iter__(self): ... return inorder(self) >>> # Create a Tree from a list. >>> def tree(list): ... n = len(list) ... if n == 0: ... return [] ... i = n // 2 ... return Tree(list[i], tree(list[:i]), tree(list[i+1:])) >>> # Show it off: create a tree. >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") >>> # A recursive generator that generates Tree labels in in-order. >>> def inorder(t): ... if t: ... for x in inorder(t.left): ... yield x ... yield t.label ... for x in inorder(t.right): ... yield x >>> # Show it off: create a tree. >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") >>> # Print the nodes of the tree in in-order. >>> for x in t: ... print(' '+x, end='') A B C D E F G H I J K L M N O P Q R S T U V W X Y Z >>> # A non-recursive generator. >>> def inorder(node): ... stack = [] ... while node: ... while node.left: ... stack.append(node) ... node = node.left ... yield node.label ... while not node.right: ... try: ... node = stack.pop() ... except IndexError: ... return ... yield node.label ... node = node.right >>> # Exercise the non-recursive generator. >>> for x in t: ... print(' '+x, end='') A B C D E F G H I J K L M N O P Q R S T U V W X Y Z """ # Examples from Iterator-List and Python-Dev and c.l.py. email_tests = """ The difference between yielding None and returning it. >>> def g(): ... for i in range(3): ... yield None ... yield None ... return >>> list(g()) [None, None, None, None] Ensure that explicitly raising StopIteration acts like any other exception in try/except, not like a return. >>> def g(): ... yield 1 ... try: ... raise StopIteration ... except: ... yield 2 ... yield 3 >>> list(g()) [1, 2, 3] Next one was posted to c.l.py. >>> def gcomb(x, k): ... "Generate all combinations of k elements from list x." ... ... if k > len(x): ... return ... if k == 0: ... yield [] ... else: ... first, rest = x[0], x[1:] ... # A combination does or doesn't contain first. ... # If it does, the remainder is a k-1 comb of rest. ... for c in gcomb(rest, k-1): ... c.insert(0, first) ... yield c ... # If it doesn't contain first, it's a k comb of rest. ... for c in gcomb(rest, k): ... yield c >>> seq = list(range(1, 5)) >>> for k in range(len(seq) + 2): ... print("%d-combs of %s:" % (k, seq)) ... for c in gcomb(seq, k): ... print(" ", c) 0-combs of [1, 2, 3, 4]: [] 1-combs of [1, 2, 3, 4]: [1] [2] [3] [4] 2-combs of [1, 2, 3, 4]: [1, 2] [1, 3] [1, 4] [2, 3] [2, 4] [3, 4] 3-combs of [1, 2, 3, 4]: [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] 4-combs of [1, 2, 3, 4]: [1, 2, 3, 4] 5-combs of [1, 2, 3, 4]: From the Iterators list, about the types of these things. >>> def g(): ... yield 1 ... >>> type(g) <class 'function'> >>> i = g() >>> type(i) <class 'generator'> >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_yieldfrom', 'send', 'throw'] >>> from test.support import HAVE_DOCSTRINGS >>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).') Implement next(self). >>> iter(i) is i True >>> import types >>> isinstance(i, types.GeneratorType) True And more, added later. >>> i.gi_running 0 >>> type(i.gi_frame) <class 'frame'> >>> i.gi_running = 42 Traceback (most recent call last): ... AttributeError: readonly attribute >>> def g(): ... yield me.gi_running >>> me = g() >>> me.gi_running 0 >>> next(me) 1 >>> me.gi_running 0 A clever union-find implementation from c.l.py, due to David Eppstein. Sent: Friday, June 29, 2001 12:16 PM To: python-list@python.org Subject: Re: PEP 255: Simple Generators >>> class disjointSet: ... def __init__(self, name): ... self.name = name ... self.parent = None ... self.generator = self.generate() ... ... def generate(self): ... while not self.parent: ... yield self ... for x in self.parent.generator: ... yield x ... ... def find(self): ... return next(self.generator) ... ... def union(self, parent): ... if self.parent: ... raise ValueError("Sorry, I'm not a root!") ... self.parent = parent ... ... def __str__(self): ... return self.name >>> names = "ABCDEFGHIJKLM" >>> sets = [disjointSet(name) for name in names] >>> roots = sets[:] >>> import random >>> gen = random.Random(42) >>> while 1: ... for s in sets: ... print(" %s->%s" % (s, s.find()), end='') ... print() ... if len(roots) > 1: ... s1 = gen.choice(roots) ... roots.remove(s1) ... s2 = gen.choice(roots) ... s1.union(s2) ... print("merged", s1, "into", s2) ... else: ... break A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M merged K into B A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M merged A into F A->F B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M merged E into F A->F B->B C->C D->D E->F F->F G->G H->H I->I J->J K->B L->L M->M merged D into C A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->M merged M into C A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->C merged J into B A->F B->B C->C D->C E->F F->F G->G H->H I->I J->B K->B L->L M->C merged B into C A->F B->C C->C D->C E->F F->F G->G H->H I->I J->C K->C L->L M->C merged F into G A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->L M->C merged L into C A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->C M->C merged G into I A->I B->C C->C D->C E->I F->I G->I H->H I->I J->C K->C L->C M->C merged I into H A->H B->C C->C D->C E->H F->H G->H H->H I->H J->C K->C L->C M->C merged C into H A->H B->H C->H D->H E->H F->H G->H H->H I->H J->H K->H L->H M->H """ # Emacs turd ' # Fun tests (for sufficiently warped notions of "fun"). fun_tests = """ Build up to a recursive Sieve of Eratosthenes generator. >>> def firstn(g, n): ... return [next(g) for i in range(n)] >>> def intsfrom(i): ... while 1: ... yield i ... i += 1 >>> firstn(intsfrom(5), 7) [5, 6, 7, 8, 9, 10, 11] >>> def exclude_multiples(n, ints): ... for i in ints: ... if i % n: ... yield i >>> firstn(exclude_multiples(3, intsfrom(1)), 6) [1, 2, 4, 5, 7, 8] >>> def sieve(ints): ... prime = next(ints) ... yield prime ... not_divisible_by_prime = exclude_multiples(prime, ints) ... for p in sieve(not_divisible_by_prime): ... yield p >>> primes = sieve(intsfrom(2)) >>> firstn(primes, 20) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71] Another famous problem: generate all integers of the form 2**i * 3**j * 5**k in increasing order, where i,j,k >= 0. Trickier than it may look at first! Try writing it without generators, and correctly, and without generating 3 internal results for each result output. >>> def times(n, g): ... for i in g: ... yield n * i >>> firstn(times(10, intsfrom(1)), 10) [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> def merge(g, h): ... ng = next(g) ... nh = next(h) ... while 1: ... if ng < nh: ... yield ng ... ng = next(g) ... elif ng > nh: ... yield nh ... nh = next(h) ... else: ... yield ng ... ng = next(g) ... nh = next(h) The following works, but is doing a whale of a lot of redundant work -- it's not clear how to get the internal uses of m235 to share a single generator. Note that me_times2 (etc) each need to see every element in the result sequence. So this is an example where lazy lists are more natural (you can look at the head of a lazy list any number of times). >>> def m235(): ... yield 1 ... me_times2 = times(2, m235()) ... me_times3 = times(3, m235()) ... me_times5 = times(5, m235()) ... for i in merge(merge(me_times2, ... me_times3), ... me_times5): ... yield i Don't print "too many" of these -- the implementation above is extremely inefficient: each call of m235() leads to 3 recursive calls, and in turn each of those 3 more, and so on, and so on, until we've descended enough levels to satisfy the print stmts. Very odd: when I printed 5 lines of results below, this managed to screw up Win98's malloc in "the usual" way, i.e. the heap grew over 4Mb so Win98 started fragmenting address space, and it *looked* like a very slow leak. >>> result = m235() >>> for i in range(3): ... print(firstn(result, 15)) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] Heh. Here's one way to get a shared list, complete with an excruciating namespace renaming trick. The *pretty* part is that the times() and merge() functions can be reused as-is, because they only assume their stream arguments are iterable -- a LazyList is the same as a generator to times(). >>> class LazyList: ... def __init__(self, g): ... self.sofar = [] ... self.fetch = g.__next__ ... ... def __getitem__(self, i): ... sofar, fetch = self.sofar, self.fetch ... while i >= len(sofar): ... sofar.append(fetch()) ... return sofar[i] >>> def m235(): ... yield 1 ... # Gack: m235 below actually refers to a LazyList. ... me_times2 = times(2, m235) ... me_times3 = times(3, m235) ... me_times5 = times(5, m235) ... for i in merge(merge(me_times2, ... me_times3), ... me_times5): ... yield i Print as many of these as you like -- *this* implementation is memory- efficient. >>> m235 = LazyList(m235()) >>> for i in range(5): ... print([m235[j] for j in range(15*i, 15*(i+1))]) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384] [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675] Ye olde Fibonacci generator, LazyList style. >>> def fibgen(a, b): ... ... def sum(g, h): ... while 1: ... yield next(g) + next(h) ... ... def tail(g): ... next(g) # throw first away ... for x in g: ... yield x ... ... yield a ... yield b ... for s in sum(iter(fib), ... tail(iter(fib))): ... yield s >>> fib = LazyList(fibgen(1, 2)) >>> firstn(iter(fib), 17) [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] Running after your tail with itertools.tee (new in version 2.4) The algorithms "m235" (Hamming) and Fibonacci presented above are both examples of a whole family of FP (functional programming) algorithms where a function produces and returns a list while the production algorithm suppose the list as already produced by recursively calling itself. For these algorithms to work, they must: - produce at least a first element without presupposing the existence of the rest of the list - produce their elements in a lazy manner To work efficiently, the beginning of the list must not be recomputed over and over again. This is ensured in most FP languages as a built-in feature. In python, we have to explicitly maintain a list of already computed results and abandon genuine recursivity. This is what had been attempted above with the LazyList class. One problem with that class is that it keeps a list of all of the generated results and therefore continually grows. This partially defeats the goal of the generator concept, viz. produce the results only as needed instead of producing them all and thereby wasting memory. Thanks to itertools.tee, it is now clear "how to get the internal uses of m235 to share a single generator". >>> from itertools import tee >>> def m235(): ... def _m235(): ... yield 1 ... for n in merge(times(2, m2), ... merge(times(3, m3), ... times(5, m5))): ... yield n ... m1 = _m235() ... m2, m3, m5, mRes = tee(m1, 4) ... return mRes >>> it = m235() >>> for i in range(5): ... print(firstn(it, 15)) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384] [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675] The "tee" function does just what we want. It internally keeps a generated result for as long as it has not been "consumed" from all of the duplicated iterators, whereupon it is deleted. You can therefore print the hamming sequence during hours without increasing memory usage, or very little. The beauty of it is that recursive running-after-their-tail FP algorithms are quite straightforwardly expressed with this Python idiom. Ye olde Fibonacci generator, tee style. >>> def fib(): ... ... def _isum(g, h): ... while 1: ... yield next(g) + next(h) ... ... def _fib(): ... yield 1 ... yield 2 ... next(fibTail) # throw first away ... for res in _isum(fibHead, fibTail): ... yield res ... ... realfib = _fib() ... fibHead, fibTail, fibRes = tee(realfib, 3) ... return fibRes >>> firstn(fib(), 17) [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] """ # syntax_tests mostly provokes SyntaxErrors. Also fiddling with #if 0 # hackery. syntax_tests = """ These are fine: >>> def f(): ... yield 1 ... return >>> def f(): ... try: ... yield 1 ... finally: ... pass >>> def f(): ... try: ... try: ... 1//0 ... except ZeroDivisionError: ... yield 666 ... except: ... pass ... finally: ... pass >>> def f(): ... try: ... try: ... yield 12 ... 1//0 ... except ZeroDivisionError: ... yield 666 ... except: ... try: ... x = 12 ... finally: ... yield 12 ... except: ... return >>> list(f()) [12, 666] >>> def f(): ... yield >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... yield >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... yield 1 >>> type(f()) <class 'generator'> >>> def f(): ... if "": ... yield None >>> type(f()) <class 'generator'> >>> def f(): ... return ... try: ... if x==4: ... pass ... elif 0: ... try: ... 1//0 ... except SyntaxError: ... pass ... else: ... if 0: ... while 12: ... x += 1 ... yield 2 # don't blink ... f(a, b, c, d, e) ... else: ... pass ... except: ... x = 1 ... return >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... def g(): ... yield 1 ... >>> type(f()) <class 'NoneType'> >>> def f(): ... if 0: ... class C: ... def __init__(self): ... yield 1 ... def f(self): ... yield 2 >>> type(f()) <class 'NoneType'> >>> def f(): ... if 0: ... return ... if 0: ... yield 2 >>> type(f()) <class 'generator'> This one caused a crash (see SF bug 567538): >>> def f(): ... for i in range(3): ... try: ... continue ... finally: ... yield i ... >>> g = f() >>> print(next(g)) 0 >>> print(next(g)) 1 >>> print(next(g)) 2 >>> print(next(g)) Traceback (most recent call last): StopIteration Test the gi_code attribute >>> def f(): ... yield 5 ... >>> g = f() >>> g.gi_code is f.__code__ True >>> next(g) 5 >>> next(g) Traceback (most recent call last): StopIteration >>> g.gi_code is f.__code__ True Test the __name__ attribute and the repr() >>> def f(): ... yield 5 ... >>> g = f() >>> g.__name__ 'f' >>> repr(g) # doctest: +ELLIPSIS '<generator object f at ...>' Lambdas shouldn't have their usual return behavior. >>> x = lambda: (yield 1) >>> list(x()) [1] >>> x = lambda: ((yield 1), (yield 2)) >>> list(x()) [1, 2] """ # conjoin is a simple backtracking generator, named in honor of Icon's # "conjunction" control structure. Pass a list of no-argument functions # that return iterable objects. Easiest to explain by example: assume the # function list [x, y, z] is passed. Then conjoin acts like: # # def g(): # values = [None] * 3 # for values[0] in x(): # for values[1] in y(): # for values[2] in z(): # yield values # # So some 3-lists of values *may* be generated, each time we successfully # get into the innermost loop. If an iterator fails (is exhausted) before # then, it "backtracks" to get the next value from the nearest enclosing # iterator (the one "to the left"), and starts all over again at the next # slot (pumps a fresh iterator). Of course this is most useful when the # iterators have side-effects, so that which values *can* be generated at # each slot depend on the values iterated at previous slots. def simple_conjoin(gs): values = [None] * len(gs) def gen(i): if i >= len(gs): yield values else: for values[i] in gs[i](): for x in gen(i+1): yield x for x in gen(0): yield x # That works fine, but recursing a level and checking i against len(gs) for # each item produced is inefficient. By doing manual loop unrolling across # generator boundaries, it's possible to eliminate most of that overhead. # This isn't worth the bother *in general* for generators, but conjoin() is # a core building block for some CPU-intensive generator applications. def conjoin(gs): n = len(gs) values = [None] * n # Do one loop nest at time recursively, until the # of loop nests # remaining is divisible by 3. def gen(i): if i >= n: yield values elif (n-i) % 3: ip1 = i+1 for values[i] in gs[i](): for x in gen(ip1): yield x else: for x in _gen3(i): yield x # Do three loop nests at a time, recursing only if at least three more # remain. Don't call directly: this is an internal optimization for # gen's use. def _gen3(i): assert i < n and (n-i) % 3 == 0 ip1, ip2, ip3 = i+1, i+2, i+3 g, g1, g2 = gs[i : ip3] if ip3 >= n: # These are the last three, so we can yield values directly. for values[i] in g(): for values[ip1] in g1(): for values[ip2] in g2(): yield values else: # At least 6 loop nests remain; peel off 3 and recurse for the # rest. for values[i] in g(): for values[ip1] in g1(): for values[ip2] in g2(): for x in _gen3(ip3): yield x for x in gen(0): yield x # And one more approach: For backtracking apps like the Knight's Tour # solver below, the number of backtracking levels can be enormous (one # level per square, for the Knight's Tour, so that e.g. a 100x100 board # needs 10,000 levels). In such cases Python is likely to run out of # stack space due to recursion. So here's a recursion-free version of # conjoin too. # NOTE WELL: This allows large problems to be solved with only trivial # demands on stack space. Without explicitly resumable generators, this is # much harder to achieve. OTOH, this is much slower (up to a factor of 2) # than the fancy unrolled recursive conjoin. def flat_conjoin(gs): # rename to conjoin to run tests with this instead n = len(gs) values = [None] * n iters = [None] * n _StopIteration = StopIteration # make local because caught a *lot* i = 0 while 1: # Descend. try: while i < n: it = iters[i] = gs[i]().__next__ values[i] = it() i += 1 except _StopIteration: pass else: assert i == n yield values # Backtrack until an older iterator can be resumed. i -= 1 while i >= 0: try: values[i] = iters[i]() # Success! Start fresh at next level. i += 1 break except _StopIteration: # Continue backtracking. i -= 1 else: assert i < 0 break # A conjoin-based N-Queens solver. class Queens: def __init__(self, n): self.n = n rangen = range(n) # Assign a unique int to each column and diagonal. # columns: n of those, range(n). # NW-SE diagonals: 2n-1 of these, i-j unique and invariant along # each, smallest i-j is 0-(n-1) = 1-n, so add n-1 to shift to 0- # based. # NE-SW diagonals: 2n-1 of these, i+j unique and invariant along # each, smallest i+j is 0, largest is 2n-2. # For each square, compute a bit vector of the columns and # diagonals it covers, and for each row compute a function that # generates the possiblities for the columns in that row. self.rowgenerators = [] for i in rangen: rowuses = [(1 << j) | # column ordinal (1 << (n + i-j + n-1)) | # NW-SE ordinal (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal for j in rangen] def rowgen(rowuses=rowuses): for j in rangen: uses = rowuses[j] if uses & self.used == 0: self.used |= uses yield j self.used &= ~uses self.rowgenerators.append(rowgen) # Generate solutions. def solve(self): self.used = 0 for row2col in conjoin(self.rowgenerators): yield row2col def printsolution(self, row2col): n = self.n assert n == len(row2col) sep = "+" + "-+" * n print(sep) for i in range(n): squares = [" " for j in range(n)] squares[row2col[i]] = "Q" print("|" + "|".join(squares) + "|") print(sep) # A conjoin-based Knight's Tour solver. This is pretty sophisticated # (e.g., when used with flat_conjoin above, and passing hard=1 to the # constructor, a 200x200 Knight's Tour was found quickly -- note that we're # creating 10s of thousands of generators then!), and is lengthy. class Knights: def __init__(self, m, n, hard=0): self.m, self.n = m, n # solve() will set up succs[i] to be a list of square #i's # successors. succs = self.succs = [] # Remove i0 from each of its successor's successor lists, i.e. # successors can't go back to i0 again. Return 0 if we can # detect this makes a solution impossible, else return 1. def remove_from_successors(i0, len=len): # If we remove all exits from a free square, we're dead: # even if we move to it next, we can't leave it again. # If we create a square with one exit, we must visit it next; # else somebody else will have to visit it, and since there's # only one adjacent, there won't be a way to leave it again. # Finelly, if we create more than one free square with a # single exit, we can only move to one of them next, leaving # the other one a dead end. ne0 = ne1 = 0 for i in succs[i0]: s = succs[i] s.remove(i0) e = len(s) if e == 0: ne0 += 1 elif e == 1: ne1 += 1 return ne0 == 0 and ne1 < 2 # Put i0 back in each of its successor's successor lists. def add_to_successors(i0): for i in succs[i0]: succs[i].append(i0) # Generate the first move. def first(): if m < 1 or n < 1: return # Since we're looking for a cycle, it doesn't matter where we # start. Starting in a corner makes the 2nd move easy. corner = self.coords2index(0, 0) remove_from_successors(corner) self.lastij = corner yield corner add_to_successors(corner) # Generate the second moves. def second(): corner = self.coords2index(0, 0) assert self.lastij == corner # i.e., we started in the corner if m < 3 or n < 3: return assert len(succs[corner]) == 2 assert self.coords2index(1, 2) in succs[corner] assert self.coords2index(2, 1) in succs[corner] # Only two choices. Whichever we pick, the other must be the # square picked on move m*n, as it's the only way to get back # to (0, 0). Save its index in self.final so that moves before # the last know it must be kept free. for i, j in (1, 2), (2, 1): this = self.coords2index(i, j) final = self.coords2index(3-i, 3-j) self.final = final remove_from_successors(this) succs[final].append(corner) self.lastij = this yield this succs[final].remove(corner) add_to_successors(this) # Generate moves 3 thru m*n-1. def advance(len=len): # If some successor has only one exit, must take it. # Else favor successors with fewer exits. candidates = [] for i in succs[self.lastij]: e = len(succs[i]) assert e > 0, "else remove_from_successors() pruning flawed" if e == 1: candidates = [(e, i)] break candidates.append((e, i)) else: candidates.sort() for e, i in candidates: if i != self.final: if remove_from_successors(i): self.lastij = i yield i add_to_successors(i) # Generate moves 3 thru m*n-1. Alternative version using a # stronger (but more expensive) heuristic to order successors. # Since the # of backtracking levels is m*n, a poor move early on # can take eons to undo. Smallest square board for which this # matters a lot is 52x52. def advance_hard(vmid=(m-1)/2.0, hmid=(n-1)/2.0, len=len): # If some successor has only one exit, must take it. # Else favor successors with fewer exits. # Break ties via max distance from board centerpoint (favor # corners and edges whenever possible). candidates = [] for i in succs[self.lastij]: e = len(succs[i]) assert e > 0, "else remove_from_successors() pruning flawed" if e == 1: candidates = [(e, 0, i)] break i1, j1 = self.index2coords(i) d = (i1 - vmid)**2 + (j1 - hmid)**2 candidates.append((e, -d, i)) else: candidates.sort() for e, d, i in candidates: if i != self.final: if remove_from_successors(i): self.lastij = i yield i add_to_successors(i) # Generate the last move. def last(): assert self.final in succs[self.lastij] yield self.final if m*n < 4: self.squaregenerators = [first] else: self.squaregenerators = [first, second] + \ [hard and advance_hard or advance] * (m*n - 3) + \ [last] def coords2index(self, i, j): assert 0 <= i < self.m assert 0 <= j < self.n return i * self.n + j def index2coords(self, index): assert 0 <= index < self.m * self.n return divmod(index, self.n) def _init_board(self): succs = self.succs del succs[:] m, n = self.m, self.n c2i = self.coords2index offsets = [( 1, 2), ( 2, 1), ( 2, -1), ( 1, -2), (-1, -2), (-2, -1), (-2, 1), (-1, 2)] rangen = range(n) for i in range(m): for j in rangen: s = [c2i(i+io, j+jo) for io, jo in offsets if 0 <= i+io < m and 0 <= j+jo < n] succs.append(s) # Generate solutions. def solve(self): self._init_board() for x in conjoin(self.squaregenerators): yield x def printsolution(self, x): m, n = self.m, self.n assert len(x) == m*n w = len(str(m*n)) format = "%" + str(w) + "d" squares = [[None] * n for i in range(m)] k = 1 for i in x: i1, j1 = self.index2coords(i) squares[i1][j1] = format % k k += 1 sep = "+" + ("-" * w + "+") * n print(sep) for i in range(m): row = squares[i] print("|" + "|".join(row) + "|") print(sep) conjoin_tests = """ Generate the 3-bit binary numbers in order. This illustrates dumbest- possible use of conjoin, just to generate the full cross-product. >>> for c in conjoin([lambda: iter((0, 1))] * 3): ... print(c) [0, 0, 0] [0, 0, 1] [0, 1, 0] [0, 1, 1] [1, 0, 0] [1, 0, 1] [1, 1, 0] [1, 1, 1] For efficiency in typical backtracking apps, conjoin() yields the same list object each time. So if you want to save away a full account of its generated sequence, you need to copy its results. >>> def gencopy(iterator): ... for x in iterator: ... yield x[:] >>> for n in range(10): ... all = list(gencopy(conjoin([lambda: iter((0, 1))] * n))) ... print(n, len(all), all[0] == [0] * n, all[-1] == [1] * n) 0 1 True True 1 2 True True 2 4 True True 3 8 True True 4 16 True True 5 32 True True 6 64 True True 7 128 True True 8 256 True True 9 512 True True And run an 8-queens solver. >>> q = Queens(8) >>> LIMIT = 2 >>> count = 0 >>> for row2col in q.solve(): ... count += 1 ... if count <= LIMIT: ... print("Solution", count) ... q.printsolution(row2col) Solution 1 +-+-+-+-+-+-+-+-+ |Q| | | | | | | | +-+-+-+-+-+-+-+-+ | | | | |Q| | | | +-+-+-+-+-+-+-+-+ | | | | | | | |Q| +-+-+-+-+-+-+-+-+ | | | | | |Q| | | +-+-+-+-+-+-+-+-+ | | |Q| | | | | | +-+-+-+-+-+-+-+-+ | | | | | | |Q| | +-+-+-+-+-+-+-+-+ | |Q| | | | | | | +-+-+-+-+-+-+-+-+ | | | |Q| | | | | +-+-+-+-+-+-+-+-+ Solution 2 +-+-+-+-+-+-+-+-+ |Q| | | | | | | | +-+-+-+-+-+-+-+-+ | | | | | |Q| | | +-+-+-+-+-+-+-+-+ | | | | | | | |Q| +-+-+-+-+-+-+-+-+ | | |Q| | | | | | +-+-+-+-+-+-+-+-+ | | | | | | |Q| | +-+-+-+-+-+-+-+-+ | | | |Q| | | | | +-+-+-+-+-+-+-+-+ | |Q| | | | | | | +-+-+-+-+-+-+-+-+ | | | | |Q| | | | +-+-+-+-+-+-+-+-+ >>> print(count, "solutions in all.") 92 solutions in all. And run a Knight's Tour on a 10x10 board. Note that there are about 20,000 solutions even on a 6x6 board, so don't dare run this to exhaustion. >>> k = Knights(10, 10) >>> LIMIT = 2 >>> count = 0 >>> for x in k.solve(): ... count += 1 ... if count <= LIMIT: ... print("Solution", count) ... k.printsolution(x) ... else: ... break Solution 1 +---+---+---+---+---+---+---+---+---+---+ | 1| 58| 27| 34| 3| 40| 29| 10| 5| 8| +---+---+---+---+---+---+---+---+---+---+ | 26| 35| 2| 57| 28| 33| 4| 7| 30| 11| +---+---+---+---+---+---+---+---+---+---+ | 59|100| 73| 36| 41| 56| 39| 32| 9| 6| +---+---+---+---+---+---+---+---+---+---+ | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31| +---+---+---+---+---+---+---+---+---+---+ | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50| +---+---+---+---+---+---+---+---+---+---+ | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13| +---+---+---+---+---+---+---+---+---+---+ | 87| 98| 91| 80| 77| 84| 53| 46| 65| 44| +---+---+---+---+---+---+---+---+---+---+ | 90| 23| 88| 95| 70| 79| 68| 83| 14| 17| +---+---+---+---+---+---+---+---+---+---+ | 97| 92| 21| 78| 81| 94| 19| 16| 45| 66| +---+---+---+---+---+---+---+---+---+---+ | 22| 89| 96| 93| 20| 69| 82| 67| 18| 15| +---+---+---+---+---+---+---+---+---+---+ Solution 2 +---+---+---+---+---+---+---+---+---+---+ | 1| 58| 27| 34| 3| 40| 29| 10| 5| 8| +---+---+---+---+---+---+---+---+---+---+ | 26| 35| 2| 57| 28| 33| 4| 7| 30| 11| +---+---+---+---+---+---+---+---+---+---+ | 59|100| 73| 36| 41| 56| 39| 32| 9| 6| +---+---+---+---+---+---+---+---+---+---+ | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31| +---+---+---+---+---+---+---+---+---+---+ | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50| +---+---+---+---+---+---+---+---+---+---+ | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13| +---+---+---+---+---+---+---+---+---+---+ | 87| 98| 89| 80| 77| 84| 53| 46| 65| 44| +---+---+---+---+---+---+---+---+---+---+ | 90| 23| 92| 95| 70| 79| 68| 83| 14| 17| +---+---+---+---+---+---+---+---+---+---+ | 97| 88| 21| 78| 81| 94| 19| 16| 45| 66| +---+---+---+---+---+---+---+---+---+---+ | 22| 91| 96| 93| 20| 69| 82| 67| 18| 15| +---+---+---+---+---+---+---+---+---+---+ """ weakref_tests = """\ Generators are weakly referencable: >>> import weakref >>> def gen(): ... yield 'foo!' ... >>> wr = weakref.ref(gen) >>> wr() is gen True >>> p = weakref.proxy(gen) Generator-iterators are weakly referencable as well: >>> gi = gen() >>> wr = weakref.ref(gi) >>> wr() is gi True >>> p = weakref.proxy(gi) >>> list(p) ['foo!'] """ coroutine_tests = """\ Sending a value into a started generator: >>> def f(): ... print((yield 1)) ... yield 2 >>> g = f() >>> next(g) 1 >>> g.send(42) 42 2 Sending a value into a new generator produces a TypeError: >>> f().send("foo") Traceback (most recent call last): ... TypeError: can't send non-None value to a just-started generator Yield by itself yields None: >>> def f(): yield >>> list(f()) [None] An obscene abuse of a yield expression within a generator expression: >>> list((yield 21) for i in range(4)) [21, None, 21, None, 21, None, 21, None] And a more sane, but still weird usage: >>> def f(): list(i for i in [(yield 26)]) >>> type(f()) <class 'generator'> A yield expression with augmented assignment. >>> def coroutine(seq): ... count = 0 ... while count < 200: ... count += yield ... seq.append(count) >>> seq = [] >>> c = coroutine(seq) >>> next(c) >>> print(seq) [] >>> c.send(10) >>> print(seq) [10] >>> c.send(10) >>> print(seq) [10, 20] >>> c.send(10) >>> print(seq) [10, 20, 30] Check some syntax errors for yield expressions: >>> f=lambda: (yield 1),(yield 2) Traceback (most recent call last): ... SyntaxError: 'yield' outside function >>> def f(): x = yield = y Traceback (most recent call last): ... SyntaxError: assignment to yield expression not possible >>> def f(): (yield bar) = y Traceback (most recent call last): ... SyntaxError: can't assign to yield expression >>> def f(): (yield bar) += y Traceback (most recent call last): ... SyntaxError: can't assign to yield expression Now check some throw() conditions: >>> def f(): ... while True: ... try: ... print((yield)) ... except ValueError as v: ... print("caught ValueError (%s)" % (v)) >>> import sys >>> g = f() >>> next(g) >>> g.throw(ValueError) # type only caught ValueError () >>> g.throw(ValueError("xyz")) # value only caught ValueError (xyz) >>> g.throw(ValueError, ValueError(1)) # value+matching type caught ValueError (1) >>> g.throw(ValueError, TypeError(1)) # mismatched type, rewrapped caught ValueError (1) >>> g.throw(ValueError, ValueError(1), None) # explicit None traceback caught ValueError (1) >>> g.throw(ValueError(1), "foo") # bad args Traceback (most recent call last): ... TypeError: instance exception may not have a separate value >>> g.throw(ValueError, "foo", 23) # bad args Traceback (most recent call last): ... TypeError: throw() third argument must be a traceback object >>> g.throw("abc") Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not str >>> g.throw(0) Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not int >>> g.throw(list) Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not type >>> def throw(g,exc): ... try: ... raise exc ... except: ... g.throw(*sys.exc_info()) >>> throw(g,ValueError) # do it with traceback included caught ValueError () >>> g.send(1) 1 >>> throw(g,TypeError) # terminate the generator Traceback (most recent call last): ... TypeError >>> print(g.gi_frame) None >>> g.send(2) Traceback (most recent call last): ... StopIteration >>> g.throw(ValueError,6) # throw on closed generator Traceback (most recent call last): ... ValueError: 6 >>> f().throw(ValueError,7) # throw on just-opened generator Traceback (most recent call last): ... ValueError: 7 Plain "raise" inside a generator should preserve the traceback (#13188). The traceback should have 3 levels: - g.throw() - f() - 1/0 >>> def f(): ... try: ... yield ... except: ... raise >>> g = f() >>> try: ... 1/0 ... except ZeroDivisionError as v: ... try: ... g.throw(v) ... except Exception as w: ... tb = w.__traceback__ >>> levels = 0 >>> while tb: ... levels += 1 ... tb = tb.tb_next >>> levels 3 Now let's try closing a generator: >>> def f(): ... try: yield ... except GeneratorExit: ... print("exiting") >>> g = f() >>> next(g) >>> g.close() exiting >>> g.close() # should be no-op now >>> f().close() # close on just-opened generator should be fine >>> def f(): yield # an even simpler generator >>> f().close() # close before opening >>> g = f() >>> next(g) >>> g.close() # close normally And finalization: >>> def f(): ... try: yield ... finally: ... print("exiting") >>> g = f() >>> next(g) >>> del g exiting GeneratorExit is not caught by except Exception: >>> def f(): ... try: yield ... except Exception: ... print('except') ... finally: ... print('finally') >>> g = f() >>> next(g) >>> del g finally Now let's try some ill-behaved generators: >>> def f(): ... try: yield ... except GeneratorExit: ... yield "foo!" >>> g = f() >>> next(g) >>> g.close() Traceback (most recent call last): ... RuntimeError: generator ignored GeneratorExit >>> g.close() Our ill-behaved code should be invoked during GC: >>> import sys, io >>> old, sys.stderr = sys.stderr, io.StringIO() >>> g = f() >>> next(g) >>> del g >>> "RuntimeError: generator ignored GeneratorExit" in sys.stderr.getvalue() True >>> sys.stderr = old And errors thrown during closing should propagate: >>> def f(): ... try: yield ... except GeneratorExit: ... raise TypeError("fie!") >>> g = f() >>> next(g) >>> g.close() Traceback (most recent call last): ... TypeError: fie! Ensure that various yield expression constructs make their enclosing function a generator: >>> def f(): x += yield >>> type(f()) <class 'generator'> >>> def f(): x = yield >>> type(f()) <class 'generator'> >>> def f(): lambda x=(yield): 1 >>> type(f()) <class 'generator'> >>> def f(): x=(i for i in (yield) if (yield)) >>> type(f()) <class 'generator'> >>> def f(d): d[(yield "a")] = d[(yield "b")] = 27 >>> data = [1,2] >>> g = f(data) >>> type(g) <class 'generator'> >>> g.send(None) 'a' >>> data [1, 2] >>> g.send(0) 'b' >>> data [27, 2] >>> try: g.send(1) ... except StopIteration: pass >>> data [27, 27] """ refleaks_tests = """ Prior to adding cycle-GC support to itertools.tee, this code would leak references. We add it to the standard suite so the routine refleak-tests would trigger if it starts being uncleanable again. >>> import itertools >>> def leak(): ... class gen: ... def __iter__(self): ... return self ... def __next__(self): ... return self.item ... g = gen() ... head, tail = itertools.tee(g) ... g.item = head ... return head >>> it = leak() Make sure to also test the involvement of the tee-internal teedataobject, which stores returned items. >>> item = next(it) This test leaked at one point due to generator finalization/destruction. It was copied from Lib/test/leakers/test_generator_cycle.py before the file was removed. >>> def leak(): ... def gen(): ... while True: ... yield g ... g = gen() >>> leak() This test isn't really generator related, but rather exception-in-cleanup related. The coroutine tests (above) just happen to cause an exception in the generator's __del__ (tp_del) method. We can also test for this explicitly, without generators. We do have to redirect stderr to avoid printing warnings and to doublecheck that we actually tested what we wanted to test. >>> import sys, io >>> old = sys.stderr >>> try: ... sys.stderr = io.StringIO() ... class Leaker: ... def __del__(self): ... def invoke(message): ... raise RuntimeError(message) ... invoke("test") ... ... l = Leaker() ... del l ... err = sys.stderr.getvalue().strip() ... "Exception ignored in" in err ... "RuntimeError: test" in err ... "Traceback" in err ... "in invoke" in err ... finally: ... sys.stderr = old True True True True These refleak tests should perhaps be in a testfile of their own, test_generators just happened to be the test that drew these out. """ __test__ = {"tut": tutorial_tests, "pep": pep_tests, "email": email_tests, "fun": fun_tests, "syntax": syntax_tests, "conjoin": conjoin_tests, "weakref": weakref_tests, "coroutine": coroutine_tests, "refleaks": refleaks_tests, } # Magic test name that regrtest.py invokes *after* importing this module. # This worms around a bootstrap problem. # Note that doctest and regrtest both look in sys.argv for a "-v" argument, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): from test import support, test_generators support.run_unittest(__name__) support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": test_main(1)
MalloyPower/parsing-python
front-end/testsuite-python-lib/Python-3.5.0/Lib/test/test_generators.py
Python
mit
58,546
[ "VisIt" ]
3adbe727fcb5dc81ed747ec17dcba8c0bcdf39ff8b5c830cb8078e246e822e75
""" SWORDv2 API implementation for SSS This provides an implenentation of sss.core.SwordServer and related support classes which implements the features that are used by this module. """ from sss.core import SwordServer, ServiceDocument, SDCollection, SwordError, Authenticator, Auth, DepositResponse, EntryDocument, Statement, MediaResourceResponse from sss.spec import Errors from flask import url_for from octopus.modules.jper import client, models from octopus.core import app class JperAuth(Auth): """ Implementation of the sss.core.Auth class, which represents the authentication information (username, password, on-behalf-of user). """ def __init__(self, username=None, on_behalf_of=None, password=None): super(JperAuth, self).__init__(username=username, on_behalf_of=on_behalf_of) self.password = password class JperAuthenticator(Authenticator): """ Implementation of the sss.core.Authenticator class, which provides a hook for basic authentication to be implemented """ def __init__(self, config): super(JperAuthenticator, self).__init__(config) def basic_authenticate(self, username, password, obo): """ Basic authenticate the user. Though in reality this does nothing. Since the actual authentication will be done at JPER rather than here, all we need to do is create a JperAuth object and let that service bounce the response if the creds are wrong :param username: the username :param password: the password :param obo: not used - here for method sig compliance on superclass :return: a JperAuth object representing these """ # we don't even attempt to auth the user, just let the # JPER API do that app.logger.debug(u"Request received for Basic Auth on Username:{x} - credentials to be forwarded to JPER, not checked here".format(x=username)) return JperAuth(username, obo, password) class JperSword(SwordServer): """ Implementation of the sss.core.SwordServer which provides implementations only for the methods supported by JPER """ def __init__(self, config, auth): super(JperSword, self).__init__(config, auth) # create a URIManager for us to use self.um = URIManager(self.configuration) # instance of the jper client to communicate via self.jper = client.JPER(api_key=self.auth_credentials.password) # a place to cache the notes we retrieve from the server self.notes = {} ############################################## ## Methods required by the JPER integration def container_exists(self, path): """ Does the url path provided refer to a notification that already exists? Note that this queries the JPER API and caches a copy of the notification :param path: url path (e.g. the notification id) :return: True if the notification exists, False if not """ app.logger.info(u"Request received to check existence of Notification:{x}".format(x=path)) return self._cache_notification(path) def media_resource_exists(self, path): """ Does the media resource (content file) as referenced by the url path exist Note that this queries the JPER API and caches a copy of the notification :param path: url path for the notification content file :return: True if the file exists, False if not """ app.logger.info(u"Request received to check existence of Media Resource for Notification:{x}".format(x=path)) cached = self._cache_notification(path) if not cached: app.logger.info(u"Unable to retrieve and cache Notification:{x}".format(x=path)) return False # get the note from the cache note = self.notes[path] # a note has a media resource if there is a content link associated with it packs = note.get_urls(type="package") if len(packs) == 0: app.logger.info(u"No Media Resource available for Notification:{x}".format(x=path)) else: app.logger.info(u"One or more Media Resources found for Notification:{x}".format(x=path)) return len(packs) > 0 def service_document(self, path=None): """ Construct the Service Document for JPER. This takes the set of collections that are in the store, and places them in an Atom Service document as the individual entries This will provide two collections for deposit: one for validation requests and the other for create requests. :param path: url path sent to the server (for supporting sub-service documents, which we don't in this implementation) :return: serialised service document """ app.logger.info(u"Request received for SWORD Service Document") service = ServiceDocument(version=self.configuration.sword_version, max_upload_size=self.configuration.max_upload_size) # Our service document always consists of exactly 2 collections - one for validation # and the other for actual deposit accept = self.configuration.app_accept multipart_accept = self.configuration.multipart_accept accept_package = self.configuration.sword_accept_package validate = SDCollection( href=self.um.col_uri("validate"), title="Validate", accept=accept, multipart_accept=multipart_accept, description="Deposit here to validate the format of your notification files", accept_package=accept_package, collection_policy="This collection will take any deposit package intended for the Router", mediation=self.configuration.mediation, treatment="Packages sent here will be validated, and you will receive an error document or a deposit receipt. " + "The deposit will not subsequently be stored, so you will not be able to retrieve it again afterwards.", sub_service=[] ) notify = SDCollection( href=self.um.col_uri("notify"), title="Notify", accept=accept, multipart_accept=multipart_accept, description="Deposit here to deliver a publication event notification", accept_package=accept_package, collection_policy="This collection will take any deposit package intended for the Router", mediation=self.configuration.mediation, treatment="Packages sent here will be analysed for metadata suitable for routing to appropriate repository systems, " + "and then delivered onward.", sub_service=[] ) service.add_workspace("JPER", [validate, notify]) # serialise and return return service.serialise() def deposit_new(self, path, deposit): """ Take the supplied deposit and treat it as a new container with content to be created in the specified collection path :param path: the ID of the collection to be deposited into :param deposit: the DepositRequest object to be processed :return: a DepositResponse object which will contain the Deposit Receipt or a SWORD Error """ app.logger.info(u"Request received to deposit new notification to Location:{x}".format(x=path)) # make a notification that we can use to go along with the deposit # it doesn't need to contain anything notification = models.IncomingNotification() notification.packaging_format = deposit.packaging # instance of the jper client to communicate via jper = client.JPER(api_key=deposit.auth.password) # the deposit could be on the validate or the notify endpoint receipt = None loc = None accepted = False create = False if path == "validate": try: jper.validate(notification, file_handle=deposit.content_file) except client.JPERAuthException as e: app.logger.debug(u"User provided invalid authentication credentials for JPER") raise SwordError(status=401, empty=True) except client.ValidationException as e: app.logger.debug("Validation failed for user's notification") raise SwordError(error_uri=Errors.bad_request, msg=e.message, author="JPER", treatment="validation failed") app.logger.debug("Validation succeeded on user's notification") accepted = True elif path == "notify": try: id, loc = jper.create_notification(notification, file_handle=deposit.content_file) receipt = self._make_receipt(id, deposit.packaging, "Notification has been accepted for routing") except client.JPERAuthException as e: app.logger.debug(u"User provided invalid authentication credentials for JPER") raise SwordError(status=401, empty=True) except client.ValidationException as e: app.logger.debug("Validation failed for user's notification") raise SwordError(error_uri=Errors.bad_request, msg=e.message, author="JPER", treatment="validation failed") app.logger.debug("Create succeeded on user's notification") create = True else: app.logger.debug(u"Create request was not made to a valid endpoint") raise SwordError(status=404, empty=True) # finally, assemble the deposit response and return dr = DepositResponse() if receipt is not None: dr.receipt = receipt.serialise() if loc is not None: dr.location = loc if accepted: dr.accepted = True elif create: dr.created = True return dr def get_media_resource(self, path, accept_parameters): """ Get a representation of the media resource for the given id as represented by the specified content type :param id: The ID of the object in the store :param content_type A ContentType object describing the type of the object to be retrieved :return: the media resource wrapped in a MediaResourceResponse object """ app.logger.info(u"Request received to retrieve Media Resource from Notification:{x}".format(x=path)) cached = self._cache_notification(path) if not cached: app.logger.debug(u"Unable to retrieve and cache Notification:{x}".format(x=path)) raise SwordError(status=404, empty=True) # get the note from the cache note = self.notes[path] # a note has a media resource if there is a content link associated with it packs = note.get_urls(type="package") if len(packs) == 0: app.logger.debug(u"No Media Resource associated with Notification:{x}".format(x=path)) raise SwordError(status=404, empty=True) mr = MediaResourceResponse() mr.redirect = True mr.url = packs[0] app.logger.debug(u"Returned Media Resource:{x}".format(x=packs[0])) return mr def get_container(self, path, accept_parameters): """ Get a representation of the container in the requested content type :param path: The ID of the object in the store :param accept_parameters: An AcceptParameters object describing the required format :return: a representation of the container in the appropriate format """ app.logger.info(u"Received request to retrieve Notification:{x}".format(x=path)) # by the time this is called, we should already know that we can return this type, so there is no need for # any checking, we just get on with it # pick either the deposit receipt or the pure statement to return to the client if accept_parameters.content_type.mimetype() == "application/atom+xml;type=entry": app.logger.info(u"Returning deposit receipt for Notification:{x}".format(x=path)) return self._get_deposit_receipt(path) else: app.logger.info(u"Returning statement for Notification:{x}".format(x=path)) return self.get_statement(path, accept_parameters.content_type.mimetype()) def get_statement(self, path, type=None): """ Get a representation of the container and its current state as a sword statement :param path: the id of the object in the store :param type: the mimetype of statement to return :return: a serialised statement in the appropriate format """ if type is None: type = "application/atom+xml;type=feed" app.logger.info(u"Received request for Statement for Notification:{x} in Mimetype:{y}".format(x=path, y=type)) cached = self._cache_notification(path) if not cached: app.logger.debug(u"Unable to retrieve and cache Notification:{x}".format(x=path)) raise SwordError(status=404, empty=True) note = self.notes[path] # State information state_uri = "http://router2.mimas.ac.uk/swordv2/state/pending" state_description = "Notification has been accepted for routing" ad = note.analysis_date if ad is not None: state_uri = "http://router2.mimas.ac.uk/swordv2/state/routed" state_description = "Notification has been routed for appropriate repositories" # the derived resources/provided links derived_resources = [l.get("url") for l in note.links] # the various urls agg_uri = self.um.agg_uri(path) edit_uri = self.um.edit_uri(path) deposit_uri = self.um.cont_uri(path) # depositing user by = self.auth_credentials.username obo = self.auth_credentials.on_behalf_of # create the new statement s = Statement() s.aggregation_uri = agg_uri s.rem_uri = edit_uri s.original_deposit(deposit_uri, note.created_datestamp, note.packaging_format, by, obo) s.add_state(state_uri, state_description) s.aggregates = derived_resources # now serve the relevant serialisation if type == "application/rdf+xml": app.logger.debug(u"Returning RDF/XML Statement for Notification:{x}".format(x=path)) return s.serialise_rdf() elif type == "application/atom+xml;type=feed": app.logger.debug(u"Returning ATOM Feed Statement for Notification:{x}".format(x=path)) return s.serialise_atom() else: app.logger.debug(u"Mimetype unrecognised, so not returning Statement for Notification:{x}".format(x=path)) return None ############################################# ## some internal methods def _cache_notification(self, path): """ Get a copy of the notification specified by the path, and store a copy of it in memory for fast access later :param path: :return: True if exists, False if not """ # if we haven't got a cached copy, get one if path not in self.notes: note = self.jper.get_notification(notification_id=path) if note is not None: # cache the result self.notes[path] = note else: return False return True def _make_receipt(self, id, packaging, treatment): """ Create an EntryDocument representing the notification with the specified identifier, packaging and treatment :param id: id of the notification :param packaging: packaging format of any associated binary content :param treatment: human readable text explaining what we did to the notification on ingest :return: an EntryDocument suitable for use as a deposit reciept """ receipt = EntryDocument() receipt.atom_id = self.um.atom_id(id) receipt.content_uri = self.um.cont_uri(id) receipt.edit_uri = self.um.edit_uri(id) receipt.em_uris = [(self.um.em_uri(id), "application/zip")] receipt.packaging = [packaging] receipt.state_uris = [(self.um.state_uri(id, "atom"), "application/atom+xml;type=feed"), (self.um.state_uri(id, "rdf"), "application/rdf+xml")] receipt.generator = self.configuration.generator receipt.treatment = treatment receipt.original_deposit_uri = self.um.em_uri(id) return receipt def _get_deposit_receipt(self, path): """ Get a deposit receipt for the notificiation identified by the path :param path: notification id :return: serialised deposit receipt """ cached = self._cache_notification(path) if not cached: raise SwordError(status=404, empty=True) note = self.notes[path] ad = note.analysis_date treatment = "Notification has been accepted for routing" if ad is not None: treatment = "Notification has been routed for appropriate repositories" receipt = self._make_receipt(note.id, note.packaging_format, treatment) return receipt.serialise() ############################################# ## Methods not currently required by the JPER ## Integration, and which are therefore not implemented ## Left here to remind us def list_collection(self, path): """ NOT IMPLEMENTED """ raise NotImplementedError() def replace(self, path, deposit): """ NOT IMPLEMENTED """ raise NotImplementedError() def delete_content(self, path, delete): """ NOT IMPLEMENTED """ raise NotImplementedError() def add_content(self, path, deposit): """ NOT IMPLEMENTED """ raise NotImplementedError() def deposit_existing(self, path, deposit): """ NOT IMPLEMENTED """ raise NotImplementedError() def delete_container(self, path, delete): """ NOT IMPLEMENTED """ raise NotImplementedError() class URIManager(object): """ Class for providing a single point of access to all identifiers used by SSS """ def __init__(self, config): self.configuration = config def atom_id(self, id): """ Format the notification ID to use for Atom Entries :param id: the notification id :return: a tag identifier for use in atom """ return "tag:container@jper/" + id def sd_uri(self): """ Get the service document URL :return: the url for the service doc """ return self.configuration.base_url[:-1] + url_for("swordv2_server.service_document") def col_uri(self, id): """ The url for a collection on the server :param id: the id of the collection (validate/notify) :return: the url to the collection """ return self.configuration.base_url[:-1] + url_for("swordv2_server.collection", collection_id=id) def edit_uri(self, id): """ The Edit-URI for a notification :param id: the id of the notification :return: the url for the container """ return self.configuration.base_url[:-1] + url_for("swordv2_server.entry", entry_id=id) def em_uri(self, id): """ The EM-URI for the notification :param id: the id of the notification :return: the url for media resource in the container """ return self.configuration.base_url[:-1] + url_for("swordv2_server.content", entry_id=id) def cont_uri(self, id): """ The Cont-URI for the notification :param id: the id of the notification :return: the url for content identifier in the container """ return self.em_uri(id) def state_uri(self, id, type): """ The Statement URL for the notification :param id: the id of the notification :param type: the type of statement (e.g. atom/rdf) :return: the url for the statment """ return self.configuration.base_url[:-1] + url_for("swordv2_server.statement", entry_id=id, type=type) def agg_uri(self, id): """ Aggregation Tag URI for use in RDF statement :param id: id of the notification :return: tag uri for use in RDF graphs """ return "tag:aggregation@jper/" + id
JiscPER/jper-sword-in
service/sword.py
Python
apache-2.0
20,738
[ "Octopus" ]
a1306ad32a22619edc2fae7819c9648438911b19c8b572e2bbb7b52f54f757de
#!/usr/bin/env python # -*- coding: utf-8 -*- # # plheatmap.py # # Copyright 2016 Cosmo <cosmo@CosmoSpectre> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. Also, see <http://www.gnu.org/licenses/>. # Imports import sys import os sys.path.append(os.path.join(os.path.dirname(os.getcwd()), 'dependencies')) from neuron_readExportedGeometry import * import matplotlib.pyplot as plt #%matplotlib inline # Initializing the figure fig = plt.figure(figsize=(20,20)) # Testing tdir = '/home/cosmo/marderlab/test/' thoc = '/home/cosmo/marderlab/test/878_043_GM_scaled.hoc' # Instructions def pathhelp(): print('\n*Use pathplot(\'hoc file\') to view the heatmap for a given hoc file.') print('*EXAMPLE: pathplot(\'/home/cosmo/marderlab/hocs/878_043_GM_scaled.hoc\')') print('\n*Use pathcompare(\'hoc folder\') to compare heatmaps for hoc files in a given folder.') print('*EXAMPLE: pathcompare(\'/home/cosmo/marderlab/hocs/\')') print('*NOTE: The folder must NOT contain anything besides hoc files.') print('\n*Use pathhelp() to view these instructions again.') pathhelp() def pathcompare(hocs, width = 0, height = 0): # Convert given directory into list of hoc files geo = [(hocs + g) for g in os.listdir(hocs)] # Calculate the size of the comparison chart if width <= 0 or height <= 0 or (width * height) < len(geo): width = int(round(sqrt(len(geo)))) height = width print('*Please specify a valid width and height for the comparison chart.') print('*Using {} by {} grid.'.format(width, height)) # Calculate font size fs = 10 # Calculate colorbar upper limit maxDists = [] for g in geo: f = demoReadsilent(g) pdists = [PathDistanceFinder(f, f.soma).distanceTo(s) for s in f.getTips()[0]] maxDists.append(max(pdists)) vmax = max(maxDists) # Create comparison chart for n, g in enumerate(geo, start = 1): plt.subplot(width, height, n) pathplot(g, False, fs, vmax) plt.suptitle('Heatmaps of Neurons Colored by Path Length', size = fs) plt.tight_layout() plt.show() def pathplot(hoc, show = True, save = False, fs = 20, vmax = 500): # Determine the neuron's working name based on its filename name = hoc.split('_s')[0].split('_f')[0].split('.h')[0].split('_r')[0].split('/')[-1] # Convert given hoc file into a geo object print('*Building geo object for {}, please wait...'.format(name)) geo = demoReadsilent(hoc) print('*Building heatmap for {}, please wait...'.format(name)) # Find the tip segments and their end locations tips, ends = geo.getTips() # Calculate the path distance to each tip pDF = PathDistanceFinder(geo, geo.soma) pdists = [pDF.distanceTo(seg) for seg in tips] # Calculate the coordinate position of each tip coords = [tips[i].coordAt(ends[i]) for i in range(len(tips))] # Build and plot the neuron skeleton (includes axons) bpts = [] for b in geo.branches: bpts.append([[n.x, n.y] for n in b.nodes]) for b in bpts: for c in range(len(b)-1): plt.plot([b[c][0], b[c+1][0]], [b[c][1], b[c+1][1]], color='k', alpha=0.5) # Set up the path distance colormap with normalized values if show: vmax = max(pdists) tfloats = [float(i)/vmax for i in pdists] cmap = plt.cm.viridis tcolors = cmap(tfloats) # Plot and color points at tips by path distance for t, pts in enumerate(coords): plt.plot(pts[0], pts[1], 'o', color=tcolors[t], alpha=0.1, mec='none', ms=1) # Plot point at the soma. plt.plot(geo.soma.nodes[0].x, geo.soma.nodes[0].y, 'o', color = 'black', alpha=0.9, mec='none') # Create a list of indices ordered from shortest path to longest pord = list(pdists) # Preserve pdists pind = [] for p in pord: maxind = pord.index(max(pord)) pind.append(maxind) pord.insert(maxind, -1) pord.remove(pord[maxind+1]) pind.reverse() # Enumerate the paths leading to each tip in a dictionary tipDict = {} for d in range(len(tips)): tipDict[d] = pDF.pathTo(tips[d]) # Overlay a tip path skeleton colored by path distance (discludes axons) for path in pind: for seg in tipDict[path]: plt.plot([seg.nodes[0].x, seg.nodes[1].x], [seg.nodes[0].y, seg.nodes[1].y], color=tcolors[path], alpha=1) # Add colorbar sc = [] sc.append(plt.scatter([0,0], [0,0], c=[0., 1.], s=0.1, vmin=0, vmax=vmax, cmap=cmap)) cbar = plt.colorbar(sc[-1]) # Add labels ax = plt.gca() if show: plt.xlabel('Micrometers', fontsize=fs) plt.ylabel('Micrometers', fontsize=fs) plt.title(name + ' Heatmap Colored by Path Length', fontsize=fs) else: ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) cbar.set_label("Path Length (um)", fontsize=fs) # Set equal aspect ratio plt.axes().set_aspect('equal', 'datalim') print('*DONE - Thank you for your patience.') # Save the figure as a PNG image file if save: plt.savefig(str(name) + '.png', bbox_inches='tight') # Display the figure in a new window if show: plt.show() def main(args): return 0 if __name__ == '__main__': import sys sys.exit(main(sys.argv))
CosmoJG/neural-heatmap
dd-path-length/plheatmap.py
Python
gpl-3.0
6,199
[ "NEURON" ]
23caa11a472a6f4fe5cc410509ab9d4ee94bf95f8b7412e4e1389b0e12b4ebdf
# # Copyright (C) 2008, Brian Tanner # #http://rl-glue-ext.googlecode.com/ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision$ # $Date$ # $Author$ # $HeadURL$ import random import sys from rlglue.agent.Agent import Agent from rlglue.agent import AgentLoader as AgentLoader from rlglue.types import Action from rlglue.types import Observation class test_message_agent(Agent): whichEpisode=0 def agent_init(self,taskSpec): pass def agent_start(self,observation): return Action() def agent_step(self,reward, observation): return Action() def agent_end(self,reward): pass def agent_cleanup(self): pass def agent_message(self,inMessage): if inMessage==None: return "null" if inMessage=="": return "empty" if inMessage=="null": return None if inMessage=="empty": return "" return inMessage; if __name__=="__main__": AgentLoader.loadAgent(test_message_agent())
aksmas/rl-glue-ext
projects/codecs/Python/src/tests/test_message_agent.py
Python
apache-2.0
1,430
[ "Brian" ]
da303790a18119ad692d02cc2936489cc45d946bac8d53f026692ec3b28d8000
# -*- coding: utf-8 -*- # # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham # Copyright (C) 2008 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2022 Jan Skarvall # Copyright (C) 2022 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # """ Validate localized date parser and displayer. Based on the Check Localized Date Displayer and Parser tool. """ #------------------------------------------------------------------------- # # standard python modules # #------------------------------------------------------------------------- import unittest import sys if '-v' in sys.argv or '--verbose' in sys.argv: import logging logging.getLogger('').addHandler(logging.StreamHandler()) log = logging.getLogger(".Date") log.setLevel(logging.DEBUG) #------------------------------------------------------------------------- # # Gramps modules # #------------------------------------------------------------------------- from ...config import config from ...lib import Date, DateError from ...utils.grampslocale import GrampsLocale, _LOCALE_NAMES from .. import LANG_TO_PARSER #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- class DateHandlerTest(unittest.TestCase): def setUp(self): config.set('preferences.date-format', 0) def __base_test_all_languages(self, dates): languages = [lang for lang in LANG_TO_PARSER.keys() if lang in _LOCALE_NAMES.keys()] for language in languages: with self.subTest(lang=language): self.__test_language(language, dates) def __test_language(self, language, dates): locale = GrampsLocale(lang=language) displayer = locale.date_displayer parser = locale.date_parser for test_date in dates: datestr = displayer.display(test_date) new_date = parser.parse(datestr) with self.subTest(date=datestr): self.assertTrue(test_date.is_equal(new_date), "{} -> {}\n{} -> {}".format( test_date, new_date, test_date.__dict__, new_date.__dict__)) def test_simple(self): dates = [] for calendar in (Date.CAL_GREGORIAN, Date.CAL_JULIAN): for newyear in (Date.NEWYEAR_JAN1, Date.NEWYEAR_MAR25, (5,5)): for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED): for modifier in (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER, Date.MOD_ABOUT): for slash1 in (False,True): for month in (2, 6, 12): for day in (5, 27): d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1), "Text comment", newyear) dates.append(d) self.__base_test_all_languages(dates) def test_span(self): dates = [] calendar = Date.CAL_GREGORIAN for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED): for modifier in (Date.MOD_RANGE, Date.MOD_SPAN): for slash1 in (False, True): for slash2 in (False, True): for month in (2, 6, 12): for day in (5, 27): d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, day, month, 1876, slash2), "Text comment") dates.append(d) d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, day, 13-month, 1876, slash2), "Text comment") dates.append(d) d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, 32-day, month, 1876, slash2), "Text comment") dates.append(d) d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, 32-day, 13-month, 1876, slash2), "Text comment") dates.append(d) self.__base_test_all_languages(dates) def test_textual(self): dates = [] calendar = Date.CAL_GREGORIAN modifier = Date.MOD_TEXTONLY for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED): test_date = Date() test_date.set(quality, modifier, calendar, Date.EMPTY, "This is a textual date") dates.append(test_date) self.__base_test_all_languages(dates) def test_too_few_arguments(self): dateval = (4, 7, 1789, False) for l in range(1, len(dateval)): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE, Date.MOD_NONE, Date.CAL_GREGORIAN, dateval[:l], "Text comment") def test_too_few_span_arguments(self): dateval = (4, 7, 1789, False, 5, 8, 1876, False) for l in range(1, len(dateval)): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE, Date.MOD_SPAN, Date.CAL_GREGORIAN, dateval[:l], "Text comment") def test_invalid_day(self): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE, Date.MOD_NONE, Date.CAL_GREGORIAN, (44, 7, 1789,False), "Text comment") def test_invalid_month(self): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE,Date.MOD_NONE, Date.CAL_GREGORIAN, (4, 77, 1789, False), "Text comment") def test_invalid_month_with_ny(self): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE,Date.MOD_NONE, Date.CAL_GREGORIAN, (4, 77, 1789, False), "Text comment", newyear=2) def test_invalid_span_day(self): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE, Date.MOD_SPAN, Date.CAL_GREGORIAN, (4, 7, 1789, False, 55, 8, 1876, False), "Text comment") def test_invalid_span_month(self): d = Date() with self.assertRaises(DateError): d.set(Date.QUAL_NONE, Date.MOD_SPAN, Date.CAL_GREGORIAN, (4, 7, 1789, False, 5, 88, 1876, False), "Text comment") if __name__ == "__main__": unittest.main()
gramps-project/gramps
gramps/gen/datehandler/test/datehandler_test.py
Python
gpl-2.0
8,243
[ "Brian" ]
caee6d40862307ffe6b6bf57fe0ea776aca6cc3afbc7f1ff232b6069394534cd
# -*- coding: utf-8 -*- """ Created on Fri Jan 31 13:06:41 2014 @author: samantha Double-Gaussian fit """ import numpy as np from scipy.optimize import curve_fit # Two-Gaussian model def func(x, a0, b0, c0, a1, b1, c1): return a0 * np.exp(-(x-b0)**2/(2*c0**2))\ + a1 * np.exp(-(x-b1)**2/(2*c1**2)) # Generating clean data x = np.linspace(0,20,200) y = func(x,1,3,1,-2,15,0.5) # Adding noise yn = y + 0.2 * np.random.normal(size=len(x)) # when fitting complex functions,providing # guesses may yeild better results guesses = [1,3,1,1,15,1] # second gauss fit would fail! # using curve_fit popt, pcov = curve_fit(func, x, yn, p0=guesses) # popt == best fit values for the model func # pcov == covariant matrix! quality of fit: diagonal elements are the variances # for each parameter. print(popt) # best fit fit_a0 = popt[0] fit_b0 = popt[1] fit_c0 = popt[2] fit_a1 = popt[0] fit_b1 = popt[1] fit_c1 = popt[2] fit_yn = func(x, fit_a0, fit_b0, fit_c0, fit_a1, fit_b1, fit_c1) import pylab as pl pl.figure(figsize=(8,6), dpi=80) pl.scatter(x,yn, color='green', label='Gaussian smeared data') pl.plot(x,y,color='red', linestyle='-', linewidth=2.5, label='Original line') pl.plot(x, fit_yn, linestyle='-', color='blue', linewidth=2.5, label='Fitted line') pl.legend(loc='upper right') #pl.plot(x, fit_yn) pl.show() # Save figure using 72 dots per inch savefig("Exe3_311.png", dpi=72)
hkaushalya/LearningSciKit
Exe3_311_OReillySciPyAndNumPy.py
Python
gpl-3.0
1,419
[ "Gaussian" ]
19c53677c54e60d9d6181750c086817f9babea2f40da016b5105bda9f875a827
""":func:`~pandas.eval` parsers """ import ast import tokenize from functools import partial import pandas as pd from pandas import compat from pandas.compat import StringIO, lmap, zip, reduce, string_types from pandas.core.base import StringMixin from pandas.core import common as com import pandas.formats.printing as printing from pandas.tools.util import compose from pandas.computation.ops import (_cmp_ops_syms, _bool_ops_syms, _arith_ops_syms, _unary_ops_syms, is_term) from pandas.computation.ops import _reductions, _mathops, _LOCAL_TAG from pandas.computation.ops import Op, BinOp, UnaryOp, Term, Constant, Div from pandas.computation.ops import UndefinedVariableError, FuncNode from pandas.computation.scope import Scope def tokenize_string(source): """Tokenize a Python source code string. Parameters ---------- source : str A Python source code string """ line_reader = StringIO(source).readline for toknum, tokval, _, _, _ in tokenize.generate_tokens(line_reader): yield toknum, tokval def _rewrite_assign(tok): """Rewrite the assignment operator for PyTables expressions that use ``=`` as a substitute for ``==``. Parameters ---------- tok : tuple of int, str ints correspond to the all caps constants in the tokenize module Returns ------- t : tuple of int, str Either the input or token or the replacement values """ toknum, tokval = tok return toknum, '==' if tokval == '=' else tokval def _replace_booleans(tok): """Replace ``&`` with ``and`` and ``|`` with ``or`` so that bitwise precedence is changed to boolean precedence. Parameters ---------- tok : tuple of int, str ints correspond to the all caps constants in the tokenize module Returns ------- t : tuple of int, str Either the input or token or the replacement values """ toknum, tokval = tok if toknum == tokenize.OP: if tokval == '&': return tokenize.NAME, 'and' elif tokval == '|': return tokenize.NAME, 'or' return toknum, tokval return toknum, tokval def _replace_locals(tok): """Replace local variables with a syntactically valid name. Parameters ---------- tok : tuple of int, str ints correspond to the all caps constants in the tokenize module Returns ------- t : tuple of int, str Either the input or token or the replacement values Notes ----- This is somewhat of a hack in that we rewrite a string such as ``'@a'`` as ``'__pd_eval_local_a'`` by telling the tokenizer that ``__pd_eval_local_`` is a ``tokenize.OP`` and to replace the ``'@'`` symbol with it. """ toknum, tokval = tok if toknum == tokenize.OP and tokval == '@': return tokenize.OP, _LOCAL_TAG return toknum, tokval def _preparse(source, f=compose(_replace_locals, _replace_booleans, _rewrite_assign)): """Compose a collection of tokenization functions Parameters ---------- source : str A Python source code string f : callable This takes a tuple of (toknum, tokval) as its argument and returns a tuple with the same structure but possibly different elements. Defaults to the composition of ``_rewrite_assign``, ``_replace_booleans``, and ``_replace_locals``. Returns ------- s : str Valid Python source code Notes ----- The `f` parameter can be any callable that takes *and* returns input of the form ``(toknum, tokval)``, where ``toknum`` is one of the constants from the ``tokenize`` module and ``tokval`` is a string. """ assert callable(f), 'f must be callable' return tokenize.untokenize(lmap(f, tokenize_string(source))) def _is_type(t): """Factory for a type checking function of type ``t`` or tuple of types.""" return lambda x: isinstance(x.value, t) _is_list = _is_type(list) _is_str = _is_type(string_types) # partition all AST nodes _all_nodes = frozenset(filter(lambda x: isinstance(x, type) and issubclass(x, ast.AST), (getattr(ast, node) for node in dir(ast)))) def _filter_nodes(superclass, all_nodes=_all_nodes): """Filter out AST nodes that are subclasses of ``superclass``.""" node_names = (node.__name__ for node in all_nodes if issubclass(node, superclass)) return frozenset(node_names) _all_node_names = frozenset(map(lambda x: x.__name__, _all_nodes)) _mod_nodes = _filter_nodes(ast.mod) _stmt_nodes = _filter_nodes(ast.stmt) _expr_nodes = _filter_nodes(ast.expr) _expr_context_nodes = _filter_nodes(ast.expr_context) _slice_nodes = _filter_nodes(ast.slice) _boolop_nodes = _filter_nodes(ast.boolop) _operator_nodes = _filter_nodes(ast.operator) _unary_op_nodes = _filter_nodes(ast.unaryop) _cmp_op_nodes = _filter_nodes(ast.cmpop) _comprehension_nodes = _filter_nodes(ast.comprehension) _handler_nodes = _filter_nodes(ast.excepthandler) _arguments_nodes = _filter_nodes(ast.arguments) _keyword_nodes = _filter_nodes(ast.keyword) _alias_nodes = _filter_nodes(ast.alias) # nodes that we don't support directly but are needed for parsing _hacked_nodes = frozenset(['Assign', 'Module', 'Expr']) _unsupported_expr_nodes = frozenset(['Yield', 'GeneratorExp', 'IfExp', 'DictComp', 'SetComp', 'Repr', 'Lambda', 'Set', 'AST', 'Is', 'IsNot']) # these nodes are low priority or won't ever be supported (e.g., AST) _unsupported_nodes = ((_stmt_nodes | _mod_nodes | _handler_nodes | _arguments_nodes | _keyword_nodes | _alias_nodes | _expr_context_nodes | _unsupported_expr_nodes) - _hacked_nodes) # we're adding a different assignment in some cases to be equality comparison # and we don't want `stmt` and friends in their so get only the class whose # names are capitalized _base_supported_nodes = (_all_node_names - _unsupported_nodes) | _hacked_nodes _msg = 'cannot both support and not support {0}'.format(_unsupported_nodes & _base_supported_nodes) assert not _unsupported_nodes & _base_supported_nodes, _msg def _node_not_implemented(node_name, cls): """Return a function that raises a NotImplementedError with a passed node name. """ def f(self, *args, **kwargs): raise NotImplementedError("{0!r} nodes are not " "implemented".format(node_name)) return f def disallow(nodes): """Decorator to disallow certain nodes from parsing. Raises a NotImplementedError instead. Returns ------- disallowed : callable """ def disallowed(cls): cls.unsupported_nodes = () for node in nodes: new_method = _node_not_implemented(node, cls) name = 'visit_{0}'.format(node) cls.unsupported_nodes += (name,) setattr(cls, name, new_method) return cls return disallowed def _op_maker(op_class, op_symbol): """Return a function to create an op class with its symbol already passed. Returns ------- f : callable """ def f(self, node, *args, **kwargs): """Return a partial function with an Op subclass with an operator already passed. Returns ------- f : callable """ return partial(op_class, op_symbol, *args, **kwargs) return f _op_classes = {'binary': BinOp, 'unary': UnaryOp} def add_ops(op_classes): """Decorator to add default implementation of ops.""" def f(cls): for op_attr_name, op_class in compat.iteritems(op_classes): ops = getattr(cls, '{0}_ops'.format(op_attr_name)) ops_map = getattr(cls, '{0}_op_nodes_map'.format(op_attr_name)) for op in ops: op_node = ops_map[op] if op_node is not None: made_op = _op_maker(op_class, op) setattr(cls, 'visit_{0}'.format(op_node), made_op) return cls return f @disallow(_unsupported_nodes) @add_ops(_op_classes) class BaseExprVisitor(ast.NodeVisitor): """Custom ast walker. Parsers of other engines should subclass this class if necessary. Parameters ---------- env : Scope engine : str parser : str preparser : callable """ const_type = Constant term_type = Term binary_ops = _cmp_ops_syms + _bool_ops_syms + _arith_ops_syms binary_op_nodes = ('Gt', 'Lt', 'GtE', 'LtE', 'Eq', 'NotEq', 'In', 'NotIn', 'BitAnd', 'BitOr', 'And', 'Or', 'Add', 'Sub', 'Mult', None, 'Pow', 'FloorDiv', 'Mod') binary_op_nodes_map = dict(zip(binary_ops, binary_op_nodes)) unary_ops = _unary_ops_syms unary_op_nodes = 'UAdd', 'USub', 'Invert', 'Not' unary_op_nodes_map = dict(zip(unary_ops, unary_op_nodes)) rewrite_map = { ast.Eq: ast.In, ast.NotEq: ast.NotIn, ast.In: ast.In, ast.NotIn: ast.NotIn } def __init__(self, env, engine, parser, preparser=_preparse): self.env = env self.engine = engine self.parser = parser self.preparser = preparser self.assigner = None def visit(self, node, **kwargs): if isinstance(node, string_types): clean = self.preparser(node) node = ast.fix_missing_locations(ast.parse(clean)) method = 'visit_' + node.__class__.__name__ visitor = getattr(self, method) return visitor(node, **kwargs) def visit_Module(self, node, **kwargs): if len(node.body) != 1: raise SyntaxError('only a single expression is allowed') expr = node.body[0] return self.visit(expr, **kwargs) def visit_Expr(self, node, **kwargs): return self.visit(node.value, **kwargs) def _rewrite_membership_op(self, node, left, right): # the kind of the operator (is actually an instance) op_instance = node.op op_type = type(op_instance) # must be two terms and the comparison operator must be ==/!=/in/not in if is_term(left) and is_term(right) and op_type in self.rewrite_map: left_list, right_list = map(_is_list, (left, right)) left_str, right_str = map(_is_str, (left, right)) # if there are any strings or lists in the expression if left_list or right_list or left_str or right_str: op_instance = self.rewrite_map[op_type]() # pop the string variable out of locals and replace it with a list # of one string, kind of a hack if right_str: name = self.env.add_tmp([right.value]) right = self.term_type(name, self.env) if left_str: name = self.env.add_tmp([left.value]) left = self.term_type(name, self.env) op = self.visit(op_instance) return op, op_instance, left, right def _possibly_transform_eq_ne(self, node, left=None, right=None): if left is None: left = self.visit(node.left, side='left') if right is None: right = self.visit(node.right, side='right') op, op_class, left, right = self._rewrite_membership_op(node, left, right) return op, op_class, left, right def _possibly_eval(self, binop, eval_in_python): # eval `in` and `not in` (for now) in "partial" python space # things that can be evaluated in "eval" space will be turned into # temporary variables. for example, # [1,2] in a + 2 * b # in that case a + 2 * b will be evaluated using numexpr, and the "in" # call will be evaluated using isin (in python space) return binop.evaluate(self.env, self.engine, self.parser, self.term_type, eval_in_python) def _possibly_evaluate_binop(self, op, op_class, lhs, rhs, eval_in_python=('in', 'not in'), maybe_eval_in_python=('==', '!=', '<', '>', '<=', '>=')): res = op(lhs, rhs) if res.has_invalid_return_type: raise TypeError("unsupported operand type(s) for {0}:" " '{1}' and '{2}'".format(res.op, lhs.type, rhs.type)) if self.engine != 'pytables': if (res.op in _cmp_ops_syms and getattr(lhs, 'is_datetime', False) or getattr(rhs, 'is_datetime', False)): # all date ops must be done in python bc numexpr doesn't work # well with NaT return self._possibly_eval(res, self.binary_ops) if res.op in eval_in_python: # "in"/"not in" ops are always evaluated in python return self._possibly_eval(res, eval_in_python) elif self.engine != 'pytables': if (getattr(lhs, 'return_type', None) == object or getattr(rhs, 'return_type', None) == object): # evaluate "==" and "!=" in python if either of our operands # has an object return type return self._possibly_eval(res, eval_in_python + maybe_eval_in_python) return res def visit_BinOp(self, node, **kwargs): op, op_class, left, right = self._possibly_transform_eq_ne(node) return self._possibly_evaluate_binop(op, op_class, left, right) def visit_Div(self, node, **kwargs): truediv = self.env.scope['truediv'] return lambda lhs, rhs: Div(lhs, rhs, truediv) def visit_UnaryOp(self, node, **kwargs): op = self.visit(node.op) operand = self.visit(node.operand) return op(operand) def visit_Name(self, node, **kwargs): return self.term_type(node.id, self.env, **kwargs) def visit_NameConstant(self, node, **kwargs): return self.const_type(node.value, self.env) def visit_Num(self, node, **kwargs): return self.const_type(node.n, self.env) def visit_Str(self, node, **kwargs): name = self.env.add_tmp(node.s) return self.term_type(name, self.env) def visit_List(self, node, **kwargs): name = self.env.add_tmp([self.visit(e)(self.env) for e in node.elts]) return self.term_type(name, self.env) visit_Tuple = visit_List def visit_Index(self, node, **kwargs): """ df.index[4] """ return self.visit(node.value) def visit_Subscript(self, node, **kwargs): value = self.visit(node.value) slobj = self.visit(node.slice) result = pd.eval(slobj, local_dict=self.env, engine=self.engine, parser=self.parser) try: # a Term instance v = value.value[result] except AttributeError: # an Op instance lhs = pd.eval(value, local_dict=self.env, engine=self.engine, parser=self.parser) v = lhs[result] name = self.env.add_tmp(v) return self.term_type(name, env=self.env) def visit_Slice(self, node, **kwargs): """ df.index[slice(4,6)] """ lower = node.lower if lower is not None: lower = self.visit(lower).value upper = node.upper if upper is not None: upper = self.visit(upper).value step = node.step if step is not None: step = self.visit(step).value return slice(lower, upper, step) def visit_Assign(self, node, **kwargs): """ support a single assignment node, like c = a + b set the assigner at the top level, must be a Name node which might or might not exist in the resolvers """ if len(node.targets) != 1: raise SyntaxError('can only assign a single expression') if not isinstance(node.targets[0], ast.Name): raise SyntaxError('left hand side of an assignment must be a ' 'single name') if self.env.target is None: raise ValueError('cannot assign without a target object') try: assigner = self.visit(node.targets[0], **kwargs) except UndefinedVariableError: assigner = node.targets[0].id self.assigner = getattr(assigner, 'name', assigner) if self.assigner is None: raise SyntaxError('left hand side of an assignment must be a ' 'single resolvable name') return self.visit(node.value, **kwargs) def visit_Attribute(self, node, **kwargs): attr = node.attr value = node.value ctx = node.ctx if isinstance(ctx, ast.Load): # resolve the value resolved = self.visit(value).value try: v = getattr(resolved, attr) name = self.env.add_tmp(v) return self.term_type(name, self.env) except AttributeError: # something like datetime.datetime where scope is overridden if isinstance(value, ast.Name) and value.id == attr: return resolved raise ValueError("Invalid Attribute context {0}".format(ctx.__name__)) def visit_Call_35(self, node, side=None, **kwargs): """ in 3.5 the starargs attribute was changed to be more flexible, #11097 """ if isinstance(node.func, ast.Attribute): res = self.visit_Attribute(node.func) elif not isinstance(node.func, ast.Name): raise TypeError("Only named functions are supported") else: try: res = self.visit(node.func) except UndefinedVariableError: # Check if this is a supported function name try: res = FuncNode(node.func.id) except ValueError: # Raise original error raise if res is None: raise ValueError("Invalid function call {0}".format(node.func.id)) if hasattr(res, 'value'): res = res.value if isinstance(res, FuncNode): new_args = [self.visit(arg) for arg in node.args] if node.keywords: raise TypeError("Function \"{0}\" does not support keyword " "arguments".format(res.name)) return res(*new_args, **kwargs) else: new_args = [self.visit(arg).value for arg in node.args] for key in node.keywords: if not isinstance(key, ast.keyword): raise ValueError("keyword error in function call " "'{0}'".format(node.func.id)) if key.arg: # TODO: bug? kwargs.append(ast.keyword( keyword.arg, self.visit(keyword.value))) # noqa return self.const_type(res(*new_args, **kwargs), self.env) def visit_Call_legacy(self, node, side=None, **kwargs): # this can happen with: datetime.datetime if isinstance(node.func, ast.Attribute): res = self.visit_Attribute(node.func) elif not isinstance(node.func, ast.Name): raise TypeError("Only named functions are supported") else: try: res = self.visit(node.func) except UndefinedVariableError: # Check if this is a supported function name try: res = FuncNode(node.func.id) except ValueError: # Raise original error raise if res is None: raise ValueError("Invalid function call {0}".format(node.func.id)) if hasattr(res, 'value'): res = res.value if isinstance(res, FuncNode): args = [self.visit(targ) for targ in node.args] if node.starargs is not None: args += self.visit(node.starargs) if node.keywords or node.kwargs: raise TypeError("Function \"{0}\" does not support keyword " "arguments".format(res.name)) return res(*args, **kwargs) else: args = [self.visit(targ).value for targ in node.args] if node.starargs is not None: args += self.visit(node.starargs).value keywords = {} for key in node.keywords: if not isinstance(key, ast.keyword): raise ValueError("keyword error in function call " "'{0}'".format(node.func.id)) keywords[key.arg] = self.visit(key.value).value if node.kwargs is not None: keywords.update(self.visit(node.kwargs).value) return self.const_type(res(*args, **keywords), self.env) def translate_In(self, op): return op def visit_Compare(self, node, **kwargs): ops = node.ops comps = node.comparators # base case: we have something like a CMP b if len(comps) == 1: op = self.translate_In(ops[0]) binop = ast.BinOp(op=op, left=node.left, right=comps[0]) return self.visit(binop) # recursive case: we have a chained comparison, a CMP b CMP c, etc. left = node.left values = [] for op, comp in zip(ops, comps): new_node = self.visit(ast.Compare(comparators=[comp], left=left, ops=[self.translate_In(op)])) left = comp values.append(new_node) return self.visit(ast.BoolOp(op=ast.And(), values=values)) def _try_visit_binop(self, bop): if isinstance(bop, (Op, Term)): return bop return self.visit(bop) def visit_BoolOp(self, node, **kwargs): def visitor(x, y): lhs = self._try_visit_binop(x) rhs = self._try_visit_binop(y) op, op_class, lhs, rhs = self._possibly_transform_eq_ne(node, lhs, rhs) return self._possibly_evaluate_binop(op, node.op, lhs, rhs) operands = node.values return reduce(visitor, operands) # ast.Call signature changed on 3.5, # conditionally change which methods is named # visit_Call depending on Python version, #11097 if compat.PY35: BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_35 else: BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_legacy _python_not_supported = frozenset(['Dict', 'BoolOp', 'In', 'NotIn']) _numexpr_supported_calls = frozenset(_reductions + _mathops) @disallow((_unsupported_nodes | _python_not_supported) - (_boolop_nodes | frozenset(['BoolOp', 'Attribute', 'In', 'NotIn', 'Tuple']))) class PandasExprVisitor(BaseExprVisitor): def __init__(self, env, engine, parser, preparser=partial(_preparse, f=compose(_replace_locals, _replace_booleans))): super(PandasExprVisitor, self).__init__(env, engine, parser, preparser) @disallow(_unsupported_nodes | _python_not_supported | frozenset(['Not'])) class PythonExprVisitor(BaseExprVisitor): def __init__(self, env, engine, parser, preparser=lambda x: x): super(PythonExprVisitor, self).__init__(env, engine, parser, preparser=preparser) class Expr(StringMixin): """Object encapsulating an expression. Parameters ---------- expr : str engine : str, optional, default 'numexpr' parser : str, optional, default 'pandas' env : Scope, optional, default None truediv : bool, optional, default True level : int, optional, default 2 """ def __init__(self, expr, engine='numexpr', parser='pandas', env=None, truediv=True, level=0): self.expr = expr self.env = env or Scope(level=level + 1) self.engine = engine self.parser = parser self.env.scope['truediv'] = truediv self._visitor = _parsers[parser](self.env, self.engine, self.parser) self.terms = self.parse() @property def assigner(self): return getattr(self._visitor, 'assigner', None) def __call__(self): return self.terms(self.env) def __unicode__(self): return printing.pprint_thing(self.terms) def __len__(self): return len(self.expr) def parse(self): """Parse an expression""" return self._visitor.visit(self.expr) @property def names(self): """Get the names in an expression""" if is_term(self.terms): return frozenset([self.terms.name]) return frozenset(term.name for term in com.flatten(self.terms)) _parsers = {'python': PythonExprVisitor, 'pandas': PandasExprVisitor}
BigDataforYou/movie_recommendation_workshop_1
big_data_4_you_demo_1/venv/lib/python2.7/site-packages/pandas/computation/expr.py
Python
mit
25,528
[ "VisIt" ]
29804a56b642f845f3e3080ec7009c4d706543c3ef88cb838f6ab819fa960edb
#!/usr/bin/env python ''' Master loader for CANON April (Spring) 2021 Campaign ''' import os import sys from datetime import datetime parentDir = os.path.join(os.path.dirname(__file__), "../") sys.path.insert(0, parentDir) from CANON import CANONLoader import timing cl = CANONLoader('stoqs_canon_april2021', 'CANON-ECOHAB - April 2021', description='October 2021 CANON campaign in Monterey Bay (CN21S)', x3dTerrains={ 'https://stoqs.mbari.org/x3d/Monterey25_10x/Monterey25_10x_scene.x3d': { 'name': 'Monterey25_10x', 'position': '-2822317.31255 -4438600.53640 3786150.85474', 'orientation': '0.89575 -0.31076 -0.31791 1.63772', 'centerOfRotation': '-2711557.9403829873 -4331414.329506527 3801353.4691465236', 'VerticalExaggeration': '10', }, }, grdTerrain=os.path.join(parentDir, 'Monterey25.grd') ) startdate = datetime(2021, 4, 8) enddate = datetime(2021, 4, 29) # default location of thredds and dods data: cl.tdsBase = 'http://odss.mbari.org/thredds/' cl.dodsBase = cl.tdsBase + 'dodsC/' ###################################################################### # GLIDERS ###################################################################### # Glider data files from CeNCOOS thredds server # L_662a updated parameter names in netCDF file cl.l_662a_base = 'http://legacy.cencoos.org/thredds/dodsC/gliders/Line67/' cl.l_662a_files = [ 'OS_Glider_L_662_20200615_TS.nc', ] cl.l_662a_parms = ['temperature', 'salinity', 'fluorescence','oxygen'] cl.l_662a_startDatetime = startdate cl.l_662a_endDatetime = enddate # NPS_34 ## cl.nps34_base = 'http://legacy.cencoos.org/thredds/dodsC/gliders/MBARI/' cl.nps34_files = [ 'OS_Glider_NPS_G34_20210414_TS.nc' ] cl.nps34_parms = ['TEMP', 'PSAL', 'FLU2', 'OXYG'] cl.nps34_startDatetime = startdate cl.nps34_endDatetime = enddate # NPS_29 ## cl.nps29_base = 'http://legacy.cencoos.org/thredds/dodsC/gliders/MBARI/' cl.nps29_files = [ 'OS_Glider_NPS_G29_20210209_TS.nc' ] cl.nps29_parms = ['TEMP', 'PSAL', 'FLU2', 'OXYG'] cl.nps29_startDatetime = startdate cl.nps29_endDatetime = enddate ###################################################################### # Wavegliders ###################################################################### # WG Tex - All instruments combined into one file - one time coordinate ##cl.wg_tex_base = cl.dodsBase + 'CANON_september2013/Platforms/Gliders/WG_Tex/final/' ##cl.wg_tex_files = [ 'WG_Tex_all_final.nc' ] ##cl.wg_tex_parms = [ 'wind_dir', 'wind_spd', 'atm_press', 'air_temp', 'water_temp', 'sal', 'density', 'bb_470', 'bb_650', 'chl' ] ##cl.wg_tex_startDatetime = startdate ##cl.wg_tex_endDatetime = enddate # WG Hansen - All instruments combined into one file - one time coordinate cl.wg_Hansen_base = 'http://dods.mbari.org/opendap/data/waveglider/deployment_data/' cl.wg_Hansen_files = [ 'wgHansen/20210409/realTime/20210409.nc' ] cl.wg_Hansen_parms = [ 'wind_dir', 'avg_wind_spd', 'max_wind_spd', 'atm_press', 'air_temp', 'water_temp_float', 'sal_float', 'water_temp_sub', 'sal_sub', 'bb_470', 'bb_650', 'chl', 'beta_470', 'beta_650', 'pH', 'O2_conc_float','O2_conc_sub' ] # two ctds (_float, _sub), no CO2 cl.wg_Hansen_depths = [ 0 ] cl.wg_Hansen_startDatetime = startdate cl.wg_Hansen_endDatetime = enddate # WG Tiny - All instruments combined into one file - one time coordinate cl.wg_Tiny_base = 'http://dods.mbari.org/opendap/data/waveglider/deployment_data/' cl.wg_Tiny_files = [ 'wgTiny/20210408/realTime/20210408.nc' ] cl.wg_Tiny_parms = [ 'wind_dir', 'avg_wind_spd', 'max_wind_spd', 'atm_press', 'air_temp', 'water_temp', 'sal', 'bb_470', 'bb_650', 'chl', 'beta_470', 'beta_650', 'pCO2_water', 'pCO2_air', 'pH', 'O2_conc' ] cl.wg_Tiny_depths = [ 0 ] cl.wg_Tiny_startDatetime = startdate cl.wg_Tiny_endDatetime = enddate ###################################################################### # MOORINGS ###################################################################### cl.m1_base = 'http://dods.mbari.org/opendap/data/ssdsdata/deployments/m1/' cl.m1_files = [ '202008/OS_M1_20200825hourly_CMSTV.nc', '202008/m1_hs2_0m_20200825.nc' ] cl.m1_parms = [ 'eastward_sea_water_velocity_HR', 'northward_sea_water_velocity_HR', 'SEA_WATER_SALINITY_HR', 'SEA_WATER_TEMPERATURE_HR', 'SW_FLUX_HR', 'AIR_TEMPERATURE_HR', 'EASTWARD_WIND_HR', 'NORTHWARD_WIND_HR', 'WIND_SPEED_HR', 'bb470', 'bb676', 'fl676' ] cl.m1_startDatetime = startdate cl.m1_endDatetime = enddate # Mooring 0A1 cl.oa1_base = 'http://dods.mbari.org/opendap/data/oa_moorings/deployment_data/OA1/202010/' cl.oa1_files = [ 'realTime/OA1_202010.nc' ] cl.oa1_parms = [ 'wind_dir', 'avg_wind_spd', 'atm_press', 'air_temp', 'water_temp', 'sal', 'O2_conc', 'chl', 'pCO2_water', 'pCO2_air', 'pH', ] cl.oa1_startDatetime = startdate cl.oa1_endDatetime = enddate # Mooring 0A2 cl.oa2_base = 'http://dods.mbari.org/opendap/data/oa_moorings/deployment_data/OA2/201912/' cl.oa2_files = [ 'realTime/OA2_201912.nc' ] cl.oa2_parms = [ 'wind_dir', 'avg_wind_spd', 'atm_press', 'air_temp', 'water_temp', 'sal', 'O2_conc', 'chl', 'pCO2_water', 'pCO2_air', 'pH', ] cl.oa2_startDatetime = startdate cl.oa2_endDatetime = enddate ###################################################################### # WESTERN FLYER ###################################################################### # UCTD cl.wfuctd_base = cl.dodsBase + 'Other/routine/Platforms/Ships/WesternFlyer/uctd/' cl.wfuctd_parms = [ 'TEMP', 'PSAL', 'xmiss', 'wetstar' ] cl.wfuctd_files = [ 'CN21Sm01.nc', 'CN21Sm02.nc', 'CN21Sm03.nc', 'CN21Sm04.nc', 'CN21Sm05.nc', 'CN21Sm06.nc', ] # PCTD cl.wfpctd_base = cl.dodsBase + 'Other/routine/Platforms/Ships/WesternFlyer/pctd/' cl.wfpctd_parms = [ 'TEMP', 'PSAL', 'xmiss', 'ecofl', 'oxygen' ] cl.wfpctd_files = [ 'CN21SC01.nc', 'CN21SC02.nc', 'CN21SC03.nc', 'CN21SC04.nc', 'CN21SC05.nc', 'CN21SC06.nc', 'CN21SC07.nc', 'CN21SC08.nc', 'CN21SC09.nc', 'CN21SC10.nc', 'CN21SC11.nc', 'CN21SC12.nc', 'CN21SC13.nc', 'CN21SC14.nc', 'CN21SC15.nc', 'CN21SC16.nc', 'CN21SC17.nc', 'CN21SC18.nc', 'CN21SC19.nc', 'CN21SC20.nc', 'CN21SC21.nc', 'CN21SC22.nc', 'CN21SC23.nc', 'CN21SC24.nc', 'CN21SC25.nc', 'CN21SC26.nc', 'CN21SC27.nc', 'CN21SC28.nc', 'CN21SC29.nc', ] # Execute the load cl.process_command_line() if cl.args.test: cl.stride = 10 elif cl.args.stride: cl.stride = cl.args.stride # Test correction of Sample name for leaked ESP Cartridges and spare used ##cl.makai_base = ' http://dods.mbari.org/opendap/data/lrauv/makai/missionlogs/2021/20210420_20210426/20210421T033242' ##cl.makai_files = ['202104210332_202104211941_2S_scieng.nc'] ##cl.makai_parms = ['temperature'] ##cl.loadLRAUV('makai', startdate, enddate, build_attrs=False) ##sys.exit() lrauv_start = datetime(2021, 4, 11) lrauv_end = datetime(2021, 4, 29) cl.loadLRAUV('brizo', lrauv_start, lrauv_end) cl.loadLRAUV('pontus', lrauv_start, lrauv_end) cl.loadLRAUV('makai', lrauv_start, lrauv_end) cl.loadLRAUV('daphne', lrauv_start, lrauv_end) cl.loadM1() cl.load_oa1() cl.load_oa2() cl.load_NPS29() cl.load_NPS34() cl.load_wg_Tiny() cl.load_wg_Hansen() # Realtime LRAUV loads - to be executed during the Campaign ##lrauv_parms = ['chlorophyll', 'temperature'] ##cl.loadLRAUV('brizo', lrauv_start, lrauv_end, critSimpleDepthTime=0.1, sbd_logs=True, ## parameters=lrauv_parms) ##cl.loadLRAUV('pontus', lrauv_start, lrauv_end, critSimpleDepthTime=0.1, sbd_logs=True, ## parameters=lrauv_parms) ##cl.loadLRAUV('makai', lrauv_start, lrauv_end, critSimpleDepthTime=0.1, sbd_logs=True, ## parameters=lrauv_parms) ##cl.loadLRAUV('daphne', lrauv_start, lrauv_end, critSimpleDepthTime=0.1, sbd_logs=True, ## parameters=lrauv_parms) cl.loadDorado(startdate, enddate, build_attrs=True) cl.loadWFuctd() cl.loadWFpctd() ##cl.loadSubSamples() # Add any X3D Terrain information specified in the constructor to the database - must be done after a load is executed cl.addTerrainResources() print("All Done.")
stoqs/stoqs
stoqs/loaders/CANON/loadCANON_april2021.py
Python
gpl-3.0
8,768
[ "NetCDF" ]
da66a647bd72bd436009b4e1211955ad7c67c4b1037a138e5be8b67370fcf1c3
import matplotlib.pyplot as plt import argparse '''parser = argparse.ArgumentParser() parser.add_argument("parameter", type=str, help="Options : mass, age, radius, lum, velo, long") parser.add_argument("numberBins", type=int, help="Set number of bins for histogram") args = parser.parse_args() param = args.parameter # Prompt User for plotting parameter numBins = args.numberBins()''' # Prompt User for number of bins param = "mass" numBins = 50 # Open CSV File datafile = open(r'C:\Users\newye\OneDrive\Documents\GitHub\galSims\misc\3DHiiRegions.csv', 'r') csvFile = [] for row in datafile: csvFile.append(row.strip().split(',')) if param == "mass" : # Save Galactic Radius Info from CSV to new list data = list() index = 0 while index < len(csvFile) : data.append(float(csvFile[index][4])) index += 1 # Produce histogram of data plt.hist(data, bins=numBins, histtype='step') plt.title("Mass Binned HII Regions in 3D Galaxy Simulation") plt.xlabel("HII Region Mass (In Solar Units)") plt.ylabel("HII Region Count") plt.yscale('log') plt.show() elif param == "age" : # Save Galactic Radius Info from CSV to new list data = list() index = 0 while index < len(csvFile) : data.append(float(csvFile[index][6])) index += 1 # Produce histogram of data plt.hist(data, bins=numBins, histtype='step') plt.title("Age Binned HII Regions in 3D Galaxy Simulation") plt.xlabel("HII Region Age (In Myr)") plt.ylabel("HII Region Count") plt.show() elif param == "radius" : # Save Galactic Radius Info from CSV to new list data = list() index = 0 while index < len(csvFile) : data.append(float(csvFile[index][7])) index += 1 # Produce histogram of data plt.hist(data, bins=numBins, histtype='step') plt.title("Radius Binned HII Regions in 3D Galaxy Simulation") plt.xlabel("HII Region Radius (parsecs)") plt.ylabel("HII Region Count") plt.show() elif param == "lum" : # Save Galactic Radius Info from CSV to new list galRad = list() #Use this to tell us flux from various directions? Useful? lum = list() index = 0 while index < len(csvFile) : galRad.append(float(csvFile[index][0])) lum.append(float(csvFile[index][5])) index += 1 # Produce histogram of data plt.hist(lum, bins=numBins, histtype='step') plt.title("Luminosity Function for HII Regions in 3D Galaxy Simulation") plt.xlabel("HII Region Integrated Luminosity at Given Radius") plt.ylabel("HII Region Count") plt.yscale('log') plt.show() elif param == "velo" : # Save Galactic Radius Info from CSV to new list data = list() index = 0 while index < len(csvFile) : data.append(float(csvFile[index][9])) index += 1 # Produce histogram of data plt.hist(data, bins=numBins, histtype='step') plt.title("Velocity Binned HII Regions in 3D Galaxy Simulation") plt.xlabel("HII Region Velocity (km/s)") plt.ylabel("HII Region Count") plt.show() elif param == "long" : # Save Galactic Radius Info from CSV to new list data = list() index = 0 while index < len(csvFile) : data.append(float(csvFile[index][8])) index += 1 # Produce histogram of data plt.hist(data, bins=numBins, histtype='step') plt.title("Longitude Binned HII Regions in 3D Galaxy Simulation") # plt.title("8000 Regions - Only Spiral and Diffuse Shown") plt.xlabel("HII Region Longitude (deg)") plt.ylabel("HII Region Count") plt.show() else : print ("Invalid Parameter") quit
WillArmentrout/galSims
plotting/ParamHist.py
Python
gpl-2.0
3,725
[ "Galaxy" ]
18bce6400a80ebf26b42212430a1c33e6a28523dda3de09505e1b8b15c02f19c
#!/usr/bin/env python # Copyright 2014-2021 The PySCF Developers. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Author: Qiming Sun <osirpt.sun@gmail.com> # ''' Full CI solver for spin-free Hamiltonian. This solver can be used to compute doublet, triplet,... The CI wfn are stored as a 2D array [alpha,beta], where each row corresponds to an alpha string. For each row (alpha string), there are total-num-beta-strings of columns. Each column corresponds to a beta string. Different FCI solvers are implemented to support different type of symmetry. Symmetry File Point group Spin singlet Real hermitian* Alpha/beta degeneracy direct_spin0_symm Yes Yes Yes Yes direct_spin1_symm Yes No Yes Yes direct_spin0 No Yes Yes Yes direct_spin1 No No Yes Yes direct_uhf No No Yes No direct_nosym No No No** Yes * Real hermitian Hamiltonian implies (ij|kl) = (ji|kl) = (ij|lk) = (ji|lk) ** Hamiltonian is real but not hermitian, (ij|kl) != (ji|kl) ... ''' import sys import ctypes import numpy import scipy.linalg from pyscf import lib from pyscf import ao2mo from pyscf.lib import logger from pyscf.fci import cistring from pyscf.fci import rdm from pyscf.fci import spin_op from pyscf.fci import addons from pyscf.fci.spin_op import contract_ss from pyscf.fci.addons import _unpack_nelec from pyscf import __config__ libfci = lib.load_library('libfci') def contract_1e(f1e, fcivec, norb, nelec, link_index=None): '''Contract the 1-electron Hamiltonian with a FCI vector to get a new FCI vector. ''' fcivec = numpy.asarray(fcivec, order='C') link_indexa, link_indexb = _unpack(norb, nelec, link_index) na, nlinka = link_indexa.shape[:2] nb, nlinkb = link_indexb.shape[:2] assert(fcivec.size == na*nb) f1e_tril = lib.pack_tril(f1e) ci1 = numpy.zeros_like(fcivec) libfci.FCIcontract_a_1e(f1e_tril.ctypes.data_as(ctypes.c_void_p), fcivec.ctypes.data_as(ctypes.c_void_p), ci1.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(norb), ctypes.c_int(na), ctypes.c_int(nb), ctypes.c_int(nlinka), ctypes.c_int(nlinkb), link_indexa.ctypes.data_as(ctypes.c_void_p), link_indexb.ctypes.data_as(ctypes.c_void_p)) libfci.FCIcontract_b_1e(f1e_tril.ctypes.data_as(ctypes.c_void_p), fcivec.ctypes.data_as(ctypes.c_void_p), ci1.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(norb), ctypes.c_int(na), ctypes.c_int(nb), ctypes.c_int(nlinka), ctypes.c_int(nlinkb), link_indexa.ctypes.data_as(ctypes.c_void_p), link_indexb.ctypes.data_as(ctypes.c_void_p)) return ci1 def contract_2e(eri, fcivec, norb, nelec, link_index=None): r'''Contract the 4-index tensor eri[pqrs] with a FCI vector .. math:: |output\rangle = E_{pq} E_{rs} eri_{pq,rs} |CI\rangle \\ E_{pq}E_{rs} = E_{pr,qs} + \delta_{qr} E_{ps} \\ E_{pq} = p^+ q + \bar{p}^+ \bar{q} E_{pr,qs} = p^+ r^+ s q + \bar{p}^+ r^+ s \bar{q} + ... :math:`p,q,...` means spin-up orbitals and :math:`\bar{p}, \bar{q}` means spin-down orbitals. Note the input argument eri is NOT the 2e hamiltonian tensor. 2e hamiltonian is .. math:: h2e &= (pq|rs) E_{pr,qs} \\ &= (pq|rs) (E_{pq}E_{rs} - \delta_{qr} E_{ps}) \\ &= eri_{pq,rs} E_{pq}E_{rs} \\ So the relation between eri and hamiltonian (the 2e-integral tensor) is .. math:: eri_{pq,rs} = (pq|rs) - (1/Nelec) \sum_q (pq|qs) to restore the symmetry between pq and rs, .. math:: eri_{pq,rs} = (pq|rs) - (.5/Nelec) [\sum_q (pq|qs) + \sum_p (pq|rp)] See also :func:`direct_spin1.absorb_h1e` ''' fcivec = numpy.asarray(fcivec, order='C') eri = ao2mo.restore(4, eri, norb) link_indexa, link_indexb = _unpack(norb, nelec, link_index) na, nlinka = link_indexa.shape[:2] nb, nlinkb = link_indexb.shape[:2] assert(fcivec.size == na*nb) ci1 = numpy.empty_like(fcivec) libfci.FCIcontract_2e_spin1(eri.ctypes.data_as(ctypes.c_void_p), fcivec.ctypes.data_as(ctypes.c_void_p), ci1.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(norb), ctypes.c_int(na), ctypes.c_int(nb), ctypes.c_int(nlinka), ctypes.c_int(nlinkb), link_indexa.ctypes.data_as(ctypes.c_void_p), link_indexb.ctypes.data_as(ctypes.c_void_p)) return ci1 def make_hdiag(h1e, eri, norb, nelec): '''Diagonal Hamiltonian for Davidson preconditioner ''' if h1e.dtype == numpy.complex128 or eri.dtype == numpy.complex128: raise NotImplementedError('Complex Hamiltonian') neleca, nelecb = _unpack_nelec(nelec) h1e = numpy.asarray(h1e, order='C') eri = ao2mo.restore(1, eri, norb) occslsta = occslstb = cistring._gen_occslst(range(norb), neleca) if neleca != nelecb: occslstb = cistring._gen_occslst(range(norb), nelecb) na = len(occslsta) nb = len(occslstb) hdiag = numpy.empty(na*nb) jdiag = numpy.asarray(numpy.einsum('iijj->ij',eri), order='C') kdiag = numpy.asarray(numpy.einsum('ijji->ij',eri), order='C') c_h1e = h1e.ctypes.data_as(ctypes.c_void_p) c_jdiag = jdiag.ctypes.data_as(ctypes.c_void_p) c_kdiag = kdiag.ctypes.data_as(ctypes.c_void_p) libfci.FCImake_hdiag_uhf(hdiag.ctypes.data_as(ctypes.c_void_p), c_h1e, c_h1e, c_jdiag, c_jdiag, c_jdiag, c_kdiag, c_kdiag, ctypes.c_int(norb), ctypes.c_int(na), ctypes.c_int(nb), ctypes.c_int(neleca), ctypes.c_int(nelecb), occslsta.ctypes.data_as(ctypes.c_void_p), occslstb.ctypes.data_as(ctypes.c_void_p)) return hdiag def absorb_h1e(h1e, eri, norb, nelec, fac=1): '''Modify 2e Hamiltonian to include 1e Hamiltonian contribution. ''' if h1e.dtype == numpy.complex128 or eri.dtype == numpy.complex128: raise NotImplementedError('Complex Hamiltonian') if not isinstance(nelec, (int, numpy.number)): nelec = sum(nelec) h2e = ao2mo.restore(1, eri.copy(), norb) f1e = h1e - numpy.einsum('jiik->jk', h2e) * .5 f1e = f1e * (1./(nelec+1e-100)) for k in range(norb): h2e[k,k,:,:] += f1e h2e[:,:,k,k] += f1e return ao2mo.restore(4, h2e, norb) * fac def pspace(h1e, eri, norb, nelec, hdiag=None, np=400): '''pspace Hamiltonian to improve Davidson preconditioner. See, CPL, 169, 463 ''' if norb > 63: raise NotImplementedError('norb > 63') if h1e.dtype == numpy.complex128 or eri.dtype == numpy.complex128: raise NotImplementedError('Complex Hamiltonian') neleca, nelecb = _unpack_nelec(nelec) h1e = numpy.ascontiguousarray(h1e) eri = ao2mo.restore(1, eri, norb) nb = cistring.num_strings(norb, nelecb) if hdiag is None: hdiag = make_hdiag(h1e, eri, norb, nelec) if hdiag.size < np: addr = numpy.arange(hdiag.size) else: try: addr = numpy.argpartition(hdiag, np-1)[:np].copy() except AttributeError: addr = numpy.argsort(hdiag)[:np].copy() addra, addrb = divmod(addr, nb) stra = cistring.addrs2str(norb, neleca, addra) strb = cistring.addrs2str(norb, nelecb, addrb) np = len(addr) h0 = numpy.zeros((np,np)) libfci.FCIpspace_h0tril(h0.ctypes.data_as(ctypes.c_void_p), h1e.ctypes.data_as(ctypes.c_void_p), eri.ctypes.data_as(ctypes.c_void_p), stra.ctypes.data_as(ctypes.c_void_p), strb.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(norb), ctypes.c_int(np)) HERMITIAN_THRESHOLD = 1e-10 if (abs(h1e - h1e.T).max() < HERMITIAN_THRESHOLD and abs(eri - eri.transpose(1,0,3,2)).max() < HERMITIAN_THRESHOLD): # symmetric Hamiltonian h0 = lib.hermi_triu(h0) else: # Fill the upper triangular part h0 = numpy.asarray(h0, order='F') h1e = numpy.asarray(h1e.T, order='C') eri = numpy.asarray(eri.transpose(1,0,3,2), order='C') libfci.FCIpspace_h0tril(h0.ctypes.data_as(ctypes.c_void_p), h1e.ctypes.data_as(ctypes.c_void_p), eri.ctypes.data_as(ctypes.c_void_p), stra.ctypes.data_as(ctypes.c_void_p), strb.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(norb), ctypes.c_int(np)) idx = numpy.arange(np) h0[idx,idx] = hdiag[addr] return addr, h0 # be careful with single determinant initial guess. It may diverge the # preconditioner when the eigvalue of first davidson iter equals to hdiag def kernel(h1e, eri, norb, nelec, ci0=None, level_shift=1e-3, tol=1e-10, lindep=1e-14, max_cycle=50, max_space=12, nroots=1, davidson_only=False, pspace_size=400, orbsym=None, wfnsym=None, ecore=0, **kwargs): return _kfactory(FCISolver, h1e, eri, norb, nelec, ci0, level_shift, tol, lindep, max_cycle, max_space, nroots, davidson_only, pspace_size, ecore=ecore, **kwargs) def _kfactory(Solver, h1e, eri, norb, nelec, ci0=None, level_shift=1e-3, tol=1e-10, lindep=1e-14, max_cycle=50, max_space=12, nroots=1, davidson_only=False, pspace_size=400, ecore=0, **kwargs): cis = Solver(None) cis.level_shift = level_shift cis.conv_tol = tol cis.lindep = lindep cis.max_cycle = max_cycle cis.max_space = max_space cis.nroots = nroots cis.davidson_only = davidson_only cis.pspace_size = pspace_size unknown = {} for k in kwargs: if not hasattr(cis, k): unknown[k] = kwargs[k] setattr(cis, k, kwargs[k]) if unknown: sys.stderr.write('Unknown keys %s for FCI kernel %s\n' % (str(unknown.keys()), __name__)) e, c = cis.kernel(h1e, eri, norb, nelec, ci0, ecore=ecore, **unknown) return e, c def energy(h1e, eri, fcivec, norb, nelec, link_index=None): '''Compute the FCI electronic energy for given Hamiltonian and FCI vector. ''' h2e = absorb_h1e(h1e, eri, norb, nelec, .5) ci1 = contract_2e(h2e, fcivec, norb, nelec, link_index) return numpy.dot(fcivec.reshape(-1), ci1.reshape(-1)) def make_rdm1s(fcivec, norb, nelec, link_index=None): r'''Spin separated 1-particle density matrices. The return values include two density matrices: (alpha,alpha), (beta,beta) dm1[p,q] = <q^\dagger p> The convention is based on McWeeney's book, Eq (5.4.20). The contraction between 1-particle Hamiltonian and rdm1 is E = einsum('pq,qp', h1, rdm1) ''' if link_index is None: neleca, nelecb = _unpack_nelec(nelec) link_indexa = cistring.gen_linkstr_index(range(norb), neleca) link_indexb = cistring.gen_linkstr_index(range(norb), nelecb) link_index = (link_indexa, link_indexb) rdm1a = rdm.make_rdm1_spin1('FCImake_rdm1a', fcivec, fcivec, norb, nelec, link_index) rdm1b = rdm.make_rdm1_spin1('FCImake_rdm1b', fcivec, fcivec, norb, nelec, link_index) return rdm1a, rdm1b def make_rdm1(fcivec, norb, nelec, link_index=None): r'''Spin-traced one-particle density matrix dm1[p,q] = <q_alpha^\dagger p_alpha> + <q_beta^\dagger p_beta> The convention is based on McWeeney's book, Eq (5.4.20) The contraction between 1-particle Hamiltonian and rdm1 is E = einsum('pq,qp', h1, rdm1) ''' rdm1a, rdm1b = make_rdm1s(fcivec, norb, nelec, link_index) return rdm1a + rdm1b def make_rdm12s(fcivec, norb, nelec, link_index=None, reorder=True): r'''Spin separated 1- and 2-particle density matrices. The return values include two lists, a list of 1-particle density matrices and a list of 2-particle density matrices. The density matrices are: (alpha,alpha), (beta,beta) for 1-particle density matrices; (alpha,alpha,alpha,alpha), (alpha,alpha,beta,beta), (beta,beta,beta,beta) for 2-particle density matrices. 1pdm[p,q] = :math:`\langle q^\dagger p\rangle`; 2pdm[p,q,r,s] = :math:`\langle p^\dagger r^\dagger s q\rangle`. Energy should be computed as E = einsum('pq,qp', h1, 1pdm) + 1/2 * einsum('pqrs,pqrs', eri, 2pdm) where h1[p,q] = <p|h|q> and eri[p,q,r,s] = (pq|rs) ''' dm1a, dm2aa = rdm.make_rdm12_spin1('FCIrdm12kern_a', fcivec, fcivec, norb, nelec, link_index, 1) dm1b, dm2bb = rdm.make_rdm12_spin1('FCIrdm12kern_b', fcivec, fcivec, norb, nelec, link_index, 1) _, dm2ab = rdm.make_rdm12_spin1('FCItdm12kern_ab', fcivec, fcivec, norb, nelec, link_index, 0) if reorder: dm1a, dm2aa = rdm.reorder_rdm(dm1a, dm2aa, inplace=True) dm1b, dm2bb = rdm.reorder_rdm(dm1b, dm2bb, inplace=True) return (dm1a, dm1b), (dm2aa, dm2ab, dm2bb) def make_rdm12(fcivec, norb, nelec, link_index=None, reorder=True): r'''Spin traced 1- and 2-particle density matrices. 1pdm[p,q] = :math:`\langle q_\alpha^\dagger p_\alpha \rangle + \langle q_\beta^\dagger p_\beta \rangle`; 2pdm[p,q,r,s] = :math:`\langle p_\alpha^\dagger r_\alpha^\dagger s_\alpha q_\alpha\rangle + \langle p_\beta^\dagger r_\alpha^\dagger s_\alpha q_\beta\rangle + \langle p_\alpha^\dagger r_\beta^\dagger s_\beta q_\alpha\rangle + \langle p_\beta^\dagger r_\beta^\dagger s_\beta q_\beta\rangle`. Energy should be computed as E = einsum('pq,qp', h1, 1pdm) + 1/2 * einsum('pqrs,pqrs', eri, 2pdm) where h1[p,q] = <p|h|q> and eri[p,q,r,s] = (pq|rs) ''' #(dm1a, dm1b), (dm2aa, dm2ab, dm2bb) = \ # make_rdm12s(fcivec, norb, nelec, link_index, reorder) #return dm1a+dm1b, dm2aa+dm2ab+dm2ab.transpose(2,3,0,1)+dm2bb dm1, dm2 = rdm.make_rdm12_spin1('FCIrdm12kern_sf', fcivec, fcivec, norb, nelec, link_index, 1) if reorder: dm1, dm2 = rdm.reorder_rdm(dm1, dm2, inplace=True) return dm1, dm2 def trans_rdm1s(cibra, ciket, norb, nelec, link_index=None): r'''Spin separated transition 1-particle density matrices. The return values include two density matrices: (alpha,alpha), (beta,beta). See also function :func:`make_rdm1s` 1pdm[p,q] = :math:`\langle q^\dagger p \rangle` ''' rdm1a = rdm.make_rdm1_spin1('FCItrans_rdm1a', cibra, ciket, norb, nelec, link_index) rdm1b = rdm.make_rdm1_spin1('FCItrans_rdm1b', cibra, ciket, norb, nelec, link_index) return rdm1a, rdm1b def trans_rdm1(cibra, ciket, norb, nelec, link_index=None): r'''Spin traced transition 1-particle transition density matrices. 1pdm[p,q] = :math:`\langle q_\alpha^\dagger p_\alpha \rangle + \langle q_\beta^\dagger p_\beta \rangle` ''' rdm1a, rdm1b = trans_rdm1s(cibra, ciket, norb, nelec, link_index) return rdm1a + rdm1b def trans_rdm12s(cibra, ciket, norb, nelec, link_index=None, reorder=True): r'''Spin separated 1- and 2-particle transition density matrices. The return values include two lists, a list of 1-particle transition density matrices and a list of 2-particle transition density matrices. The density matrices are: (alpha,alpha), (beta,beta) for 1-particle transition density matrices; (alpha,alpha,alpha,alpha), (alpha,alpha,beta,beta), (beta,beta,alpha,alpha), (beta,beta,beta,beta) for 2-particle transition density matrices. 1pdm[p,q] = :math:`\langle q^\dagger p\rangle`; 2pdm[p,q,r,s] = :math:`\langle p^\dagger r^\dagger s q\rangle`. ''' dm1a, dm2aa = rdm.make_rdm12_spin1('FCItdm12kern_a', cibra, ciket, norb, nelec, link_index, 2) dm1b, dm2bb = rdm.make_rdm12_spin1('FCItdm12kern_b', cibra, ciket, norb, nelec, link_index, 2) _, dm2ab = rdm.make_rdm12_spin1('FCItdm12kern_ab', cibra, ciket, norb, nelec, link_index, 0) _, dm2ba = rdm.make_rdm12_spin1('FCItdm12kern_ab', ciket, cibra, norb, nelec, link_index, 0) dm2ba = dm2ba.transpose(3,2,1,0) if reorder: dm1a, dm2aa = rdm.reorder_rdm(dm1a, dm2aa, inplace=True) dm1b, dm2bb = rdm.reorder_rdm(dm1b, dm2bb, inplace=True) return (dm1a, dm1b), (dm2aa, dm2ab, dm2ba, dm2bb) def trans_rdm12(cibra, ciket, norb, nelec, link_index=None, reorder=True): r'''Spin traced transition 1- and 2-particle transition density matrices. 1pdm[p,q] = :math:`\langle q^\dagger p\rangle`; 2pdm[p,q,r,s] = :math:`\langle p^\dagger r^\dagger s q\rangle`. ''' #(dm1a, dm1b), (dm2aa, dm2ab, dm2ba, dm2bb) = \ # trans_rdm12s(cibra, ciket, norb, nelec, link_index, reorder) #return dm1a+dm1b, dm2aa+dm2ab+dm2ba+dm2bb dm1, dm2 = rdm.make_rdm12_spin1('FCItdm12kern_sf', cibra, ciket, norb, nelec, link_index, 2) if reorder: dm1, dm2 = rdm.reorder_rdm(dm1, dm2, inplace=True) return dm1, dm2 def _get_init_guess(na, nb, nroots, hdiag): '''Initial guess is the single Slater determinant ''' # The "nroots" lowest determinats based on energy expectation value. ci0 = [] try: addrs = numpy.argpartition(hdiag, nroots-1)[:nroots] except AttributeError: addrs = numpy.argsort(hdiag)[:nroots] for addr in addrs: x = numpy.zeros((na*nb)) x[addr] = 1 ci0.append(x.ravel()) # Add noise ci0[0][0 ] += 1e-5 ci0[0][-1] -= 1e-5 return ci0 def get_init_guess(norb, nelec, nroots, hdiag): '''Initial guess is the single Slater determinant ''' neleca, nelecb = _unpack_nelec(nelec) na = cistring.num_strings(norb, neleca) nb = cistring.num_strings(norb, nelecb) return _get_init_guess(na, nb, nroots, hdiag) ############################################################### # direct-CI driver ############################################################### def kernel_ms1(fci, h1e, eri, norb, nelec, ci0=None, link_index=None, tol=None, lindep=None, max_cycle=None, max_space=None, nroots=None, davidson_only=None, pspace_size=None, max_memory=None, verbose=None, ecore=0, **kwargs): if nroots is None: nroots = fci.nroots if davidson_only is None: davidson_only = fci.davidson_only if pspace_size is None: pspace_size = fci.pspace_size if max_memory is None: max_memory = fci.max_memory - lib.current_memory()[0] log = logger.new_logger(fci, verbose) nelec = _unpack_nelec(nelec, fci.spin) assert(0 <= nelec[0] <= norb and 0 <= nelec[1] <= norb) link_indexa, link_indexb = _unpack(norb, nelec, link_index) na = link_indexa.shape[0] nb = link_indexb.shape[0] if max_memory < na*nb*6*8e-6: log.warn('Not enough memory for FCI solver. ' 'The minimal requirement is %.0f MB', na*nb*60e-6) hdiag = fci.make_hdiag(h1e, eri, norb, nelec) nroots = min(hdiag.size, nroots) try: addr, h0 = fci.pspace(h1e, eri, norb, nelec, hdiag, max(pspace_size,nroots)) if pspace_size > 0: pw, pv = fci.eig(h0) else: pw = pv = None if pspace_size >= na*nb and ci0 is None and not davidson_only: # The degenerated wfn can break symmetry. The davidson iteration with proper # initial guess doesn't have this issue if na*nb == 1: return pw[0]+ecore, pv[:,0].reshape(1,1) elif nroots > 1: civec = numpy.empty((nroots,na*nb)) civec[:,addr] = pv[:,:nroots].T return pw[:nroots]+ecore, [c.reshape(na,nb) for c in civec] elif abs(pw[0]-pw[1]) > 1e-12: civec = numpy.empty((na*nb)) civec[addr] = pv[:,0] return pw[0]+ecore, civec.reshape(na,nb) except NotImplementedError: addr = [0] pw = pv = None precond = fci.make_precond(hdiag, pw, pv, addr) h2e = fci.absorb_h1e(h1e, eri, norb, nelec, .5) def hop(c): hc = fci.contract_2e(h2e, c, norb, nelec, (link_indexa,link_indexb)) return hc.ravel() if ci0 is None: if callable(getattr(fci, 'get_init_guess', None)): ci0 = lambda: fci.get_init_guess(norb, nelec, nroots, hdiag) else: def ci0(): # lazy initialization to reduce memory footprint x0 = [] for i in range(nroots): x = numpy.zeros(na*nb) x[addr[i]] = 1 x0.append(x) return x0 elif not callable(ci0): if isinstance(ci0, numpy.ndarray) and ci0.size == na*nb: ci0 = [ci0.ravel()] else: ci0 = [x.ravel() for x in ci0] # Add vectors if not enough initial guess is given if len(ci0) < nroots: if callable(getattr(fci, 'get_init_guess', None)): ci0.extend(fci.get_init_guess(norb, nelec, nroots, hdiag)[len(ci0):]) else: for i in range(len(ci0), nroots): x = numpy.zeros(na*nb) x[addr[i]] = 1 ci0.append(x) if tol is None: tol = fci.conv_tol if lindep is None: lindep = fci.lindep if max_cycle is None: max_cycle = fci.max_cycle if max_space is None: max_space = fci.max_space tol_residual = getattr(fci, 'conv_tol_residual', None) with lib.with_omp_threads(fci.threads): #e, c = lib.davidson(hop, ci0, precond, tol=fci.conv_tol, lindep=fci.lindep) e, c = fci.eig(hop, ci0, precond, tol=tol, lindep=lindep, max_cycle=max_cycle, max_space=max_space, nroots=nroots, max_memory=max_memory, verbose=log, follow_state=True, tol_residual=tol_residual, **kwargs) if nroots > 1: return e+ecore, [ci.reshape(na,nb) for ci in c] else: return e+ecore, c.reshape(na,nb) def make_pspace_precond(hdiag, pspaceig, pspaceci, addr, level_shift=0): # precondition with pspace Hamiltonian, CPL, 169, 463 def precond(r, e0, x0, *args): #h0e0 = h0 - numpy.eye(len(addr))*(e0-level_shift) h0e0inv = numpy.dot(pspaceci/(pspaceig-(e0-level_shift)), pspaceci.T) hdiaginv = 1/(hdiag - (e0-level_shift)) hdiaginv[abs(hdiaginv)>1e8] = 1e8 h0x0 = x0 * hdiaginv #h0x0[addr] = numpy.linalg.solve(h0e0, x0[addr]) h0x0[addr] = numpy.dot(h0e0inv, x0[addr]) h0r = r * hdiaginv #h0r[addr] = numpy.linalg.solve(h0e0, r[addr]) h0r[addr] = numpy.dot(h0e0inv, r[addr]) e1 = numpy.dot(x0, h0r) / numpy.dot(x0, h0x0) x1 = r - e1*x0 #pspace_x1 = x1[addr].copy() x1 *= hdiaginv # pspace (h0-e0)^{-1} cause diverging? #x1[addr] = numpy.linalg.solve(h0e0, pspace_x1) return x1 return precond def make_diag_precond(hdiag, pspaceig, pspaceci, addr, level_shift=0): return lib.make_diag_precond(hdiag, level_shift) class FCIBase(lib.StreamObject): '''Full CI solver Attributes: verbose : int Print level. Default value equals to :class:`Mole.verbose`. max_cycle : int Total number of iterations. Default is 100 max_space : tuple of int Davidson iteration space size. Default is 14. conv_tol : float Energy convergence tolerance. Default is 1e-10. level_shift : float Level shift applied in the preconditioner to avoid singularity. Default is 1e-3 davidson_only : bool By default, the entire Hamiltonian matrix will be constructed and diagonalized if the system is small (see attribute pspace_size). Setting this parameter to True will enforce the eigenvalue problems being solved by Davidson subspace algorithm. This flag should be enabled when initial guess is given or particular spin symmetry or point-group symmetry is required because the initial guess or symmetry are completely ignored in the direct diagonlization. pspace_size : int The dimension of Hamiltonian matrix over which Davidson iteration algorithm will be used for the eigenvalue problem. Default is 400. This is roughly corresponding to a (6e,6o) system. nroots : int Number of states to be solved. Default is 1, the ground state. spin : int or None Spin (2S = nalpha-nbeta) of the system. If this attribute is None, spin will be determined by the argument nelec (number of electrons) of the kernel function. wfnsym : str or int Symmetry of wavefunction. It is used only in direct_spin1_symm and direct_spin0_symm solver. Saved results eci : float or a list of float FCI energy(ies) ci : nparray FCI wfn vector(s) converged : bool (or a list of bool for multiple roots) Whether davidson iteration is converged Examples: >>> from pyscf import gto, scf, ao2mo, fci >>> mol = gto.M(atom='Li 0 0 0; Li 0 0 1', basis='sto-3g') >>> mf = scf.RHF(mol).run() >>> h1 = mf.mo_coeff.T.dot(mf.get_hcore()).dot(mf.mo_coeff) >>> eri = ao2mo.kernel(mol, mf.mo_coeff) >>> cisolver = fci.direct_spin1.FCI(mol) >>> e, ci = cisolver.kernel(h1, eri, h1.shape[1], mol.nelec, ecore=mol.energy_nuc()) >>> print(e) -14.4197890826 ''' max_cycle = getattr(__config__, 'fci_direct_spin1_FCI_max_cycle', 100) max_space = getattr(__config__, 'fci_direct_spin1_FCI_max_space', 12) conv_tol = getattr(__config__, 'fci_direct_spin1_FCI_conv_tol', 1e-10) conv_tol_residual = getattr(__config__, 'fci_direct_spin1_FCI_conv_tol_residual', None) lindep = getattr(__config__, 'fci_direct_spin1_FCI_lindep', 1e-14) # level shift in precond level_shift = getattr(__config__, 'fci_direct_spin1_FCI_level_shift', 1e-3) # force the diagonlization use davidson iteration. When the CI space # is small, the solver exactly diagonlizes the Hamiltonian. But this # solution will ignore the initial guess. Setting davidson_only can # enforce the solution on the initial guess state davidson_only = getattr(__config__, 'fci_direct_spin1_FCI_davidson_only', False) pspace_size = getattr(__config__, 'fci_direct_spin1_FCI_pspace_size', 400) threads = getattr(__config__, 'fci_direct_spin1_FCI_threads', None) lessio = getattr(__config__, 'fci_direct_spin1_FCI_lessio', False) def __init__(self, mol=None): if mol is None: self.stdout = sys.stdout self.verbose = logger.NOTE self.max_memory = lib.param.MAX_MEMORY else: self.stdout = mol.stdout self.verbose = mol.verbose self.max_memory = mol.max_memory self.mol = mol self.nroots = 1 self.spin = None # Initialize symmetry attributes for the compatibility with direct_spin1_symm # solver. They are not used by direct_spin1 solver. self.orbsym = None self.wfnsym = None self.converged = False self.norb = None self.nelec = None self.eci = None self.ci = None keys = set(('max_cycle', 'max_space', 'conv_tol', 'lindep', 'level_shift', 'davidson_only', 'pspace_size', 'threads', 'lessio')) self._keys = set(self.__dict__.keys()).union(keys) @property def e_tot(self): return self.eci @property def nstates(self): return self.nroots @nstates.setter def nstates(self, x): self.nroots = x def dump_flags(self, verbose=None): log = logger.new_logger(self, verbose) log.info('******** %s ********', self.__class__) log.info('max. cycles = %d', self.max_cycle) log.info('conv_tol = %g', self.conv_tol) log.info('davidson only = %s', self.davidson_only) log.info('linear dependence = %g', self.lindep) log.info('level shift = %g', self.level_shift) log.info('max iter space = %d', self.max_space) log.info('max_memory %d MB', self.max_memory) log.info('nroots = %d', self.nroots) log.info('pspace_size = %d', self.pspace_size) log.info('spin = %s', self.spin) return self @lib.with_doc(absorb_h1e.__doc__) def absorb_h1e(self, h1e, eri, norb, nelec, fac=1): nelec = _unpack_nelec(nelec, self.spin) return absorb_h1e(h1e, eri, norb, nelec, fac) @lib.with_doc(make_hdiag.__doc__) def make_hdiag(self, h1e, eri, norb, nelec): nelec = _unpack_nelec(nelec, self.spin) return make_hdiag(h1e, eri, norb, nelec) @lib.with_doc(pspace.__doc__) def pspace(self, h1e, eri, norb, nelec, hdiag=None, np=400): nelec = _unpack_nelec(nelec, self.spin) return pspace(h1e, eri, norb, nelec, hdiag, np) @lib.with_doc(contract_1e.__doc__) def contract_1e(self, f1e, fcivec, norb, nelec, link_index=None, **kwargs): nelec = _unpack_nelec(nelec, self.spin) return contract_1e(f1e, fcivec, norb, nelec, link_index, **kwargs) @lib.with_doc(contract_2e.__doc__) def contract_2e(self, eri, fcivec, norb, nelec, link_index=None, **kwargs): nelec = _unpack_nelec(nelec, self.spin) return contract_2e(eri, fcivec, norb, nelec, link_index, **kwargs) def eig(self, op, x0=None, precond=None, **kwargs): if isinstance(op, numpy.ndarray): self.converged = True return scipy.linalg.eigh(op) self.converged, e, ci = \ lib.davidson1(lambda xs: [op(x) for x in xs], x0, precond, lessio=self.lessio, **kwargs) if kwargs['nroots'] == 1: self.converged = self.converged[0] e = e[0] ci = ci[0] return e, ci def make_precond(self, hdiag, pspaceig, pspaceci, addr): if pspaceig is None: return make_diag_precond(hdiag, pspaceig, pspaceci, addr, self.level_shift) else: return make_pspace_precond(hdiag, pspaceig, pspaceci, addr, self.level_shift) @lib.with_doc(get_init_guess.__doc__) def get_init_guess(self, norb, nelec, nroots, hdiag): return get_init_guess(norb, nelec, nroots, hdiag) def kernel(self, h1e, eri, norb, nelec, ci0=None, tol=None, lindep=None, max_cycle=None, max_space=None, nroots=None, davidson_only=None, pspace_size=None, orbsym=None, wfnsym=None, ecore=0, **kwargs): if self.verbose >= logger.WARN: self.check_sanity() self.norb = norb self.nelec = nelec self.eci, self.ci = \ kernel_ms1(self, h1e, eri, norb, nelec, ci0, None, tol, lindep, max_cycle, max_space, nroots, davidson_only, pspace_size, ecore=ecore, **kwargs) return self.eci, self.ci @lib.with_doc(energy.__doc__) def energy(self, h1e, eri, fcivec, norb, nelec, link_index=None): nelec = _unpack_nelec(nelec, self.spin) h2e = self.absorb_h1e(h1e, eri, norb, nelec, .5) ci1 = self.contract_2e(h2e, fcivec, norb, nelec, link_index) return numpy.dot(fcivec.reshape(-1), ci1.reshape(-1)) def spin_square(self, fcivec, norb, nelec): nelec = _unpack_nelec(nelec, self.spin) return spin_op.spin_square0(fcivec, norb, nelec) spin_square.__doc__ = spin_op.spin_square0.__doc__ @lib.with_doc(make_rdm1s.__doc__) def make_rdm1s(self, fcivec, norb, nelec, link_index=None): nelec = _unpack_nelec(nelec, self.spin) return make_rdm1s(fcivec, norb, nelec, link_index) @lib.with_doc(make_rdm1.__doc__) def make_rdm1(self, fcivec, norb, nelec, link_index=None): nelec = _unpack_nelec(nelec, self.spin) return make_rdm1(fcivec, norb, nelec, link_index) @lib.with_doc(make_rdm12s.__doc__) def make_rdm12s(self, fcivec, norb, nelec, link_index=None, reorder=True): nelec = _unpack_nelec(nelec, self.spin) return make_rdm12s(fcivec, norb, nelec, link_index, reorder) @lib.with_doc(make_rdm12.__doc__) def make_rdm12(self, fcivec, norb, nelec, link_index=None, reorder=True): nelec = _unpack_nelec(nelec, self.spin) return make_rdm12(fcivec, norb, nelec, link_index, reorder) def make_rdm2(self, fcivec, norb, nelec, link_index=None, reorder=True): r'''Spin traced 2-particle density matrice NOTE the 2pdm is :math:`\langle p^\dagger q^\dagger s r\rangle` but stored as [p,r,q,s] ''' nelec = _unpack_nelec(nelec, self.spin) return self.make_rdm12(fcivec, norb, nelec, link_index, reorder)[1] @lib.with_doc(trans_rdm1s.__doc__) def trans_rdm1s(self, cibra, ciket, norb, nelec, link_index=None): nelec = _unpack_nelec(nelec, self.spin) return trans_rdm1s(cibra, ciket, norb, nelec, link_index) @lib.with_doc(trans_rdm1.__doc__) def trans_rdm1(self, cibra, ciket, norb, nelec, link_index=None): nelec = _unpack_nelec(nelec, self.spin) return trans_rdm1(cibra, ciket, norb, nelec, link_index) @lib.with_doc(trans_rdm12s.__doc__) def trans_rdm12s(self, cibra, ciket, norb, nelec, link_index=None, reorder=True): nelec = _unpack_nelec(nelec, self.spin) return trans_rdm12s(cibra, ciket, norb, nelec, link_index, reorder) @lib.with_doc(trans_rdm12.__doc__) def trans_rdm12(self, cibra, ciket, norb, nelec, link_index=None, reorder=True): nelec = _unpack_nelec(nelec, self.spin) return trans_rdm12(cibra, ciket, norb, nelec, link_index, reorder) def large_ci(self, fcivec, norb, nelec, tol=getattr(__config__, 'fci_addons_large_ci_tol', .1), return_strs=getattr(__config__, 'fci_addons_large_ci_return_strs', True)): nelec = _unpack_nelec(nelec, self.spin) return addons.large_ci(fcivec, norb, nelec, tol, return_strs) def contract_ss(self, fcivec, norb, nelec): # noqa: F811 from pyscf.fci import spin_op nelec = _unpack_nelec(nelec, self.spin) return spin_op.contract_ss(fcivec, norb, nelec) def gen_linkstr(self, norb, nelec, tril=True, spin=None): if spin is None: spin = self.spin neleca, nelecb = _unpack_nelec(nelec, spin) if tril: link_indexa = cistring.gen_linkstr_index_trilidx(range(norb), neleca) link_indexb = cistring.gen_linkstr_index_trilidx(range(norb), nelecb) else: link_indexa = cistring.gen_linkstr_index(range(norb), neleca) link_indexb = cistring.gen_linkstr_index(range(norb), nelecb) return link_indexa, link_indexb class FCISolver(FCIBase): # transform_ci_for_orbital_rotation only available for FCI wavefunctions. # Some approx FCI solver does not have this functionality. def transform_ci_for_orbital_rotation(self, fcivec, norb, nelec, u): nelec = _unpack_nelec(nelec, self.spin) return addons.transform_ci_for_orbital_rotation(fcivec, norb, nelec, u) FCI = FCISolver def _unpack(norb, nelec, link_index, spin=None): if link_index is None: neleca, nelecb = _unpack_nelec(nelec, spin) link_indexa = link_indexb = cistring.gen_linkstr_index_trilidx(range(norb), neleca) if neleca != nelecb: link_indexb = cistring.gen_linkstr_index_trilidx(range(norb), nelecb) return link_indexa, link_indexb else: return link_index if __name__ == '__main__': from functools import reduce from pyscf import gto from pyscf import scf mol = gto.Mole() mol.verbose = 0 mol.output = None#"out_h2o" mol.atom = [ ['H', ( 1.,-1. , 0. )], ['H', ( 0.,-1. ,-1. )], ['H', ( 1.,-0.5 ,-1. )], #['H', ( 0.,-0.5 ,-1. )], #['H', ( 0.,-0.5 ,-0. )], ['H', ( 0.,-0. ,-1. )], ['H', ( 1.,-0.5 , 0. )], ['H', ( 0., 1. , 1. )], ] mol.basis = {'H': 'sto-3g'} mol.build() m = scf.RHF(mol) ehf = m.scf() cis = FCISolver(mol) norb = m.mo_coeff.shape[1] nelec = mol.nelectron - 2 h1e = reduce(numpy.dot, (m.mo_coeff.T, m.get_hcore(), m.mo_coeff)) eri = ao2mo.incore.general(m._eri, (m.mo_coeff,)*4, compact=False) eri = eri.reshape(norb,norb,norb,norb) nea = nelec//2 + 1 neb = nelec//2 - 1 nelec = (nea, neb) e1 = cis.kernel(h1e, eri, norb, nelec, davidson_only=True)[0] print(e1, e1 - -7.7466756526056004)
sunqm/pyscf
pyscf/fci/direct_spin1.py
Python
apache-2.0
38,662
[ "PySCF" ]
c2ea6295a6c86b4c2838d4ad4ba315e6ab56c18646c2376dcd87d9d89d961217
# # Parse tree nodes for expressions # import cython cython.declare(error=object, warning=object, warn_once=object, InternalError=object, CompileError=object, UtilityCode=object, StringEncoding=object, operator=object, Naming=object, Nodes=object, PyrexTypes=object, py_object_type=object, list_type=object, tuple_type=object, set_type=object, dict_type=object, \ unicode_type=object, str_type=object, bytes_type=object, type_type=object, Builtin=object, Symtab=object, Utils=object, find_coercion_error=object, debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object) import operator from Errors import error, warning, warn_once, InternalError, CompileError from Errors import hold_errors, release_errors, held_errors, report_error from Code import UtilityCode import StringEncoding import Naming import Nodes from Nodes import Node import PyrexTypes from PyrexTypes import py_object_type, c_long_type, typecast, error_type, \ unspecified_type, cython_memoryview_ptr_type import TypeSlots from Builtin import list_type, tuple_type, set_type, dict_type, \ unicode_type, str_type, bytes_type, type_type import Builtin import Symtab import Options from Cython import Utils from Annotate import AnnotationItem from Cython.Debugging import print_call_chain from DebugFlags import debug_disposal_code, debug_temp_alloc, \ debug_coercion try: from __builtin__ import basestring except ImportError: basestring = str # Python 3 class NotConstant(object): def __repr__(self): return "<NOT CONSTANT>" not_a_constant = NotConstant() constant_value_not_set = object() # error messages when coercing from key[0] to key[1] find_coercion_error = { # string related errors (Builtin.unicode_type, Builtin.bytes_type) : "Cannot convert Unicode string to 'bytes' implicitly, encoding required.", (Builtin.unicode_type, Builtin.str_type) : "Cannot convert Unicode string to 'str' implicitly. This is not portable and requires explicit encoding.", (Builtin.unicode_type, PyrexTypes.c_char_ptr_type) : "Unicode objects do not support coercion to C types.", (Builtin.bytes_type, Builtin.unicode_type) : "Cannot convert 'bytes' object to unicode implicitly, decoding required", (Builtin.bytes_type, Builtin.str_type) : "Cannot convert 'bytes' object to str implicitly. This is not portable to Py3.", (Builtin.str_type, Builtin.unicode_type) : "str objects do not support coercion to unicode, use a unicode string literal instead (u'')", (Builtin.str_type, Builtin.bytes_type) : "Cannot convert 'str' to 'bytes' implicitly. This is not portable.", (Builtin.str_type, PyrexTypes.c_char_ptr_type) : "'str' objects do not support coercion to C types (use 'bytes'?).", (PyrexTypes.c_char_ptr_type, Builtin.unicode_type) : "Cannot convert 'char*' to unicode implicitly, decoding required", (PyrexTypes.c_uchar_ptr_type, Builtin.unicode_type) : "Cannot convert 'char*' to unicode implicitly, decoding required", }.get class ExprNode(Node): # subexprs [string] Class var holding names of subexpr node attrs # type PyrexType Type of the result # result_code string Code fragment # result_ctype string C type of result_code if different from type # is_temp boolean Result is in a temporary variable # is_sequence_constructor # boolean Is a list or tuple constructor expression # is_starred boolean Is a starred expression (e.g. '*a') # saved_subexpr_nodes # [ExprNode or [ExprNode or None] or None] # Cached result of subexpr_nodes() # use_managed_ref boolean use ref-counted temps/assignments/etc. # result_is_used boolean indicates that the result will be dropped and the # result_code/temp_result can safely be set to None result_ctype = None type = None temp_code = None old_temp = None # error checker for multiple frees etc. use_managed_ref = True # can be set by optimisation transforms result_is_used = True # The Analyse Expressions phase for expressions is split # into two sub-phases: # # Analyse Types # Determines the result type of the expression based # on the types of its sub-expressions, and inserts # coercion nodes into the expression tree where needed. # Marks nodes which will need to have temporary variables # allocated. # # Allocate Temps # Allocates temporary variables where needed, and fills # in the result_code field of each node. # # ExprNode provides some convenience routines which # perform both of the above phases. These should only # be called from statement nodes, and only when no # coercion nodes need to be added around the expression # being analysed. In that case, the above two phases # should be invoked separately. # # Framework code in ExprNode provides much of the common # processing for the various phases. It makes use of the # 'subexprs' class attribute of ExprNodes, which should # contain a list of the names of attributes which can # hold sub-nodes or sequences of sub-nodes. # # The framework makes use of a number of abstract methods. # Their responsibilities are as follows. # # Declaration Analysis phase # # analyse_target_declaration # Called during the Analyse Declarations phase to analyse # the LHS of an assignment or argument of a del statement. # Nodes which cannot be the LHS of an assignment need not # implement it. # # Expression Analysis phase # # analyse_types # - Call analyse_types on all sub-expressions. # - Check operand types, and wrap coercion nodes around # sub-expressions where needed. # - Set the type of this node. # - If a temporary variable will be required for the # result, set the is_temp flag of this node. # # analyse_target_types # Called during the Analyse Types phase to analyse # the LHS of an assignment or argument of a del # statement. Similar responsibilities to analyse_types. # # target_code # Called by the default implementation of allocate_target_temps. # Should return a C lvalue for assigning to the node. The default # implementation calls calculate_result_code. # # check_const # - Check that this node and its subnodes form a # legal constant expression. If so, do nothing, # otherwise call not_const. # # The default implementation of check_const # assumes that the expression is not constant. # # check_const_addr # - Same as check_const, except check that the # expression is a C lvalue whose address is # constant. Otherwise, call addr_not_const. # # The default implementation of calc_const_addr # assumes that the expression is not a constant # lvalue. # # Code Generation phase # # generate_evaluation_code # - Call generate_evaluation_code for sub-expressions. # - Perform the functions of generate_result_code # (see below). # - If result is temporary, call generate_disposal_code # on all sub-expressions. # # A default implementation of generate_evaluation_code # is provided which uses the following abstract methods: # # generate_result_code # - Generate any C statements necessary to calculate # the result of this node from the results of its # sub-expressions. # # calculate_result_code # - Should return a C code fragment evaluating to the # result. This is only called when the result is not # a temporary. # # generate_assignment_code # Called on the LHS of an assignment. # - Call generate_evaluation_code for sub-expressions. # - Generate code to perform the assignment. # - If the assignment absorbed a reference, call # generate_post_assignment_code on the RHS, # otherwise call generate_disposal_code on it. # # generate_deletion_code # Called on an argument of a del statement. # - Call generate_evaluation_code for sub-expressions. # - Generate code to perform the deletion. # - Call generate_disposal_code on all sub-expressions. # # is_sequence_constructor = 0 is_string_literal = 0 is_attribute = 0 saved_subexpr_nodes = None is_temp = 0 is_target = 0 is_starred = 0 constant_result = constant_value_not_set try: _get_child_attrs = operator.attrgetter('subexprs') except AttributeError: # Python 2.3 def __get_child_attrs(self): return self.subexprs _get_child_attrs = __get_child_attrs child_attrs = property(fget=_get_child_attrs) def not_implemented(self, method_name): print_call_chain(method_name, "not implemented") ### raise InternalError( "%s.%s not implemented" % (self.__class__.__name__, method_name)) def is_lvalue(self): return 0 def is_ephemeral(self): # An ephemeral node is one whose result is in # a Python temporary and we suspect there are no # other references to it. Certain operations are # disallowed on such values, since they are # likely to result in a dangling pointer. return self.type.is_pyobject and self.is_temp def subexpr_nodes(self): # Extract a list of subexpression nodes based # on the contents of the subexprs class attribute. nodes = [] for name in self.subexprs: item = getattr(self, name) if item is not None: if type(item) is list: nodes.extend(item) else: nodes.append(item) return nodes def result(self): if self.is_temp: return self.temp_code else: return self.calculate_result_code() def result_as(self, type = None): # Return the result code cast to the specified C type. return typecast(type, self.ctype(), self.result()) def py_result(self): # Return the result code cast to PyObject *. return self.result_as(py_object_type) def ctype(self): # Return the native C type of the result (i.e. the # C type of the result_code expression). return self.result_ctype or self.type def get_constant_c_result_code(self): # Return the constant value of this node as a result code # string, or None if the node is not constant. This method # can be called when the constant result code is required # before the code generation phase. # # The return value is a string that can represent a simple C # value, a constant C name or a constant C expression. If the # node type depends on Python code, this must return None. return None def calculate_constant_result(self): # Calculate the constant compile time result value of this # expression and store it in ``self.constant_result``. Does # nothing by default, thus leaving ``self.constant_result`` # unknown. If valid, the result can be an arbitrary Python # value. # # This must only be called when it is assured that all # sub-expressions have a valid constant_result value. The # ConstantFolding transform will do this. pass def has_constant_result(self): return self.constant_result is not constant_value_not_set and \ self.constant_result is not not_a_constant def compile_time_value(self, denv): # Return value of compile-time expression, or report error. error(self.pos, "Invalid compile-time expression") def compile_time_value_error(self, e): error(self.pos, "Error in compile-time expression: %s: %s" % ( e.__class__.__name__, e)) # ------------- Declaration Analysis ---------------- def analyse_target_declaration(self, env): error(self.pos, "Cannot assign to or delete this") # ------------- Expression Analysis ---------------- def analyse_const_expression(self, env): # Called during the analyse_declarations phase of a # constant expression. Analyses the expression's type, # checks whether it is a legal const expression, # and determines its value. self.analyse_types(env) return self.check_const() def analyse_expressions(self, env): # Convenience routine performing both the Type # Analysis and Temp Allocation phases for a whole # expression. self.analyse_types(env) def analyse_target_expression(self, env, rhs): # Convenience routine performing both the Type # Analysis and Temp Allocation phases for the LHS of # an assignment. self.analyse_target_types(env) def analyse_boolean_expression(self, env): # Analyse expression and coerce to a boolean. self.analyse_types(env) bool = self.coerce_to_boolean(env) return bool def analyse_temp_boolean_expression(self, env): # Analyse boolean expression and coerce result into # a temporary. This is used when a branch is to be # performed on the result and we won't have an # opportunity to ensure disposal code is executed # afterwards. By forcing the result into a temporary, # we ensure that all disposal has been done by the # time we get the result. self.analyse_types(env) return self.coerce_to_boolean(env).coerce_to_simple(env) # --------------- Type Inference ----------------- def type_dependencies(self, env): # Returns the list of entries whose types must be determined # before the type of self can be infered. if hasattr(self, 'type') and self.type is not None: return () return sum([node.type_dependencies(env) for node in self.subexpr_nodes()], ()) def infer_type(self, env): # Attempt to deduce the type of self. # Differs from analyse_types as it avoids unnecessary # analysis of subexpressions, but can assume everything # in self.type_dependencies() has been resolved. if hasattr(self, 'type') and self.type is not None: return self.type elif hasattr(self, 'entry') and self.entry is not None: return self.entry.type else: self.not_implemented("infer_type") def nonlocally_immutable(self): # Returns whether this variable is a safe reference, i.e. # can't be modified as part of globals or closures. return self.is_temp or self.type.is_array or self.type.is_cfunction # --------------- Type Analysis ------------------ def analyse_as_module(self, env): # If this node can be interpreted as a reference to a # cimported module, return its scope, else None. return None def analyse_as_type(self, env): # If this node can be interpreted as a reference to a # type, return that type, else None. return None def analyse_as_extension_type(self, env): # If this node can be interpreted as a reference to an # extension type, return its type, else None. return None def analyse_types(self, env): self.not_implemented("analyse_types") def analyse_target_types(self, env): self.analyse_types(env) def nogil_check(self, env): # By default, any expression based on Python objects is # prevented in nogil environments. Subtypes must override # this if they can work without the GIL. if self.type and self.type.is_pyobject: self.gil_error() def gil_assignment_check(self, env): if env.nogil and self.type.is_pyobject: error(self.pos, "Assignment of Python object not allowed without gil") def check_const(self): self.not_const() return False def not_const(self): error(self.pos, "Not allowed in a constant expression") def check_const_addr(self): self.addr_not_const() return False def addr_not_const(self): error(self.pos, "Address is not constant") # ----------------- Result Allocation ----------------- def result_in_temp(self): # Return true if result is in a temporary owned by # this node or one of its subexpressions. Overridden # by certain nodes which can share the result of # a subnode. return self.is_temp def target_code(self): # Return code fragment for use as LHS of a C assignment. return self.calculate_result_code() def calculate_result_code(self): self.not_implemented("calculate_result_code") # def release_target_temp(self, env): # # Release temporaries used by LHS of an assignment. # self.release_subexpr_temps(env) def allocate_temp_result(self, code): if self.temp_code: raise RuntimeError("Temp allocated multiple times in %r: %r" % (self.__class__.__name__, self.pos)) type = self.type if not type.is_void: if type.is_pyobject: type = PyrexTypes.py_object_type self.temp_code = code.funcstate.allocate_temp( type, manage_ref=self.use_managed_ref) else: self.temp_code = None def release_temp_result(self, code): if not self.temp_code: if not self.result_is_used: # not used anyway, so ignore if not set up return if self.old_temp: raise RuntimeError("temp %s released multiple times in %s" % ( self.old_temp, self.__class__.__name__)) else: raise RuntimeError("no temp, but release requested in %s" % ( self.__class__.__name__)) code.funcstate.release_temp(self.temp_code) self.old_temp = self.temp_code self.temp_code = None # ---------------- Code Generation ----------------- def make_owned_reference(self, code): # If result is a pyobject, make sure we own # a reference to it. if self.type.is_pyobject and not self.result_in_temp(): code.put_incref(self.result(), self.ctype()) def generate_evaluation_code(self, code): code.mark_pos(self.pos) # Generate code to evaluate this node and # its sub-expressions, and dispose of any # temporary results of its sub-expressions. self.generate_subexpr_evaluation_code(code) if self.is_temp: self.allocate_temp_result(code) self.generate_result_code(code) if self.is_temp: # If we are temp we do not need to wait until this node is disposed # before disposing children. self.generate_subexpr_disposal_code(code) self.free_subexpr_temps(code) def generate_subexpr_evaluation_code(self, code): for node in self.subexpr_nodes(): node.generate_evaluation_code(code) def generate_result_code(self, code): self.not_implemented("generate_result_code") def generate_disposal_code(self, code): if self.is_temp: if self.result(): if self.type.is_pyobject: code.put_decref_clear(self.result(), self.ctype()) elif self.type.is_memoryviewslice: code.put_xdecref_memoryviewslice( self.result(), have_gil=not self.in_nogil_context) else: # Already done if self.is_temp self.generate_subexpr_disposal_code(code) def generate_subexpr_disposal_code(self, code): # Generate code to dispose of temporary results # of all sub-expressions. for node in self.subexpr_nodes(): node.generate_disposal_code(code) def generate_post_assignment_code(self, code): if self.is_temp: if self.type.is_pyobject: code.putln("%s = 0;" % self.result()) elif self.type.is_memoryviewslice: code.putln("%s.memview = NULL;" % self.result()) code.putln("%s.data = NULL;" % self.result()) else: self.generate_subexpr_disposal_code(code) def generate_assignment_code(self, rhs, code): # Stub method for nodes which are not legal as # the LHS of an assignment. An error will have # been reported earlier. pass def generate_deletion_code(self, code): # Stub method for nodes that are not legal as # the argument of a del statement. An error # will have been reported earlier. pass def free_temps(self, code): if self.is_temp: if not self.type.is_void: self.release_temp_result(code) else: self.free_subexpr_temps(code) def free_subexpr_temps(self, code): for sub in self.subexpr_nodes(): sub.free_temps(code) def generate_function_definitions(self, env, code): pass # ---------------- Annotation --------------------- def annotate(self, code): for node in self.subexpr_nodes(): node.annotate(code) # ----------------- Coercion ---------------------- def coerce_to(self, dst_type, env): # Coerce the result so that it can be assigned to # something of type dst_type. If processing is necessary, # wraps this node in a coercion node and returns that. # Otherwise, returns this node unchanged. # # This method is called during the analyse_expressions # phase of the src_node's processing. # # Note that subclasses that override this (especially # ConstNodes) must not (re-)set their own .type attribute # here. Since expression nodes may turn up in different # places in the tree (e.g. inside of CloneNodes in cascaded # assignments), this method must return a new node instance # if it changes the type. # src = self src_type = self.type src_is_py_type = src_type.is_pyobject dst_is_py_type = dst_type.is_pyobject if self.check_for_coercion_error(dst_type): return self if dst_type.is_reference: dst_type = dst_type.ref_base_type if self.coercion_type is not None: # This is purely for error checking purposes! node = NameNode(self.pos, name='', type=self.coercion_type) node.coerce_to(dst_type, env) if dst_type.is_memoryviewslice: import MemoryView if not src.type.is_memoryviewslice: if src.type.is_pyobject: src = CoerceToMemViewSliceNode(src, dst_type, env) else: error(self.pos, "Cannot convert '%s' to memoryviewslice" % (src_type,)) elif not MemoryView.src_conforms_to_dst(src.type, dst_type): if src.type.dtype.same_as(dst_type.dtype): msg = "Memoryview '%s' not conformable to memoryview '%s'." tup = src.type, dst_type else: msg = "Different base types for memoryviews (%s, %s)" tup = src.type.dtype, dst_type.dtype error(self.pos, msg % tup) elif dst_type.is_pyobject: if not src.type.is_pyobject: if dst_type is bytes_type and src.type.is_int: src = CoerceIntToBytesNode(src, env) else: src = CoerceToPyTypeNode(src, env) if not src.type.subtype_of(dst_type): if not isinstance(src, NoneNode): src = PyTypeTestNode(src, dst_type, env) elif src.type.is_pyobject: src = CoerceFromPyTypeNode(dst_type, src, env) elif (dst_type.is_complex and src_type != dst_type and dst_type.assignable_from(src_type)): src = CoerceToComplexNode(src, dst_type, env) else: # neither src nor dst are py types # Added the string comparison, since for c types that # is enough, but Cython gets confused when the types are # in different pxi files. if not (str(src.type) == str(dst_type) or dst_type.assignable_from(src_type)): self.fail_assignment(dst_type) return src def fail_assignment(self, dst_type): error(self.pos, "Cannot assign type '%s' to '%s'" % (self.type, dst_type)) def check_for_coercion_error(self, dst_type, fail=False, default=None): if fail and not default: default = "Cannot assign type '%(FROM)s' to '%(TO)s'" message = find_coercion_error((self.type, dst_type), default) if message is not None: error(self.pos, message % {'FROM': self.type, 'TO': dst_type}) return True if fail: self.fail_assignment(dst_type) return True return False def coerce_to_pyobject(self, env): return self.coerce_to(PyrexTypes.py_object_type, env) def coerce_to_boolean(self, env): # Coerce result to something acceptable as # a boolean value. # if it's constant, calculate the result now if self.has_constant_result(): bool_value = bool(self.constant_result) return BoolNode(self.pos, value=bool_value, constant_result=bool_value) type = self.type if type.is_pyobject or type.is_ptr or type.is_float: return CoerceToBooleanNode(self, env) else: if not (type.is_int or type.is_enum or type.is_error): error(self.pos, "Type '%s' not acceptable as a boolean" % type) return self def coerce_to_integer(self, env): # If not already some C integer type, coerce to longint. if self.type.is_int: return self else: return self.coerce_to(PyrexTypes.c_long_type, env) def coerce_to_temp(self, env): # Ensure that the result is in a temporary. if self.result_in_temp(): return self else: return CoerceToTempNode(self, env) def coerce_to_simple(self, env): # Ensure that the result is simple (see is_simple). if self.is_simple(): return self else: return self.coerce_to_temp(env) def is_simple(self): # A node is simple if its result is something that can # be referred to without performing any operations, e.g. # a constant, local var, C global var, struct member # reference, or temporary. return self.result_in_temp() def may_be_none(self): if self.type and not self.type.is_pyobject: return False if self.constant_result not in (not_a_constant, constant_value_not_set): return self.constant_result is not None return True def as_cython_attribute(self): return None def as_none_safe_node(self, message, error="PyExc_TypeError", format_args=()): # Wraps the node in a NoneCheckNode if it is not known to be # not-None (e.g. because it is a Python literal). if self.may_be_none(): return NoneCheckNode(self, error, message, format_args) else: return self class AtomicExprNode(ExprNode): # Abstract base class for expression nodes which have # no sub-expressions. subexprs = [] # Override to optimize -- we know we have no children def generate_subexpr_evaluation_code(self, code): pass def generate_subexpr_disposal_code(self, code): pass class PyConstNode(AtomicExprNode): # Abstract base class for constant Python values. is_literal = 1 type = py_object_type def is_simple(self): return 1 def may_be_none(self): return False def analyse_types(self, env): pass def calculate_result_code(self): return self.value def generate_result_code(self, code): pass class NoneNode(PyConstNode): # The constant value None is_none = 1 value = "Py_None" constant_result = None nogil_check = None def compile_time_value(self, denv): return None def may_be_none(self): return True class EllipsisNode(PyConstNode): # '...' in a subscript list. value = "Py_Ellipsis" constant_result = Ellipsis def compile_time_value(self, denv): return Ellipsis class ConstNode(AtomicExprNode): # Abstract base type for literal constant nodes. # # value string C code fragment is_literal = 1 nogil_check = None def is_simple(self): return 1 def nonlocally_immutable(self): return 1 def may_be_none(self): return False def analyse_types(self, env): pass # Types are held in class variables def check_const(self): return True def get_constant_c_result_code(self): return self.calculate_result_code() def calculate_result_code(self): return str(self.value) def generate_result_code(self, code): pass class BoolNode(ConstNode): type = PyrexTypes.c_bint_type # The constant value True or False def calculate_constant_result(self): self.constant_result = self.value def compile_time_value(self, denv): return self.value def calculate_result_code(self): return str(int(self.value)) class NullNode(ConstNode): type = PyrexTypes.c_null_ptr_type value = "NULL" constant_result = 0 def get_constant_c_result_code(self): return self.value class CharNode(ConstNode): type = PyrexTypes.c_char_type def calculate_constant_result(self): self.constant_result = ord(self.value) def compile_time_value(self, denv): return ord(self.value) def calculate_result_code(self): return "'%s'" % StringEncoding.escape_char(self.value) class IntNode(ConstNode): # unsigned "" or "U" # longness "" or "L" or "LL" # is_c_literal True/False/None creator considers this a C integer literal unsigned = "" longness = "" is_c_literal = None # unknown def __init__(self, pos, **kwds): ExprNode.__init__(self, pos, **kwds) if 'type' not in kwds: self.type = self.find_suitable_type_for_value() def find_suitable_type_for_value(self): if self.constant_result is constant_value_not_set: try: self.calculate_constant_result() except ValueError: pass # we ignore 'is_c_literal = True' and instead map signed 32bit # integers as C long values if self.is_c_literal or \ self.constant_result in (constant_value_not_set, not_a_constant) or \ self.unsigned or self.longness == 'LL': # clearly a C literal rank = (self.longness == 'LL') and 2 or 1 suitable_type = PyrexTypes.modifiers_and_name_to_type[not self.unsigned, rank, "int"] if self.type: suitable_type = PyrexTypes.widest_numeric_type(suitable_type, self.type) else: # C literal or Python literal - split at 32bit boundary if self.constant_result >= -2**31 and self.constant_result < 2**31: if self.type and self.type.is_int: suitable_type = self.type else: suitable_type = PyrexTypes.c_long_type else: suitable_type = PyrexTypes.py_object_type return suitable_type def coerce_to(self, dst_type, env): if self.type is dst_type: return self elif dst_type.is_float: if self.constant_result is not not_a_constant: return FloatNode(self.pos, value='%d.0' % int(self.constant_result), type=dst_type, constant_result=float(self.constant_result)) else: return FloatNode(self.pos, value=self.value, type=dst_type, constant_result=not_a_constant) if dst_type.is_numeric and not dst_type.is_complex: node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, type = dst_type, is_c_literal = True, unsigned=self.unsigned, longness=self.longness) return node elif dst_type.is_pyobject: node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, type = PyrexTypes.py_object_type, is_c_literal = False, unsigned=self.unsigned, longness=self.longness) else: # FIXME: not setting the type here to keep it working with # complex numbers. Should they be special cased? node = IntNode(self.pos, value=self.value, constant_result=self.constant_result, unsigned=self.unsigned, longness=self.longness) # We still need to perform normal coerce_to processing on the # result, because we might be coercing to an extension type, # in which case a type test node will be needed. return ConstNode.coerce_to(node, dst_type, env) def coerce_to_boolean(self, env): return IntNode( self.pos, value=self.value, type = PyrexTypes.c_bint_type, unsigned=self.unsigned, longness=self.longness) def generate_evaluation_code(self, code): if self.type.is_pyobject: # pre-allocate a Python version of the number plain_integer_string = self.value_as_c_integer_string(plain_digits=True) self.result_code = code.get_py_num(plain_integer_string, self.longness) else: self.result_code = self.get_constant_c_result_code() def get_constant_c_result_code(self): return self.value_as_c_integer_string() + self.unsigned + self.longness def value_as_c_integer_string(self, plain_digits=False): value = self.value if isinstance(value, basestring) and len(value) > 2: # must convert C-incompatible Py3 oct/bin notations if value[1] in 'oO': if plain_digits: value = int(value[2:], 8) else: value = value[0] + value[2:] # '0o123' => '0123' elif value[1] in 'bB': value = int(value[2:], 2) elif plain_digits and value[1] in 'xX': value = int(value[2:], 16) return str(value) def calculate_result_code(self): return self.result_code def calculate_constant_result(self): self.constant_result = Utils.str_to_number(self.value) def compile_time_value(self, denv): return Utils.str_to_number(self.value) class FloatNode(ConstNode): type = PyrexTypes.c_double_type def calculate_constant_result(self): self.constant_result = float(self.value) def compile_time_value(self, denv): return float(self.value) def calculate_result_code(self): strval = self.value assert isinstance(strval, (str, unicode)) cmpval = repr(float(strval)) if cmpval == 'nan': return "(Py_HUGE_VAL * 0)" elif cmpval == 'inf': return "Py_HUGE_VAL" elif cmpval == '-inf': return "(-Py_HUGE_VAL)" else: return strval class BytesNode(ConstNode): # A char* or bytes literal # # value BytesLiteral is_string_literal = True # start off as Python 'bytes' to support len() in O(1) type = bytes_type def compile_time_value(self, denv): return self.value def analyse_as_type(self, env): type = PyrexTypes.parse_basic_type(self.value) if type is not None: return type from TreeFragment import TreeFragment pos = (self.pos[0], self.pos[1], self.pos[2]-7) declaration = TreeFragment(u"sizeof(%s)" % self.value, name=pos[0].filename, initial_pos=pos) sizeof_node = declaration.root.stats[0].expr sizeof_node.analyse_types(env) if isinstance(sizeof_node, SizeofTypeNode): return sizeof_node.arg_type def can_coerce_to_char_literal(self): return len(self.value) == 1 def coerce_to_boolean(self, env): # This is special because testing a C char* for truth directly # would yield the wrong result. bool_value = bool(self.value) return BoolNode(self.pos, value=bool_value, constant_result=bool_value) def coerce_to(self, dst_type, env): if self.type == dst_type: return self if dst_type.is_int: if not self.can_coerce_to_char_literal(): error(self.pos, "Only single-character string literals can be coerced into ints.") return self if dst_type.is_unicode_char: error(self.pos, "Bytes literals cannot coerce to Py_UNICODE/Py_UCS4, use a unicode literal instead.") return self return CharNode(self.pos, value=self.value) node = BytesNode(self.pos, value=self.value) if dst_type.is_pyobject: if dst_type in (py_object_type, Builtin.bytes_type): node.type = Builtin.bytes_type else: self.check_for_coercion_error(dst_type, fail=True) return node elif dst_type == PyrexTypes.c_char_ptr_type: node.type = dst_type return node elif dst_type == PyrexTypes.c_uchar_ptr_type: node.type = PyrexTypes.c_char_ptr_type return CastNode(node, PyrexTypes.c_uchar_ptr_type) elif dst_type.assignable_from(PyrexTypes.c_char_ptr_type): node.type = dst_type return node # We still need to perform normal coerce_to processing on the # result, because we might be coercing to an extension type, # in which case a type test node will be needed. return ConstNode.coerce_to(node, dst_type, env) def generate_evaluation_code(self, code): if self.type.is_pyobject: self.result_code = code.get_py_string_const(self.value) else: self.result_code = code.get_string_const(self.value) def get_constant_c_result_code(self): return None # FIXME def calculate_result_code(self): return self.result_code class UnicodeNode(PyConstNode): # A Python unicode object # # value EncodedString # bytes_value BytesLiteral the literal parsed as bytes string ('-3' unicode literals only) is_string_literal = True bytes_value = None type = unicode_type def coerce_to(self, dst_type, env): if dst_type is self.type: pass elif dst_type.is_unicode_char: if not self.can_coerce_to_char_literal(): error(self.pos, "Only single-character Unicode string literals or surrogate pairs can be coerced into Py_UCS4/Py_UNICODE.") return self int_value = ord(self.value) return IntNode(self.pos, type=dst_type, value=str(int_value), constant_result=int_value) elif not dst_type.is_pyobject: if dst_type.is_string and self.bytes_value is not None: # special case: '-3' enforced unicode literal used in a C char* context return BytesNode(self.pos, value=self.bytes_value).coerce_to(dst_type, env) error(self.pos, "Unicode literals do not support coercion to C types other than Py_UNICODE or Py_UCS4.") elif dst_type is not py_object_type: if not self.check_for_coercion_error(dst_type): self.fail_assignment(dst_type) return self def can_coerce_to_char_literal(self): return len(self.value) == 1 ## or (len(self.value) == 2 ## and (0xD800 <= self.value[0] <= 0xDBFF) ## and (0xDC00 <= self.value[1] <= 0xDFFF)) def contains_surrogates(self): # Check if the unicode string contains surrogate code points # on a CPython platform with wide (UCS-4) or narrow (UTF-16) # Unicode, i.e. characters that would be spelled as two # separate code units on a narrow platform. for c in map(ord, self.value): if c > 65535: # can only happen on wide platforms return True # We only look for the first code unit (D800-DBFF) of a # surrogate pair - if we find one, the other one # (DC00-DFFF) is likely there, too. If we don't find it, # any second code unit cannot make for a surrogate pair by # itself. if c >= 0xD800 and c <= 0xDBFF: return True return False def generate_evaluation_code(self, code): self.result_code = code.get_py_string_const(self.value) def calculate_result_code(self): return self.result_code def compile_time_value(self, env): return self.value class StringNode(PyConstNode): # A Python str object, i.e. a byte string in Python 2.x and a # unicode string in Python 3.x # # value BytesLiteral (or EncodedString with ASCII content) # unicode_value EncodedString or None # is_identifier boolean type = str_type is_string_literal = True is_identifier = None unicode_value = None def coerce_to(self, dst_type, env): if dst_type is not py_object_type and not str_type.subtype_of(dst_type): # if dst_type is Builtin.bytes_type: # # special case: bytes = 'str literal' # return BytesNode(self.pos, value=self.value) if not dst_type.is_pyobject: return BytesNode(self.pos, value=self.value).coerce_to(dst_type, env) self.check_for_coercion_error(dst_type, fail=True) return self def can_coerce_to_char_literal(self): return not self.is_identifier and len(self.value) == 1 def generate_evaluation_code(self, code): self.result_code = code.get_py_string_const( self.value, identifier=self.is_identifier, is_str=True, unicode_value=self.unicode_value) def get_constant_c_result_code(self): return None def calculate_result_code(self): return self.result_code def compile_time_value(self, env): return self.value class IdentifierStringNode(StringNode): # A special str value that represents an identifier (bytes in Py2, # unicode in Py3). is_identifier = True class LongNode(AtomicExprNode): # Python long integer literal # # value string type = py_object_type def calculate_constant_result(self): self.constant_result = Utils.str_to_number(self.value) def compile_time_value(self, denv): return Utils.str_to_number(self.value) def analyse_types(self, env): self.is_temp = 1 def may_be_none(self): return False gil_message = "Constructing Python long int" def generate_result_code(self, code): code.putln( '%s = PyLong_FromString((char *)"%s", 0, 0); %s' % ( self.result(), self.value, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class ImagNode(AtomicExprNode): # Imaginary number literal # # value float imaginary part type = PyrexTypes.c_double_complex_type def calculate_constant_result(self): self.constant_result = complex(0.0, self.value) def compile_time_value(self, denv): return complex(0.0, self.value) def analyse_types(self, env): self.type.create_declaration_utility_code(env) def may_be_none(self): return False def coerce_to(self, dst_type, env): if self.type is dst_type: return self node = ImagNode(self.pos, value=self.value) if dst_type.is_pyobject: node.is_temp = 1 node.type = PyrexTypes.py_object_type # We still need to perform normal coerce_to processing on the # result, because we might be coercing to an extension type, # in which case a type test node will be needed. return AtomicExprNode.coerce_to(node, dst_type, env) gil_message = "Constructing complex number" def calculate_result_code(self): if self.type.is_pyobject: return self.result() else: return "%s(0, %r)" % (self.type.from_parts, float(self.value)) def generate_result_code(self, code): if self.type.is_pyobject: code.putln( "%s = PyComplex_FromDoubles(0.0, %r); %s" % ( self.result(), float(self.value), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class NewExprNode(AtomicExprNode): # C++ new statement # # cppclass node c++ class to create type = None def infer_type(self, env): type = self.cppclass.analyse_as_type(env) if type is None or not type.is_cpp_class: error(self.pos, "new operator can only be applied to a C++ class") self.type = error_type return self.cpp_check(env) constructor = type.scope.lookup(u'<init>') if constructor is None: return_type = PyrexTypes.CFuncType(type, []) return_type = PyrexTypes.CPtrType(return_type) type.scope.declare_cfunction(u'<init>', return_type, self.pos) constructor = type.scope.lookup(u'<init>') self.class_type = type self.entry = constructor self.type = constructor.type return self.type def analyse_types(self, env): if self.type is None: self.infer_type(env) def may_be_none(self): return False def generate_result_code(self, code): pass def calculate_result_code(self): return "new " + self.class_type.declaration_code("") class NameNode(AtomicExprNode): # Reference to a local or global variable name. # # name string Python name of the variable # entry Entry Symbol table entry # type_entry Entry For extension type names, the original type entry # cf_is_null boolean Is uninitialized before this node # cf_maybe_null boolean Maybe uninitialized before this node # allow_null boolean Don't raise UnboundLocalError # nogil boolean Whether it is used in a nogil context is_name = True is_cython_module = False cython_attribute = None lhs_of_first_assignment = False # TODO: remove me is_used_as_rvalue = 0 entry = None type_entry = None cf_maybe_null = True cf_is_null = False allow_null = False nogil = False def create_analysed_rvalue(pos, env, entry): node = NameNode(pos) node.analyse_types(env, entry=entry) return node def as_cython_attribute(self): return self.cython_attribute create_analysed_rvalue = staticmethod(create_analysed_rvalue) def type_dependencies(self, env): if self.entry is None: self.entry = env.lookup(self.name) if self.entry is not None and self.entry.type.is_unspecified: return (self.entry,) else: return () def infer_type(self, env): if self.entry is None: self.entry = env.lookup(self.name) if self.entry is None: return py_object_type elif (self.entry.type.is_extension_type or self.entry.type.is_builtin_type) and \ self.name == self.entry.type.name: # Unfortunately the type attribute of type objects # is used for the pointer to the type they represent. return type_type elif self.entry.type.is_cfunction: # special case: referring to a C function must return its pointer return PyrexTypes.CPtrType(self.entry.type) else: return self.entry.type def compile_time_value(self, denv): try: return denv.lookup(self.name) except KeyError: error(self.pos, "Compile-time name '%s' not defined" % self.name) def get_constant_c_result_code(self): if not self.entry or self.entry.type.is_pyobject: return None return self.entry.cname def coerce_to(self, dst_type, env): # If coercing to a generic pyobject and this is a builtin # C function with a Python equivalent, manufacture a NameNode # referring to the Python builtin. #print "NameNode.coerce_to:", self.name, dst_type ### if dst_type is py_object_type: entry = self.entry if entry and entry.is_cfunction: var_entry = entry.as_variable if var_entry: if var_entry.is_builtin and var_entry.is_const: var_entry = env.declare_builtin(var_entry.name, self.pos) node = NameNode(self.pos, name = self.name) node.entry = var_entry node.analyse_rvalue_entry(env) return node return super(NameNode, self).coerce_to(dst_type, env) def analyse_as_module(self, env): # Try to interpret this as a reference to a cimported module. # Returns the module scope, or None. entry = self.entry if not entry: entry = env.lookup(self.name) if entry and entry.as_module: return entry.as_module return None def analyse_as_type(self, env): if self.cython_attribute: type = PyrexTypes.parse_basic_type(self.cython_attribute) else: type = PyrexTypes.parse_basic_type(self.name) if type: return type entry = self.entry if not entry: entry = env.lookup(self.name) if entry and entry.is_type: return entry.type else: return None def analyse_as_extension_type(self, env): # Try to interpret this as a reference to an extension type. # Returns the extension type, or None. entry = self.entry if not entry: entry = env.lookup(self.name) if entry and entry.is_type and entry.type.is_extension_type: return entry.type else: return None def analyse_target_declaration(self, env): if not self.entry: self.entry = env.lookup_here(self.name) if not self.entry: if env.directives['warn.undeclared']: warning(self.pos, "implicit declaration of '%s'" % self.name, 1) if env.directives['infer_types'] != False: type = unspecified_type else: type = py_object_type self.entry = env.declare_var(self.name, type, self.pos) if self.entry.is_declared_generic: self.result_ctype = py_object_type def analyse_types(self, env): self.initialized_check = env.directives['initializedcheck'] if self.entry is None: self.entry = env.lookup(self.name) if not self.entry: self.entry = env.declare_builtin(self.name, self.pos) if not self.entry: self.type = PyrexTypes.error_type return entry = self.entry if entry: entry.used = 1 if entry.type.is_buffer: import Buffer Buffer.used_buffer_aux_vars(entry) if entry.utility_code: env.use_utility_code(entry.utility_code) self.analyse_rvalue_entry(env) def analyse_target_types(self, env): self.analyse_entry(env) if not self.is_lvalue(): error(self.pos, "Assignment to non-lvalue '%s'" % self.name) self.type = PyrexTypes.error_type self.entry.used = 1 if self.entry.type.is_buffer: import Buffer Buffer.used_buffer_aux_vars(self.entry) def analyse_rvalue_entry(self, env): #print "NameNode.analyse_rvalue_entry:", self.name ### #print "Entry:", self.entry.__dict__ ### self.analyse_entry(env) entry = self.entry if entry.is_declared_generic: self.result_ctype = py_object_type if entry.is_pyglobal or entry.is_builtin: if entry.is_builtin and entry.is_const: self.is_temp = 0 else: self.is_temp = 1 env.use_utility_code(get_name_interned_utility_code) self.is_used_as_rvalue = 1 elif entry.type.is_memoryviewslice: self.is_temp = False self.is_used_as_rvalue = True self.use_managed_ref = True def nogil_check(self, env): self.nogil = True if self.is_used_as_rvalue: entry = self.entry if entry.is_builtin: if not entry.is_const: # cached builtins are ok self.gil_error() elif entry.is_pyglobal: self.gil_error() elif self.entry.type.is_memoryviewslice: if self.cf_is_null or self.cf_maybe_null: import MemoryView MemoryView.err_if_nogil_initialized_check(self.pos, env) gil_message = "Accessing Python global or builtin" def analyse_entry(self, env): #print "NameNode.analyse_entry:", self.name ### self.check_identifier_kind() entry = self.entry type = entry.type self.type = type def check_identifier_kind(self): # Check that this is an appropriate kind of name for use in an # expression. Also finds the variable entry associated with # an extension type. entry = self.entry if entry.is_type and entry.type.is_extension_type: self.type_entry = entry if not (entry.is_const or entry.is_variable or entry.is_builtin or entry.is_cfunction or entry.is_cpp_class): if self.entry.as_variable: self.entry = self.entry.as_variable else: error(self.pos, "'%s' is not a constant, variable or function identifier" % self.name) def is_simple(self): # If it's not a C variable, it'll be in a temp. return 1 def may_be_none(self): if self.cf_state and self.type and self.type.is_pyobject: # gard against infinite recursion on self-dependencies if getattr(self, '_none_checking', False): # self-dependency - either this node receives a None # value from *another* node, or it can not reference # None at this point => safe to assume "not None" return False self._none_checking = True # evaluate control flow state to see if there were any # potential None values assigned to the node so far may_be_none = False for assignment in self.cf_state: if assignment.rhs.may_be_none(): may_be_none = True break del self._none_checking return may_be_none return super(NameNode, self).may_be_none() def nonlocally_immutable(self): if ExprNode.nonlocally_immutable(self): return True entry = self.entry return entry and (entry.is_local or entry.is_arg) and not entry.in_closure def calculate_target_results(self, env): pass def check_const(self): entry = self.entry if entry is not None and not (entry.is_const or entry.is_cfunction or entry.is_builtin): self.not_const() return False return True def check_const_addr(self): entry = self.entry if not (entry.is_cglobal or entry.is_cfunction or entry.is_builtin): self.addr_not_const() return False return True def is_lvalue(self): return self.entry.is_variable and \ not self.entry.type.is_array and \ not self.entry.is_readonly def is_ephemeral(self): # Name nodes are never ephemeral, even if the # result is in a temporary. return 0 def calculate_result_code(self): entry = self.entry if not entry: return "<error>" # There was an error earlier return entry.cname def generate_result_code(self, code): assert hasattr(self, 'entry') entry = self.entry if entry is None: return # There was an error earlier if entry.is_builtin and entry.is_const: return # Lookup already cached elif entry.is_pyclass_attr: assert entry.type.is_pyobject, "Python global or builtin not a Python object" interned_cname = code.intern_identifier(self.entry.name) if entry.is_builtin: namespace = Naming.builtins_cname else: # entry.is_pyglobal namespace = entry.scope.namespace_cname if not self.cf_is_null: code.putln( '%s = PyObject_GetItem(%s, %s);' % ( self.result(), namespace, interned_cname)) if self.cf_maybe_null: if not self.cf_is_null: code.putln('if (unlikely(!%s)) {' % self.result()) code.putln('PyErr_Clear();') code.putln( '%s = __Pyx_GetName(%s, %s);' % ( self.result(), Naming.module_cname, interned_cname)) if not self.cf_is_null: code.putln("}"); code.putln(code.error_goto_if_null(self.result(), self.pos)) code.put_gotref(self.py_result()) elif entry.is_pyglobal or entry.is_builtin: assert entry.type.is_pyobject, "Python global or builtin not a Python object" interned_cname = code.intern_identifier(self.entry.name) if entry.is_builtin: namespace = Naming.builtins_cname else: # entry.is_pyglobal namespace = entry.scope.namespace_cname code.globalstate.use_utility_code(get_name_interned_utility_code) code.putln( '%s = __Pyx_GetName(%s, %s); %s' % ( self.result(), namespace, interned_cname, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) elif entry.is_local or entry.in_closure or entry.from_closure: # Raise UnboundLocalError for objects and memoryviewslices raise_unbound = ( (self.cf_maybe_null or self.cf_is_null) and not self.allow_null) null_code = entry.type.check_for_null_code(entry.cname) memslice_check = entry.type.is_memoryviewslice and self.initialized_check if null_code and raise_unbound and (entry.type.is_pyobject or memslice_check): code.put_error_if_unbound(self.pos, entry) def generate_assignment_code(self, rhs, code): #print "NameNode.generate_assignment_code:", self.name ### entry = self.entry if entry is None: return # There was an error earlier if (self.entry.type.is_ptr and isinstance(rhs, ListNode) and not self.lhs_of_first_assignment): error(self.pos, "Literal list must be assigned to pointer at time of declaration") # is_pyglobal seems to be True for module level-globals only. # We use this to access class->tp_dict if necessary. if entry.is_pyglobal: assert entry.type.is_pyobject, "Python global or builtin not a Python object" interned_cname = code.intern_identifier(self.entry.name) namespace = self.entry.scope.namespace_cname if entry.is_member: # if the entry is a member we have to cheat: SetAttr does not work # on types, so we create a descriptor which is then added to tp_dict code.put_error_if_neg(self.pos, 'PyDict_SetItem(%s->tp_dict, %s, %s)' % ( namespace, interned_cname, rhs.py_result())) rhs.generate_disposal_code(code) rhs.free_temps(code) # in Py2.6+, we need to invalidate the method cache code.putln("PyType_Modified(%s);" % entry.scope.parent_type.typeptr_cname) elif entry.is_pyclass_attr: code.put_error_if_neg(self.pos, 'PyObject_SetItem(%s, %s, %s)' % ( namespace, interned_cname, rhs.py_result())) rhs.generate_disposal_code(code) rhs.free_temps(code) else: code.put_error_if_neg(self.pos, 'PyObject_SetAttr(%s, %s, %s)' % ( namespace, interned_cname, rhs.py_result())) if debug_disposal_code: print("NameNode.generate_assignment_code:") print("...generating disposal code for %s" % rhs) rhs.generate_disposal_code(code) rhs.free_temps(code) else: if self.type.is_memoryviewslice: self.generate_acquire_memoryviewslice(rhs, code) elif self.type.is_buffer: # Generate code for doing the buffer release/acquisition. # This might raise an exception in which case the assignment (done # below) will not happen. # # The reason this is not in a typetest-like node is because the # variables that the acquired buffer info is stored to is allocated # per entry and coupled with it. self.generate_acquire_buffer(rhs, code) if self.type.is_pyobject: #print "NameNode.generate_assignment_code: to", self.name ### #print "...from", rhs ### #print "...LHS type", self.type, "ctype", self.ctype() ### #print "...RHS type", rhs.type, "ctype", rhs.ctype() ### if self.use_managed_ref: rhs.make_owned_reference(code) is_external_ref = entry.is_cglobal or self.entry.in_closure or self.entry.from_closure if is_external_ref: if not self.cf_is_null: if self.cf_maybe_null: code.put_xgotref(self.py_result()) else: code.put_gotref(self.py_result()) if entry.is_cglobal: code.put_decref(self.result(), self.ctype()) else: if not self.cf_is_null: if self.cf_maybe_null: code.put_xdecref(self.result(), self.ctype()) else: code.put_decref(self.result(), self.ctype()) if is_external_ref: code.put_giveref(rhs.py_result()) if not self.type.is_memoryviewslice: code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype()))) if debug_disposal_code: print("NameNode.generate_assignment_code:") print("...generating post-assignment code for %s" % rhs) rhs.generate_post_assignment_code(code) elif rhs.result_in_temp(): rhs.generate_post_assignment_code(code) rhs.free_temps(code) def generate_acquire_memoryviewslice(self, rhs, code): """ Slices, coercions from objects, return values etc are new references. We have a borrowed reference in case of dst = src """ import MemoryView MemoryView.put_acquire_memoryviewslice( lhs_cname=self.result(), lhs_type=self.type, lhs_pos=self.pos, rhs=rhs, code=code, incref_rhs=rhs.is_name, have_gil=not self.in_nogil_context) def generate_acquire_buffer(self, rhs, code): # rhstmp is only used in case the rhs is a complicated expression leading to # the object, to avoid repeating the same C expression for every reference # to the rhs. It does NOT hold a reference. pretty_rhs = isinstance(rhs, NameNode) or rhs.is_temp if pretty_rhs: rhstmp = rhs.result_as(self.ctype()) else: rhstmp = code.funcstate.allocate_temp(self.entry.type, manage_ref=False) code.putln('%s = %s;' % (rhstmp, rhs.result_as(self.ctype()))) import Buffer Buffer.put_assign_to_buffer(self.result(), rhstmp, self.entry, is_initialized=not self.lhs_of_first_assignment, pos=self.pos, code=code) if not pretty_rhs: code.putln("%s = 0;" % rhstmp) code.funcstate.release_temp(rhstmp) def generate_deletion_code(self, code): if self.entry is None: return # There was an error earlier elif self.entry.is_pyclass_attr: namespace = self.entry.scope.namespace_cname interned_cname = code.intern_identifier(self.entry.name) code.put_error_if_neg(self.pos, 'PyMapping_DelItem(%s, %s)' % ( namespace, interned_cname)) elif self.entry.is_pyglobal: code.put_error_if_neg(self.pos, '__Pyx_DelAttrString(%s, "%s")' % ( Naming.module_cname, self.entry.name)) elif self.entry.type.is_pyobject or self.entry.type.is_memoryviewslice: if not self.cf_is_null: if self.cf_maybe_null: code.put_error_if_unbound(self.pos, self.entry) if self.entry.type.is_pyobject: code.put_decref(self.result(), self.ctype()) code.putln('%s = NULL;' % self.result()) else: code.put_xdecref_memoryviewslice(self.entry.cname, have_gil=not self.nogil) else: error(self.pos, "Deletion of C names not supported") def annotate(self, code): if hasattr(self, 'is_called') and self.is_called: pos = (self.pos[0], self.pos[1], self.pos[2] - len(self.name) - 1) if self.type.is_pyobject: code.annotate(pos, AnnotationItem('py_call', 'python function', size=len(self.name))) else: code.annotate(pos, AnnotationItem('c_call', 'c function', size=len(self.name))) class BackquoteNode(ExprNode): # `expr` # # arg ExprNode type = py_object_type subexprs = ['arg'] def analyse_types(self, env): self.arg.analyse_types(env) self.arg = self.arg.coerce_to_pyobject(env) self.is_temp = 1 gil_message = "Backquote expression" def calculate_constant_result(self): self.constant_result = repr(self.arg.constant_result) def generate_result_code(self, code): code.putln( "%s = PyObject_Repr(%s); %s" % ( self.result(), self.arg.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class ImportNode(ExprNode): # Used as part of import statement implementation. # Implements result = # __import__(module_name, globals(), None, name_list, level) # # module_name StringNode dotted name of module. Empty module # name means importing the parent package accourding # to level # name_list ListNode or None list of names to be imported # level int relative import level: # -1: attempt both relative import and absolute import; # 0: absolute import; # >0: the number of parent directories to search # relative to the current module. # None: decide the level according to language level and # directives type = py_object_type subexprs = ['module_name', 'name_list'] def analyse_types(self, env): if self.level is None: if env.directives['language_level'] < 3 or env.directives['py2_import']: self.level = -1 else: self.level = 0 self.module_name.analyse_types(env) self.module_name = self.module_name.coerce_to_pyobject(env) if self.name_list: self.name_list.analyse_types(env) self.name_list.coerce_to_pyobject(env) self.is_temp = 1 env.use_utility_code(import_utility_code) gil_message = "Python import" def generate_result_code(self, code): if self.name_list: name_list_code = self.name_list.py_result() else: name_list_code = "0" code.putln( "%s = __Pyx_Import(%s, %s, %d); %s" % ( self.result(), self.module_name.py_result(), name_list_code, self.level, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class IteratorNode(ExprNode): # Used as part of for statement implementation. # # Implements result = iter(sequence) # # sequence ExprNode type = py_object_type iter_func_ptr = None counter_cname = None reversed = False # currently only used for list/tuple types (see Optimize.py) subexprs = ['sequence'] def analyse_types(self, env): self.sequence.analyse_types(env) if (self.sequence.type.is_array or self.sequence.type.is_ptr) and \ not self.sequence.type.is_string: # C array iteration will be transformed later on self.type = self.sequence.type else: self.sequence = self.sequence.coerce_to_pyobject(env) if self.sequence.type is list_type or \ self.sequence.type is tuple_type: self.sequence = self.sequence.as_none_safe_node("'NoneType' object is not iterable") self.is_temp = 1 gil_message = "Iterating over Python object" _func_iternext_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType( PyrexTypes.py_object_type, [ PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None), ])) def generate_result_code(self, code): sequence_type = self.sequence.type if sequence_type.is_array or sequence_type.is_ptr: raise InternalError("for in carray slice not transformed") is_builtin_sequence = sequence_type is list_type or \ sequence_type is tuple_type if not is_builtin_sequence: # reversed() not currently optimised (see Optimize.py) assert not self.reversed, "internal error: reversed() only implemented for list/tuple objects" self.may_be_a_sequence = not sequence_type.is_builtin_type if self.may_be_a_sequence: code.putln( "if (PyList_CheckExact(%s) || PyTuple_CheckExact(%s)) {" % ( self.sequence.py_result(), self.sequence.py_result())) if is_builtin_sequence or self.may_be_a_sequence: self.counter_cname = code.funcstate.allocate_temp( PyrexTypes.c_py_ssize_t_type, manage_ref=False) if self.reversed: if sequence_type is list_type: init_value = 'PyList_GET_SIZE(%s) - 1' % self.result() else: init_value = 'PyTuple_GET_SIZE(%s) - 1' % self.result() else: init_value = '0' code.putln( "%s = %s; __Pyx_INCREF(%s); %s = %s;" % ( self.result(), self.sequence.py_result(), self.result(), self.counter_cname, init_value )) if not is_builtin_sequence: self.iter_func_ptr = code.funcstate.allocate_temp(self._func_iternext_type, manage_ref=False) if self.may_be_a_sequence: code.putln("%s = NULL;" % self.iter_func_ptr) code.putln("} else {") code.put("%s = -1; " % self.counter_cname) code.putln("%s = PyObject_GetIter(%s); %s" % ( self.result(), self.sequence.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) code.putln("%s = Py_TYPE(%s)->tp_iternext;" % (self.iter_func_ptr, self.py_result())) if self.may_be_a_sequence: code.putln("}") def generate_next_sequence_item(self, test_name, result_name, code): assert self.counter_cname, "internal error: counter_cname temp not prepared" code.putln( "if (%s >= Py%s_GET_SIZE(%s)) break;" % ( self.counter_cname, test_name, self.py_result())) if self.reversed: inc_dec = '--' else: inc_dec = '++' code.putln( "%s = Py%s_GET_ITEM(%s, %s); __Pyx_INCREF(%s); %s%s;" % ( result_name, test_name, self.py_result(), self.counter_cname, result_name, self.counter_cname, inc_dec)) def generate_iter_next_result_code(self, result_name, code): sequence_type = self.sequence.type if self.reversed: code.putln("if (%s < 0) break;" % self.counter_cname) if sequence_type is list_type: self.generate_next_sequence_item('List', result_name, code) return elif sequence_type is tuple_type: self.generate_next_sequence_item('Tuple', result_name, code) return if self.may_be_a_sequence: for test_name in ('List', 'Tuple'): code.putln("if (Py%s_CheckExact(%s)) {" % (test_name, self.py_result())) self.generate_next_sequence_item(test_name, result_name, code) code.put("} else ") code.putln("{") code.putln( "%s = %s(%s);" % ( result_name, self.iter_func_ptr, self.py_result())) code.putln("if (unlikely(!%s)) {" % result_name) code.putln("if (PyErr_Occurred()) {") code.putln("if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();") code.putln("else %s" % code.error_goto(self.pos)) code.putln("}") code.putln("break;") code.putln("}") code.put_gotref(result_name) code.putln("}") def free_temps(self, code): if self.counter_cname: code.funcstate.release_temp(self.counter_cname) if self.iter_func_ptr: code.funcstate.release_temp(self.iter_func_ptr) self.iter_func_ptr = None ExprNode.free_temps(self, code) class NextNode(AtomicExprNode): # Used as part of for statement implementation. # Implements result = iterator.next() # Created during analyse_types phase. # The iterator is not owned by this node. # # iterator IteratorNode type = py_object_type def __init__(self, iterator): self.pos = iterator.pos self.iterator = iterator if iterator.type.is_ptr or iterator.type.is_array: self.type = iterator.type.base_type self.is_temp = 1 def generate_result_code(self, code): self.iterator.generate_iter_next_result_code(self.result(), code) class WithExitCallNode(ExprNode): # The __exit__() call of a 'with' statement. Used in both the # except and finally clauses. # with_stat WithStatNode the surrounding 'with' statement # args TupleNode or ResultStatNode the exception info tuple subexprs = ['args'] def analyse_types(self, env): self.args.analyse_types(env) self.type = PyrexTypes.c_bint_type self.is_temp = True def generate_result_code(self, code): if isinstance(self.args, TupleNode): # call only if it was not already called (and decref-cleared) code.putln("if (%s) {" % self.with_stat.exit_var) result_var = code.funcstate.allocate_temp(py_object_type, manage_ref=False) code.putln("%s = PyObject_Call(%s, %s, NULL);" % ( result_var, self.with_stat.exit_var, self.args.result())) code.put_decref_clear(self.with_stat.exit_var, type=py_object_type) code.putln(code.error_goto_if_null(result_var, self.pos)) code.put_gotref(result_var) code.putln("%s = __Pyx_PyObject_IsTrue(%s);" % (self.result(), result_var)) code.put_decref_clear(result_var, type=py_object_type) code.putln(code.error_goto_if_neg(self.result(), self.pos)) code.funcstate.release_temp(result_var) if isinstance(self.args, TupleNode): code.putln("}") class ExcValueNode(AtomicExprNode): # Node created during analyse_types phase # of an ExceptClauseNode to fetch the current # exception value. type = py_object_type def __init__(self, pos, env): ExprNode.__init__(self, pos) def set_var(self, var): self.var = var def calculate_result_code(self): return self.var def generate_result_code(self, code): pass def analyse_types(self, env): pass class TempNode(ExprNode): # Node created during analyse_types phase # of some nodes to hold a temporary value. # # Note: One must call "allocate" and "release" on # the node during code generation to get/release the temp. # This is because the temp result is often used outside of # the regular cycle. subexprs = [] def __init__(self, pos, type, env=None): ExprNode.__init__(self, pos) self.type = type if type.is_pyobject: self.result_ctype = py_object_type self.is_temp = 1 def analyse_types(self, env): return self.type def analyse_target_declaration(self, env): pass def generate_result_code(self, code): pass def allocate(self, code): self.temp_cname = code.funcstate.allocate_temp(self.type, manage_ref=True) def release(self, code): code.funcstate.release_temp(self.temp_cname) self.temp_cname = None def result(self): try: return self.temp_cname except: assert False, "Remember to call allocate/release on TempNode" raise # Do not participate in normal temp alloc/dealloc: def allocate_temp_result(self, code): pass def release_temp_result(self, code): pass class PyTempNode(TempNode): # TempNode holding a Python value. def __init__(self, pos, env): TempNode.__init__(self, pos, PyrexTypes.py_object_type, env) class RawCNameExprNode(ExprNode): subexprs = [] def __init__(self, pos, type=None): self.pos = pos self.type = type def analyse_types(self, env): return self.type def set_cname(self, cname): self.cname = cname def result(self): return self.cname def generate_result_code(self, code): pass #------------------------------------------------------------------- # # Parallel nodes (cython.parallel.thread(savailable|id)) # #------------------------------------------------------------------- class ParallelThreadsAvailableNode(AtomicExprNode): """ Note: this is disabled and not a valid directive at this moment Implements cython.parallel.threadsavailable(). If we are called from the sequential part of the application, we need to call omp_get_max_threads(), and in the parallel part we can just call omp_get_num_threads() """ type = PyrexTypes.c_int_type def analyse_types(self, env): self.is_temp = True # env.add_include_file("omp.h") return self.type def generate_result_code(self, code): code.putln("#ifdef _OPENMP") code.putln("if (omp_in_parallel()) %s = omp_get_max_threads();" % self.temp_code) code.putln("else %s = omp_get_num_threads();" % self.temp_code) code.putln("#else") code.putln("%s = 1;" % self.temp_code) code.putln("#endif") def result(self): return self.temp_code class ParallelThreadIdNode(AtomicExprNode): #, Nodes.ParallelNode): """ Implements cython.parallel.threadid() """ type = PyrexTypes.c_int_type def analyse_types(self, env): self.is_temp = True # env.add_include_file("omp.h") return self.type def generate_result_code(self, code): code.putln("#ifdef _OPENMP") code.putln("%s = omp_get_thread_num();" % self.temp_code) code.putln("#else") code.putln("%s = 0;" % self.temp_code) code.putln("#endif") def result(self): return self.temp_code #------------------------------------------------------------------- # # Trailer nodes # #------------------------------------------------------------------- class IndexNode(ExprNode): # Sequence indexing. # # base ExprNode # index ExprNode # indices [ExprNode] # is_buffer_access boolean Whether this is a buffer access. # # indices is used on buffer access, index on non-buffer access. # The former contains a clean list of index parameters, the # latter whatever Python object is needed for index access. subexprs = ['base', 'index', 'indices'] indices = None # Whether we're assigning to a buffer (in that case it needs to be # writable) writable_needed = False # Whether we are indexing or slicing a memoryviewslice memslice_index = False memslice_slice = False def __init__(self, pos, index, *args, **kw): ExprNode.__init__(self, pos, index=index, *args, **kw) self._index = index def calculate_constant_result(self): self.constant_result = \ self.base.constant_result[self.index.constant_result] def compile_time_value(self, denv): base = self.base.compile_time_value(denv) index = self.index.compile_time_value(denv) try: return base[index] except Exception, e: self.compile_time_value_error(e) def is_ephemeral(self): return self.base.is_ephemeral() def is_simple(self): if self.is_buffer_access or self.memslice_index: return False elif self.memslice_slice: return True base = self.base return (base.is_simple() and self.index.is_simple() and base.type and (base.type.is_ptr or base.type.is_array)) def analyse_target_declaration(self, env): pass def analyse_as_type(self, env): base_type = self.base.analyse_as_type(env) if base_type and not base_type.is_pyobject: if base_type.is_cpp_class: if isinstance(self.index, TupleNode): template_values = self.index.args else: template_values = [self.index] import Nodes type_node = Nodes.TemplatedTypeNode( pos = self.pos, positional_args = template_values, keyword_args = None) return type_node.analyse(env, base_type = base_type) else: return PyrexTypes.CArrayType(base_type, int(self.index.compile_time_value(env))) return None def type_dependencies(self, env): return self.base.type_dependencies(env) + self.index.type_dependencies(env) def infer_type(self, env): base_type = self.base.infer_type(env) if isinstance(self.index, SliceNode): # slicing! if base_type.is_string: # sliced C strings must coerce to Python return bytes_type elif base_type in (unicode_type, bytes_type, str_type, list_type, tuple_type): # slicing these returns the same type return base_type else: # TODO: Handle buffers (hopefully without too much redundancy). return py_object_type index_type = self.index.infer_type(env) if index_type and index_type.is_int or isinstance(self.index, (IntNode, LongNode)): # indexing! if base_type is unicode_type: # Py_UCS4 will automatically coerce to a unicode string # if required, so this is safe. We only infer Py_UCS4 # when the index is a C integer type. Otherwise, we may # need to use normal Python item access, in which case # it's faster to return the one-char unicode string than # to receive it, throw it away, and potentially rebuild it # on a subsequent PyObject coercion. return PyrexTypes.c_py_ucs4_type elif base_type is str_type: # always returns str - Py2: bytes, Py3: unicode return base_type elif isinstance(self.base, BytesNode): #if env.global_scope().context.language_level >= 3: # # infering 'char' can be made to work in Python 3 mode # return PyrexTypes.c_char_type # Py2/3 return different types on indexing bytes objects return py_object_type elif base_type.is_ptr or base_type.is_array: return base_type.base_type # may be slicing or indexing, we don't know if base_type in (unicode_type, str_type): # these types always returns their own type on Python indexing/slicing return base_type else: # TODO: Handle buffers (hopefully without too much redundancy). return py_object_type def analyse_types(self, env): self.analyse_base_and_index_types(env, getting = 1) def analyse_target_types(self, env): self.analyse_base_and_index_types(env, setting = 1) def analyse_base_and_index_types(self, env, getting = 0, setting = 0, analyse_base = True): # Note: This might be cleaned up by having IndexNode # parsed in a saner way and only construct the tuple if # needed. # Note that this function must leave IndexNode in a cloneable state. # For buffers, self.index is packed out on the initial analysis, and # when cloning self.indices is copied. self.is_buffer_access = False # a[...] = b self.is_memoryviewslice_access = False # incomplete indexing, Ellipsis indexing or slicing self.memslice_slice = False # integer indexing self.memslice_index = False if analyse_base: self.base.analyse_types(env) if self.base.type.is_error: # Do not visit child tree if base is undeclared to avoid confusing # error messages self.type = PyrexTypes.error_type return is_slice = isinstance(self.index, SliceNode) # Potentially overflowing index value. if not is_slice and isinstance(self.index, IntNode) and Utils.long_literal(self.index.value): self.index = self.index.coerce_to_pyobject(env) is_memslice = self.base.type.is_memoryviewslice # Handle the case where base is a literal char* (and we expect a string, not an int) if not is_memslice and (isinstance(self.base, BytesNode) or is_slice): if self.base.type.is_string or not (self.base.type.is_ptr or self.base.type.is_array): self.base = self.base.coerce_to_pyobject(env) skip_child_analysis = False buffer_access = False memoryviewslice_access = False if self.indices: indices = self.indices elif isinstance(self.index, TupleNode): indices = self.index.args else: indices = [self.index] if (is_memslice and not self.indices and isinstance(self.index, EllipsisNode)): # Memoryviewslice copying memoryviewslice_access = True elif is_memslice: # memoryviewslice indexing or slicing import MemoryView skip_child_analysis = True have_slices, indices = MemoryView.unellipsify(indices, self.base.type.ndim) self.memslice_index = len(indices) == self.base.type.ndim axes = [] index_type = PyrexTypes.c_py_ssize_t_type new_indices = [] if len(indices) > self.base.type.ndim: self.type = error_type return error(indices[self.base.type.ndim].pos, "Too many indices specified for type %s" % self.base.type) suboffsets_dim = -1 for i, index in enumerate(indices[:]): index.analyse_types(env) access, packing = self.base.type.axes[i] if isinstance(index, SliceNode): suboffsets_dim = i self.memslice_slice = True if index.step.is_none: axes.append((access, packing)) else: axes.append((access, 'strided')) # Coerce start, stop and step to temps of the right type for attr in ('start', 'stop', 'step'): value = getattr(index, attr) if not value.is_none: value = value.coerce_to(index_type, env) #value = value.coerce_to_temp(env) setattr(index, attr, value) new_indices.append(value) elif index.type.is_int: self.memslice_index = True index = index.coerce_to(index_type, env) indices[i] = index new_indices.append(index) if access in ('ptr', 'generic') and i != 0 and have_slices: self.type = error_type return error(index.pos, "Indexing of non-leading indirect or generic " "dimensions not supported yet, " "try slicing with i:i+1") else: self.type = error_type return error(index.pos, "Invalid index for memoryview specified") self.memslice_index = self.memslice_index and not self.memslice_slice self.original_indices = indices # All indices with all start/stop/step for slices. # We need to keep this around self.indices = new_indices self.env = env elif self.base.type.is_buffer: # Buffer indexing if len(indices) == self.base.type.ndim: buffer_access = True skip_child_analysis = True for x in indices: x.analyse_types(env) if not x.type.is_int: buffer_access = False if buffer_access and not self.base.type.is_memoryviewslice: assert hasattr(self.base, "entry") # Must be a NameNode-like node # On cloning, indices is cloned. Otherwise, unpack index into indices assert not (buffer_access and isinstance(self.index, CloneNode)) self.nogil = env.nogil if buffer_access or self.memslice_index: if self.base.type.is_memoryviewslice and not self.base.is_name: self.base = self.base.coerce_to_temp(env) self.indices = indices self.index = None self.type = self.base.type.dtype self.is_buffer_access = True self.buffer_type = self.base.type #self.base.entry.type if getting and self.type.is_pyobject: self.is_temp = True if setting and self.base.type.is_memoryviewslice: self.base.type.writable_needed = True elif setting: if not self.base.entry.type.writable: error(self.pos, "Writing to readonly buffer") else: self.writable_needed = True if self.base.type.is_buffer: self.base.entry.buffer_aux.writable_needed = True elif memoryviewslice_access: self.type = self.base.type self.is_memoryviewslice_access = True if getting: error(self.pos, "memoryviews currently support setting only.") elif self.memslice_slice: self.index = None self.is_temp = True self.use_managed_ref = True self.type = PyrexTypes.MemoryViewSliceType( self.base.type.dtype, axes) else: base_type = self.base.type if isinstance(self.index, TupleNode): self.index.analyse_types(env, skip_children=skip_child_analysis) elif not skip_child_analysis: self.index.analyse_types(env) self.original_index_type = self.index.type if base_type.is_unicode_char: # we infer Py_UNICODE/Py_UCS4 for unicode strings in some # cases, but indexing must still work for them if self.index.constant_result in (0, -1): # FIXME: we know that this node is redundant - # currently, this needs to get handled in Optimize.py pass self.base = self.base.coerce_to_pyobject(env) base_type = self.base.type if base_type.is_pyobject: if self.index.type.is_int: if (not setting and (base_type in (list_type, tuple_type, unicode_type)) and (not self.index.type.signed or not env.directives['wraparound'] or isinstance(self.index, IntNode) and int(self.index.value) >= 0) and not env.directives['boundscheck']): self.is_temp = 0 else: self.is_temp = 1 self.index = self.index.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env) else: self.index = self.index.coerce_to_pyobject(env) self.is_temp = 1 if self.index.type.is_int and base_type is unicode_type: # Py_UNICODE/Py_UCS4 will automatically coerce to a unicode string # if required, so this is fast and safe self.type = PyrexTypes.c_py_ucs4_type elif is_slice and base_type in (bytes_type, str_type, unicode_type, list_type, tuple_type): self.type = base_type else: self.type = py_object_type else: if base_type.is_ptr or base_type.is_array: self.type = base_type.base_type if is_slice: self.type = base_type elif self.index.type.is_pyobject: self.index = self.index.coerce_to( PyrexTypes.c_py_ssize_t_type, env) elif not self.index.type.is_int: error(self.pos, "Invalid index type '%s'" % self.index.type) elif base_type.is_cpp_class: function = env.lookup_operator("[]", [self.base, self.index]) if function is None: error(self.pos, "Indexing '%s' not supported for index type '%s'" % (base_type, self.index.type)) self.type = PyrexTypes.error_type self.result_code = "<error>" return func_type = function.type if func_type.is_ptr: func_type = func_type.base_type self.index = self.index.coerce_to(func_type.args[0].type, env) self.type = func_type.return_type if setting and not func_type.return_type.is_reference: error(self.pos, "Can't set non-reference result '%s'" % self.type) else: error(self.pos, "Attempting to index non-array type '%s'" % base_type) self.type = PyrexTypes.error_type gil_message = "Indexing Python object" def nogil_check(self, env): if self.is_buffer_access or self.memslice_index or self.memslice_slice: if not self.memslice_slice and env.directives['boundscheck']: error(self.pos, "Cannot check buffer index bounds without gil; use boundscheck(False) directive") return elif self.type.is_pyobject: error(self.pos, "Cannot access buffer with object dtype without gil") return super(IndexNode, self).nogil_check(env) def check_const_addr(self): return self.base.check_const_addr() and self.index.check_const() def is_lvalue(self): return 1 def calculate_result_code(self): if self.is_buffer_access: return "(*%s)" % self.buffer_ptr_code elif self.base.type is list_type: return "PyList_GET_ITEM(%s, %s)" % (self.base.result(), self.index.result()) elif self.base.type is tuple_type: return "PyTuple_GET_ITEM(%s, %s)" % (self.base.result(), self.index.result()) elif self.base.type is unicode_type and self.type.is_unicode_char: return "__Pyx_PyUnicode_READ_CHAR(%s, %s)" % (self.base.result(), self.index.result()) elif (self.type.is_ptr or self.type.is_array) and self.type == self.base.type: error(self.pos, "Invalid use of pointer slice") else: return "(%s[%s])" % ( self.base.result(), self.index.result()) def extra_index_params(self): if self.index.type.is_int: if self.original_index_type.signed: size_adjustment = "" else: size_adjustment = "+1" return ", sizeof(%s)%s, %s" % (self.original_index_type.declaration_code(""), size_adjustment, self.original_index_type.to_py_function) else: return "" def generate_subexpr_evaluation_code(self, code): self.base.generate_evaluation_code(code) if not self.indices: self.index.generate_evaluation_code(code) else: for i in self.indices: i.generate_evaluation_code(code) def generate_subexpr_disposal_code(self, code): self.base.generate_disposal_code(code) if not self.indices: self.index.generate_disposal_code(code) else: for i in self.indices: i.generate_disposal_code(code) def free_subexpr_temps(self, code): self.base.free_temps(code) if not self.indices: self.index.free_temps(code) else: for i in self.indices: i.free_temps(code) def generate_result_code(self, code): if self.is_buffer_access or self.memslice_index: if code.globalstate.directives['nonecheck']: self.put_nonecheck(code) buffer_entry, self.buffer_ptr_code = self.buffer_lookup_code(code) if self.type.is_pyobject: # is_temp is True, so must pull out value and incref it. code.putln("%s = *%s;" % (self.result(), self.buffer_ptr_code)) code.putln("__Pyx_INCREF((PyObject*)%s);" % self.result()) elif self.memslice_slice: self.put_memoryviewslice_slice_code(code) elif self.is_temp: if self.type.is_pyobject: if self.index.type.is_int: index_code = self.index.result() if self.base.type is list_type: function = "__Pyx_GetItemInt_List" elif self.base.type is tuple_type: function = "__Pyx_GetItemInt_Tuple" else: function = "__Pyx_GetItemInt" code.globalstate.use_utility_code(getitem_int_utility_code) else: index_code = self.index.py_result() if self.base.type is dict_type: function = "__Pyx_PyDict_GetItem" code.globalstate.use_utility_code(getitem_dict_utility_code) else: function = "PyObject_GetItem" code.putln( "%s = %s(%s, %s%s); if (!%s) %s" % ( self.result(), function, self.base.py_result(), index_code, self.extra_index_params(), self.result(), code.error_goto(self.pos))) code.put_gotref(self.py_result()) elif self.type.is_unicode_char and self.base.type is unicode_type: assert self.index.type.is_int index_code = self.index.result() function = "__Pyx_GetItemInt_Unicode" code.globalstate.use_utility_code(getitem_int_pyunicode_utility_code) code.putln( "%s = %s(%s, %s%s); if (unlikely(%s == (Py_UCS4)-1)) %s;" % ( self.result(), function, self.base.py_result(), index_code, self.extra_index_params(), self.result(), code.error_goto(self.pos))) def generate_setitem_code(self, value_code, code): if self.index.type.is_int: function = "__Pyx_SetItemInt" index_code = self.index.result() code.globalstate.use_utility_code(setitem_int_utility_code) else: index_code = self.index.py_result() if self.base.type is dict_type: function = "PyDict_SetItem" # It would seem that we could specialized lists/tuples, but that # shouldn't happen here. # Both PyList_SetItem PyTuple_SetItem and a Py_ssize_t as input, # not a PyObject*, and bad conversion here would give the wrong # exception. Also, tuples are supposed to be immutable, and raise # TypeErrors when trying to set their entries (PyTuple_SetItem # is for creating new tuples from). else: function = "PyObject_SetItem" code.putln( "if (%s(%s, %s, %s%s) < 0) %s" % ( function, self.base.py_result(), index_code, value_code, self.extra_index_params(), code.error_goto(self.pos))) def generate_memoryviewslice_copy_code(self, rhs, code, op=""): assert isinstance(self.index, EllipsisNode) import MemoryView util_code = MemoryView.CopyContentsFuncUtilCode(rhs.type, self.type) func_name = util_code.copy_contents_name code.putln(code.error_goto_if_neg("%s(&%s, &%s)" % (func_name, rhs.result(), self.base.result()), self.pos)) code.globalstate.use_utility_code(util_code) def generate_buffer_setitem_code(self, rhs, code, op=""): # Used from generate_assignment_code and InPlaceAssignmentNode if code.globalstate.directives['nonecheck'] and not self.memslice_index: self.put_nonecheck(code) buffer_entry, ptrexpr = self.buffer_lookup_code(code) if self.buffer_type.dtype.is_pyobject: # Must manage refcounts. Decref what is already there # and incref what we put in. ptr = code.funcstate.allocate_temp(buffer_entry.buf_ptr_type, manage_ref=False) rhs_code = rhs.result() code.putln("%s = %s;" % (ptr, ptrexpr)) code.put_gotref("*%s" % ptr) code.putln("__Pyx_DECREF(*%s); __Pyx_INCREF(%s);" % ( ptr, rhs_code )) code.putln("*%s %s= %s;" % (ptr, op, rhs_code)) code.put_giveref("*%s" % ptr) code.funcstate.release_temp(ptr) else: # Simple case code.putln("*%s %s= %s;" % (ptrexpr, op, rhs.result())) def generate_assignment_code(self, rhs, code): self.generate_subexpr_evaluation_code(code) if self.is_buffer_access or self.memslice_index: self.generate_buffer_setitem_code(rhs, code) elif self.memslice_slice: error(rhs.pos, "Slice assignment not supported yet") #self.generate_memoryviewslice_setslice_code(rhs, code) elif self.is_memoryviewslice_access: self.generate_memoryviewslice_copy_code(rhs, code) elif self.type.is_pyobject: self.generate_setitem_code(rhs.py_result(), code) else: code.putln( "%s = %s;" % ( self.result(), rhs.result())) self.generate_subexpr_disposal_code(code) self.free_subexpr_temps(code) rhs.generate_disposal_code(code) rhs.free_temps(code) def generate_deletion_code(self, code): self.generate_subexpr_evaluation_code(code) #if self.type.is_pyobject: if self.index.type.is_int: function = "__Pyx_DelItemInt" index_code = self.index.result() code.globalstate.use_utility_code(delitem_int_utility_code) else: index_code = self.index.py_result() if self.base.type is dict_type: function = "PyDict_DelItem" else: function = "PyObject_DelItem" code.putln( "if (%s(%s, %s%s) < 0) %s" % ( function, self.base.py_result(), index_code, self.extra_index_params(), code.error_goto(self.pos))) self.generate_subexpr_disposal_code(code) self.free_subexpr_temps(code) def buffer_entry(self): import Buffer, MemoryView if self.base.is_name: entry = self.base.entry else: assert self.base.is_temp cname = self.base.result() entry = Symtab.Entry(cname, cname, self.base.type, self.base.pos) if entry.type.is_buffer: buffer_entry = Buffer.BufferEntry(entry) else: buffer_entry = MemoryView.MemoryViewSliceBufferEntry(entry) return buffer_entry def buffer_lookup_code(self, code): # Assign indices to temps index_temps = [code.funcstate.allocate_temp(i.type, manage_ref=False) for i in self.indices] for temp, index in zip(index_temps, self.indices): code.putln("%s = %s;" % (temp, index.result())) # Generate buffer access code using these temps import Buffer, MemoryView buffer_entry = self.buffer_entry() if buffer_entry.type.is_buffer: negative_indices = buffer_entry.type.negative_indices else: negative_indices = Buffer.buffer_defaults['negative_indices'] return buffer_entry, Buffer.put_buffer_lookup_code( entry=buffer_entry, index_signeds=[i.type.signed for i in self.indices], index_cnames=index_temps, directives=code.globalstate.directives, pos=self.pos, code=code, negative_indices=negative_indices) def put_memoryviewslice_slice_code(self, code): buffer_entry = self.buffer_entry() have_gil = not self.in_nogil_context buffer_entry.generate_buffer_slice_code(code, self.original_indices, self.result(), have_gil=have_gil) def put_nonecheck(self, code): code.globalstate.use_utility_code(raise_noneindex_error_utility_code) code.putln("if (%s) {" % code.unlikely("%s == Py_None") % self.base.result_as(PyrexTypes.py_object_type)) code.putln("__Pyx_RaiseNoneIndexingError();") code.putln(code.error_goto(self.pos)) code.putln("}") class SliceIndexNode(ExprNode): # 2-element slice indexing # # base ExprNode # start ExprNode or None # stop ExprNode or None subexprs = ['base', 'start', 'stop'] def infer_type(self, env): base_type = self.base.infer_type(env) if base_type.is_string: return bytes_type elif base_type in (bytes_type, str_type, unicode_type, list_type, tuple_type): return base_type elif base_type.is_ptr or base_type.is_array: return PyrexTypes.c_array_type(base_type.base_type, None) return py_object_type def calculate_constant_result(self): self.constant_result = self.base.constant_result[ self.start.constant_result : self.stop.constant_result] def compile_time_value(self, denv): base = self.base.compile_time_value(denv) if self.start is None: start = 0 else: start = self.start.compile_time_value(denv) if self.stop is None: stop = None else: stop = self.stop.compile_time_value(denv) try: return base[start:stop] except Exception, e: self.compile_time_value_error(e) def analyse_target_declaration(self, env): pass def analyse_target_types(self, env): self.analyse_types(env, getting=False) # when assigning, we must accept any Python type if self.type.is_pyobject: self.type = py_object_type def analyse_types(self, env, getting=True): self.base.analyse_types(env) if self.base.type.is_memoryviewslice: # Gross hack here! But we do not know the type until this point, # and we cannot create and return a new node. So we change the # type... none_node = NoneNode(self.pos) index = SliceNode(self.pos, start=self.start or none_node, stop=self.stop or none_node, step=none_node) del self.start del self.stop self.index = index self.__class__ = IndexNode self.analyse_base_and_index_types(env, getting=getting, setting=not getting, analyse_base=False) return if self.start: self.start.analyse_types(env) if self.stop: self.stop.analyse_types(env) base_type = self.base.type if base_type.is_string: self.type = bytes_type elif base_type.is_ptr: self.type = base_type elif base_type.is_array: # we need a ptr type here instead of an array type, as # array types can result in invalid type casts in the C # code self.type = PyrexTypes.CPtrType(base_type.base_type) else: self.base = self.base.coerce_to_pyobject(env) self.type = py_object_type if base_type.is_builtin_type: # slicing builtin types returns something of the same type self.type = base_type c_int = PyrexTypes.c_py_ssize_t_type if self.start: self.start = self.start.coerce_to(c_int, env) if self.stop: self.stop = self.stop.coerce_to(c_int, env) self.is_temp = 1 nogil_check = Node.gil_error gil_message = "Slicing Python object" def generate_result_code(self, code): if not self.type.is_pyobject: error(self.pos, "Slicing is not currently supported for '%s'." % self.type) return if self.base.type.is_string: if self.stop is None: code.putln( "%s = PyBytes_FromString(%s + %s); %s" % ( self.result(), self.base.result(), self.start_code(), code.error_goto_if_null(self.result(), self.pos))) else: code.putln( "%s = PyBytes_FromStringAndSize(%s + %s, %s - %s); %s" % ( self.result(), self.base.result(), self.start_code(), self.stop_code(), self.start_code(), code.error_goto_if_null(self.result(), self.pos))) else: code.putln( "%s = __Pyx_PySequence_GetSlice(%s, %s, %s); %s" % ( self.result(), self.base.py_result(), self.start_code(), self.stop_code(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) def generate_assignment_code(self, rhs, code): self.generate_subexpr_evaluation_code(code) if self.type.is_pyobject: code.put_error_if_neg(self.pos, "__Pyx_PySequence_SetSlice(%s, %s, %s, %s)" % ( self.base.py_result(), self.start_code(), self.stop_code(), rhs.py_result())) else: start_offset = '' if self.start: start_offset = self.start_code() if start_offset == '0': start_offset = '' else: start_offset += '+' if rhs.type.is_array: array_length = rhs.type.size self.generate_slice_guard_code(code, array_length) else: error(self.pos, "Slice assignments from pointers are not yet supported.") # FIXME: fix the array size according to start/stop array_length = self.base.type.size for i in range(array_length): code.putln("%s[%s%s] = %s[%d];" % ( self.base.result(), start_offset, i, rhs.result(), i)) self.generate_subexpr_disposal_code(code) self.free_subexpr_temps(code) rhs.generate_disposal_code(code) rhs.free_temps(code) def generate_deletion_code(self, code): if not self.base.type.is_pyobject: error(self.pos, "Deleting slices is only supported for Python types, not '%s'." % self.type) return self.generate_subexpr_evaluation_code(code) code.put_error_if_neg(self.pos, "__Pyx_PySequence_DelSlice(%s, %s, %s)" % ( self.base.py_result(), self.start_code(), self.stop_code())) self.generate_subexpr_disposal_code(code) self.free_subexpr_temps(code) def generate_slice_guard_code(self, code, target_size): if not self.base.type.is_array: return slice_size = self.base.type.size start = stop = None if self.stop: stop = self.stop.result() try: stop = int(stop) if stop < 0: slice_size = self.base.type.size + stop else: slice_size = stop stop = None except ValueError: pass if self.start: start = self.start.result() try: start = int(start) if start < 0: start = self.base.type.size + start slice_size -= start start = None except ValueError: pass check = None if slice_size < 0: if target_size > 0: error(self.pos, "Assignment to empty slice.") elif start is None and stop is None: # we know the exact slice length if target_size != slice_size: error(self.pos, "Assignment to slice of wrong length, expected %d, got %d" % ( slice_size, target_size)) elif start is not None: if stop is None: stop = slice_size check = "(%s)-(%s)" % (stop, start) else: # stop is not None: check = stop if check: code.putln("if (unlikely((%s) != %d)) {" % (check, target_size)) code.putln('PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %%"PY_FORMAT_SIZE_T"d, got %%"PY_FORMAT_SIZE_T"d", (Py_ssize_t)%d, (Py_ssize_t)(%s));' % ( target_size, check)) code.putln(code.error_goto(self.pos)) code.putln("}") def start_code(self): if self.start: return self.start.result() else: return "0" def stop_code(self): if self.stop: return self.stop.result() elif self.base.type.is_array: return self.base.type.size else: return "PY_SSIZE_T_MAX" def calculate_result_code(self): # self.result() is not used, but this method must exist return "<unused>" class SliceNode(ExprNode): # start:stop:step in subscript list # # start ExprNode # stop ExprNode # step ExprNode subexprs = ['start', 'stop', 'step'] type = py_object_type is_temp = 1 def calculate_constant_result(self): self.constant_result = slice( self.start.constant_result, self.stop.constant_result, self.step.constant_result) def compile_time_value(self, denv): start = self.start.compile_time_value(denv) stop = self.stop.compile_time_value(denv) step = self.step.compile_time_value(denv) try: return slice(start, stop, step) except Exception, e: self.compile_time_value_error(e) def analyse_types(self, env): self.start.analyse_types(env) self.stop.analyse_types(env) self.step.analyse_types(env) self.start = self.start.coerce_to_pyobject(env) self.stop = self.stop.coerce_to_pyobject(env) self.step = self.step.coerce_to_pyobject(env) if self.start.is_literal and self.stop.is_literal and self.step.is_literal: self.is_literal = True self.is_temp = False gil_message = "Constructing Python slice object" def calculate_result_code(self): return self.result_code def generate_result_code(self, code): if self.is_literal: self.result_code = code.get_py_const(py_object_type, 'slice_', cleanup_level=2) code = code.get_cached_constants_writer() code.mark_pos(self.pos) code.putln( "%s = PySlice_New(%s, %s, %s); %s" % ( self.result(), self.start.py_result(), self.stop.py_result(), self.step.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) if self.is_literal: code.put_giveref(self.py_result()) class CallNode(ExprNode): # allow overriding the default 'may_be_none' behaviour may_return_none = None def may_be_none(self): if self.may_return_none is not None: return self.may_return_none return ExprNode.may_be_none(self) def analyse_as_type_constructor(self, env): type = self.function.analyse_as_type(env) if type and type.is_struct_or_union: args, kwds = self.explicit_args_kwds() items = [] for arg, member in zip(args, type.scope.var_entries): items.append(DictItemNode(pos=arg.pos, key=StringNode(pos=arg.pos, value=member.name), value=arg)) if kwds: items += kwds.key_value_pairs self.key_value_pairs = items self.__class__ = DictNode self.analyse_types(env) self.coerce_to(type, env) return True elif type and type.is_cpp_class: for arg in self.args: arg.analyse_types(env) constructor = type.scope.lookup("<init>") self.function = RawCNameExprNode(self.function.pos, constructor.type) self.function.entry = constructor self.function.set_cname(type.declaration_code("")) self.analyse_c_function_call(env) return True def is_lvalue(self): return self.type.is_reference def nogil_check(self, env): func_type = self.function_type() if func_type.is_pyobject: self.gil_error() elif not getattr(func_type, 'nogil', False): self.gil_error() gil_message = "Calling gil-requiring function" class SimpleCallNode(CallNode): # Function call without keyword, * or ** args. # # function ExprNode # args [ExprNode] # arg_tuple ExprNode or None used internally # self ExprNode or None used internally # coerced_self ExprNode or None used internally # wrapper_call bool used internally # has_optional_args bool used internally # nogil bool used internally subexprs = ['self', 'coerced_self', 'function', 'args', 'arg_tuple'] self = None coerced_self = None arg_tuple = None wrapper_call = False has_optional_args = False nogil = False analysed = False def compile_time_value(self, denv): function = self.function.compile_time_value(denv) args = [arg.compile_time_value(denv) for arg in self.args] try: return function(*args) except Exception, e: self.compile_time_value_error(e) def type_dependencies(self, env): # TODO: Update when Danilo's C++ code merged in to handle the # the case of function overloading. return self.function.type_dependencies(env) def infer_type(self, env): function = self.function func_type = function.infer_type(env) if isinstance(self.function, NewExprNode): return PyrexTypes.CPtrType(self.function.class_type) if func_type.is_ptr: func_type = func_type.base_type if func_type.is_cfunction: return func_type.return_type elif func_type is type_type: if function.is_name and function.entry and function.entry.type: result_type = function.entry.type if result_type.is_extension_type: return result_type elif result_type.is_builtin_type: if function.entry.name == 'float': return PyrexTypes.c_double_type elif function.entry.name in Builtin.types_that_construct_their_instance: return result_type return py_object_type def analyse_as_type(self, env): attr = self.function.as_cython_attribute() if attr == 'pointer': if len(self.args) != 1: error(self.args.pos, "only one type allowed.") else: type = self.args[0].analyse_as_type(env) if not type: error(self.args[0].pos, "Unknown type") else: return PyrexTypes.CPtrType(type) def explicit_args_kwds(self): return self.args, None def analyse_types(self, env): if self.analyse_as_type_constructor(env): return if self.analysed: return self.analysed = True function = self.function function.is_called = 1 self.function.analyse_types(env) if function.is_attribute and function.entry and function.entry.is_cmethod: # Take ownership of the object from which the attribute # was obtained, because we need to pass it as 'self'. self.self = function.obj function.obj = CloneNode(self.self) func_type = self.function_type() if func_type.is_pyobject: self.arg_tuple = TupleNode(self.pos, args = self.args) self.arg_tuple.analyse_types(env) self.args = None if func_type is Builtin.type_type and function.is_name and \ function.entry and \ function.entry.is_builtin and \ function.entry.name in Builtin.types_that_construct_their_instance: # calling a builtin type that returns a specific object type if function.entry.name == 'float': # the following will come true later on in a transform self.type = PyrexTypes.c_double_type self.result_ctype = PyrexTypes.c_double_type else: self.type = Builtin.builtin_types[function.entry.name] self.result_ctype = py_object_type self.may_return_none = False elif function.is_name and function.type_entry: # We are calling an extension type constructor. As # long as we do not support __new__(), the result type # is clear self.type = function.type_entry.type self.result_ctype = py_object_type self.may_return_none = False else: self.type = py_object_type self.is_temp = 1 else: for arg in self.args: arg.analyse_types(env) if self.self and func_type.args: # Coerce 'self' to the type expected by the method. self_arg = func_type.args[0] if self_arg.not_none: # C methods must do the None test for self at *call* time self.self = self.self.as_none_safe_node( "'NoneType' object has no attribute '%s'", error = 'PyExc_AttributeError', format_args = [self.function.entry.name]) expected_type = self_arg.type if self_arg.accept_builtin_subtypes: self.coerced_self = CMethodSelfCloneNode(self.self) else: self.coerced_self = CloneNode(self.self) self.coerced_self = self.coerced_self.coerce_to(expected_type, env) # Insert coerced 'self' argument into argument list. self.args.insert(0, self.coerced_self) self.analyse_c_function_call(env) def function_type(self): # Return the type of the function being called, coercing a function # pointer to a function if necessary. func_type = self.function.type if func_type.is_ptr: func_type = func_type.base_type return func_type def is_simple(self): # C function calls could be considered simple, but they may # have side-effects that may hit when multiple operations must # be effected in order, e.g. when constructing the argument # sequence for a function call or comparing values. return False def analyse_c_function_call(self, env): if self.function.type is error_type: self.type = error_type return if self.function.type.is_cpp_class: overloaded_entry = self.function.type.scope.lookup("operator()") if overloaded_entry is None: self.type = PyrexTypes.error_type self.result_code = "<error>" return elif hasattr(self.function, 'entry'): overloaded_entry = self.function.entry else: overloaded_entry = None if overloaded_entry: entry = PyrexTypes.best_match(self.args, overloaded_entry.all_alternatives(), self.pos) if not entry: self.type = PyrexTypes.error_type self.result_code = "<error>" return self.function.entry = entry self.function.type = entry.type func_type = self.function_type() else: func_type = self.function_type() if not func_type.is_cfunction: error(self.pos, "Calling non-function type '%s'" % func_type) self.type = PyrexTypes.error_type self.result_code = "<error>" return # Check no. of args max_nargs = len(func_type.args) expected_nargs = max_nargs - func_type.optional_arg_count actual_nargs = len(self.args) if func_type.optional_arg_count and expected_nargs != actual_nargs: self.has_optional_args = 1 self.is_temp = 1 # Coerce arguments some_args_in_temps = False for i in xrange(min(max_nargs, actual_nargs)): formal_type = func_type.args[i].type arg = self.args[i].coerce_to(formal_type, env) if arg.is_temp: if i > 0: # first argument in temp doesn't impact subsequent arguments some_args_in_temps = True elif arg.type.is_pyobject and not env.nogil: if i == 0 and self.self is not None: # a method's cloned "self" argument is ok pass elif arg.nonlocally_immutable(): # plain local variables are ok pass else: # we do not safely own the argument's reference, # but we must make sure it cannot be collected # before we return from the function, so we create # an owned temp reference to it if i > 0: # first argument doesn't matter some_args_in_temps = True arg = arg.coerce_to_temp(env) self.args[i] = arg # handle additional varargs parameters for i in xrange(max_nargs, actual_nargs): arg = self.args[i] if arg.type.is_pyobject: arg_ctype = arg.type.default_coerced_ctype() if arg_ctype is None: error(self.args[i].pos, "Python object cannot be passed as a varargs parameter") else: self.args[i] = arg = arg.coerce_to(arg_ctype, env) if arg.is_temp and i > 0: some_args_in_temps = True if some_args_in_temps: # if some args are temps and others are not, they may get # constructed in the wrong order (temps first) => make # sure they are either all temps or all not temps (except # for the last argument, which is evaluated last in any # case) for i in xrange(actual_nargs-1): if i == 0 and self.self is not None: continue # self is ok arg = self.args[i] if arg.nonlocally_immutable(): # locals, C functions, unassignable types are safe. pass elif arg.type.is_cpp_class: # Assignment has side effects, avoid. pass elif env.nogil and arg.type.is_pyobject: # can't copy a Python reference into a temp in nogil # env (this is safe: a construction would fail in # nogil anyway) pass else: #self.args[i] = arg.coerce_to_temp(env) # instead: issue a warning if i > 0 or i == 1 and self.self is not None: # skip first arg warning(arg.pos, "Argument evaluation order in C function call is undefined and may not be as expected", 0) break # Calc result type and code fragment if isinstance(self.function, NewExprNode): self.type = PyrexTypes.CPtrType(self.function.class_type) else: self.type = func_type.return_type if self.function.is_name or self.function.is_attribute: if self.function.entry and self.function.entry.utility_code: self.is_temp = 1 # currently doesn't work for self.calculate_result_code() if self.type.is_pyobject: self.result_ctype = py_object_type self.is_temp = 1 elif func_type.exception_value is not None \ or func_type.exception_check: self.is_temp = 1 elif self.type.is_memoryviewslice: self.is_temp = 1 # func_type.exception_check = True # Called in 'nogil' context? self.nogil = env.nogil if (self.nogil and func_type.exception_check and func_type.exception_check != '+'): env.use_utility_code(pyerr_occurred_withgil_utility_code) # C++ exception handler if func_type.exception_check == '+': if func_type.exception_value is None: env.use_utility_code(cpp_exception_utility_code) def calculate_result_code(self): return self.c_call_code() def c_call_code(self): func_type = self.function_type() if self.type is PyrexTypes.error_type or not func_type.is_cfunction: return "<error>" formal_args = func_type.args arg_list_code = [] args = list(zip(formal_args, self.args)) max_nargs = len(func_type.args) expected_nargs = max_nargs - func_type.optional_arg_count actual_nargs = len(self.args) for formal_arg, actual_arg in args[:expected_nargs]: arg_code = actual_arg.result_as(formal_arg.type) arg_list_code.append(arg_code) if func_type.is_overridable: arg_list_code.append(str(int(self.wrapper_call or self.function.entry.is_unbound_cmethod))) if func_type.optional_arg_count: if expected_nargs == actual_nargs: optional_args = 'NULL' else: optional_args = "&%s" % self.opt_arg_struct arg_list_code.append(optional_args) for actual_arg in self.args[len(formal_args):]: arg_list_code.append(actual_arg.result()) result = "%s(%s)" % (self.function.result(), ', '.join(arg_list_code)) return result def generate_result_code(self, code): func_type = self.function_type() if self.function.is_name or self.function.is_attribute: if self.function.entry and self.function.entry.utility_code: code.globalstate.use_utility_code(self.function.entry.utility_code) if func_type.is_pyobject: arg_code = self.arg_tuple.py_result() code.putln( "%s = PyObject_Call(%s, %s, NULL); %s" % ( self.result(), self.function.py_result(), arg_code, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) elif func_type.is_cfunction: if self.has_optional_args: actual_nargs = len(self.args) expected_nargs = len(func_type.args) - func_type.optional_arg_count self.opt_arg_struct = code.funcstate.allocate_temp( func_type.op_arg_struct.base_type, manage_ref=True) code.putln("%s.%s = %s;" % ( self.opt_arg_struct, Naming.pyrex_prefix + "n", len(self.args) - expected_nargs)) args = list(zip(func_type.args, self.args)) for formal_arg, actual_arg in args[expected_nargs:actual_nargs]: code.putln("%s.%s = %s;" % ( self.opt_arg_struct, func_type.opt_arg_cname(formal_arg.name), actual_arg.result_as(formal_arg.type))) exc_checks = [] if self.type.is_pyobject and self.is_temp: exc_checks.append("!%s" % self.result()) elif self.type.is_memoryviewslice: assert self.is_temp exc_checks.append(self.type.error_condition(self.result())) else: exc_val = func_type.exception_value exc_check = func_type.exception_check if exc_val is not None: exc_checks.append("%s == %s" % (self.result(), exc_val)) if exc_check: if self.nogil: exc_checks.append("__Pyx_ErrOccurredWithGIL()") else: exc_checks.append("PyErr_Occurred()") if self.is_temp or exc_checks: rhs = self.c_call_code() if self.result(): lhs = "%s = " % self.result() if self.is_temp and self.type.is_pyobject: #return_type = self.type # func_type.return_type #print "SimpleCallNode.generate_result_code: casting", rhs, \ # "from", return_type, "to pyobject" ### rhs = typecast(py_object_type, self.type, rhs) else: lhs = "" if func_type.exception_check == '+': if func_type.exception_value is None: raise_py_exception = "__Pyx_CppExn2PyErr()" elif func_type.exception_value.type.is_pyobject: raise_py_exception = ' try { throw; } catch(const std::exception& exn) { PyErr_SetString(%s, exn.what()); } catch(...) { PyErr_SetNone(%s); }' % ( func_type.exception_value.entry.cname, func_type.exception_value.entry.cname) else: raise_py_exception = '%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.")' % func_type.exception_value.entry.cname if self.nogil: raise_py_exception = 'Py_BLOCK_THREADS; %s; Py_UNBLOCK_THREADS' % raise_py_exception code.putln( "try {%s%s;} catch(...) {%s; %s}" % ( lhs, rhs, raise_py_exception, code.error_goto(self.pos))) else: if exc_checks: goto_error = code.error_goto_if(" && ".join(exc_checks), self.pos) else: goto_error = "" code.putln("%s%s; %s" % (lhs, rhs, goto_error)) if self.type.is_pyobject and self.result(): code.put_gotref(self.py_result()) if self.has_optional_args: code.funcstate.release_temp(self.opt_arg_struct) class PythonCapiFunctionNode(ExprNode): subexprs = [] def __init__(self, pos, py_name, cname, func_type, utility_code = None): self.pos = pos self.name = py_name self.cname = cname self.type = func_type self.utility_code = utility_code def analyse_types(self, env): pass def generate_result_code(self, code): if self.utility_code: code.globalstate.use_utility_code(self.utility_code) def calculate_result_code(self): return self.cname class PythonCapiCallNode(SimpleCallNode): # Python C-API Function call (only created in transforms) # By default, we assume that the call never returns None, as this # is true for most C-API functions in CPython. If this does not # apply to a call, set the following to True (or None to inherit # the default behaviour). may_return_none = False def __init__(self, pos, function_name, func_type, utility_code = None, py_name=None, **kwargs): self.type = func_type.return_type self.result_ctype = self.type self.function = PythonCapiFunctionNode( pos, py_name, function_name, func_type, utility_code = utility_code) # call this last so that we can override the constructed # attributes above with explicit keyword arguments if required SimpleCallNode.__init__(self, pos, **kwargs) class GeneralCallNode(CallNode): # General Python function call, including keyword, # * and ** arguments. # # function ExprNode # positional_args ExprNode Tuple of positional arguments # keyword_args ExprNode or None Dict of keyword arguments type = py_object_type subexprs = ['function', 'positional_args', 'keyword_args'] nogil_check = Node.gil_error def compile_time_value(self, denv): function = self.function.compile_time_value(denv) positional_args = self.positional_args.compile_time_value(denv) keyword_args = self.keyword_args.compile_time_value(denv) try: return function(*positional_args, **keyword_args) except Exception, e: self.compile_time_value_error(e) def explicit_args_kwds(self): if (self.keyword_args and not isinstance(self.keyword_args, DictNode) or not isinstance(self.positional_args, TupleNode)): raise CompileError(self.pos, 'Compile-time keyword arguments must be explicit.') return self.positional_args.args, self.keyword_args def analyse_types(self, env): if self.analyse_as_type_constructor(env): return self.function.analyse_types(env) self.positional_args.analyse_types(env) if self.keyword_args: self.keyword_args.analyse_types(env) if not self.function.type.is_pyobject: if self.function.type.is_error: self.type = error_type return if hasattr(self.function, 'entry') and not self.function.entry.as_variable: error(self.pos, "Keyword and starred arguments not allowed in cdef functions.") else: self.function = self.function.coerce_to_pyobject(env) self.positional_args = \ self.positional_args.coerce_to_pyobject(env) function = self.function if function.is_name and function.type_entry: # We are calling an extension type constructor. As long # as we do not support __new__(), the result type is clear self.type = function.type_entry.type self.result_ctype = py_object_type self.may_return_none = False else: self.type = py_object_type self.is_temp = 1 def generate_result_code(self, code): if self.type.is_error: return if self.keyword_args: kwargs = self.keyword_args.py_result() else: kwargs = 'NULL' code.putln( "%s = PyObject_Call(%s, %s, %s); %s" % ( self.result(), self.function.py_result(), self.positional_args.py_result(), kwargs, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class AsTupleNode(ExprNode): # Convert argument to tuple. Used for normalising # the * argument of a function call. # # arg ExprNode subexprs = ['arg'] def calculate_constant_result(self): self.constant_result = tuple(self.base.constant_result) def compile_time_value(self, denv): arg = self.arg.compile_time_value(denv) try: return tuple(arg) except Exception, e: self.compile_time_value_error(e) def analyse_types(self, env): self.arg.analyse_types(env) self.arg = self.arg.coerce_to_pyobject(env) self.type = tuple_type self.is_temp = 1 def may_be_none(self): return False nogil_check = Node.gil_error gil_message = "Constructing Python tuple" def generate_result_code(self, code): code.putln( "%s = PySequence_Tuple(%s); %s" % ( self.result(), self.arg.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class AttributeNode(ExprNode): # obj.attribute # # obj ExprNode # attribute string # needs_none_check boolean Used if obj is an extension type. # If set to True, it is known that the type is not None. # # Used internally: # # is_py_attr boolean Is a Python getattr operation # member string C name of struct member # is_called boolean Function call is being done on result # entry Entry Symbol table entry of attribute is_attribute = 1 subexprs = ['obj'] type = PyrexTypes.error_type entry = None is_called = 0 needs_none_check = True is_memslice_transpose = False def as_cython_attribute(self): if (isinstance(self.obj, NameNode) and self.obj.is_cython_module and not self.attribute == u"parallel"): return self.attribute cy = self.obj.as_cython_attribute() if cy: return "%s.%s" % (cy, self.attribute) return None def coerce_to(self, dst_type, env): # If coercing to a generic pyobject and this is a cpdef function # we can create the corresponding attribute if dst_type is py_object_type: entry = self.entry if entry and entry.is_cfunction and entry.as_variable: # must be a cpdef function self.is_temp = 1 self.entry = entry.as_variable self.analyse_as_python_attribute(env) return self return ExprNode.coerce_to(self, dst_type, env) def calculate_constant_result(self): attr = self.attribute if attr.startswith("__") and attr.endswith("__"): return self.constant_result = getattr(self.obj.constant_result, attr) def compile_time_value(self, denv): attr = self.attribute if attr.startswith("__") and attr.endswith("__"): error(self.pos, "Invalid attribute name '%s' in compile-time expression" % attr) return None obj = self.obj.compile_time_value(denv) try: return getattr(obj, attr) except Exception, e: self.compile_time_value_error(e) def type_dependencies(self, env): return self.obj.type_dependencies(env) def infer_type(self, env): if self.analyse_as_cimported_attribute(env, 0): return self.entry.type elif self.analyse_as_unbound_cmethod(env): return self.entry.type else: obj_type = self.obj.infer_type(env) self.analyse_attribute(env, obj_type = obj_type) if obj_type.is_builtin_type and self.type.is_cfunction: # special case: C-API replacements for C methods of # builtin types cannot be inferred as C functions as # that would prevent their use as bound methods self.type = py_object_type return py_object_type return self.type def analyse_target_declaration(self, env): pass def analyse_target_types(self, env): self.analyse_types(env, target = 1) def analyse_types(self, env, target = 0): self.initialized_check = env.directives['initializedcheck'] if self.analyse_as_cimported_attribute(env, target): self.entry.used = True elif not target and self.analyse_as_unbound_cmethod(env): self.entry.used = True else: self.analyse_as_ordinary_attribute(env, target) if self.entry: self.entry.used = True def analyse_as_cimported_attribute(self, env, target): # Try to interpret this as a reference to an imported # C const, type, var or function. If successful, mutates # this node into a NameNode and returns 1, otherwise # returns 0. module_scope = self.obj.analyse_as_module(env) if module_scope: entry = module_scope.lookup_here(self.attribute) if entry and ( entry.is_cglobal or entry.is_cfunction or entry.is_type or entry.is_const): self.mutate_into_name_node(env, entry, target) entry.used = 1 return 1 return 0 def analyse_as_unbound_cmethod(self, env): # Try to interpret this as a reference to an unbound # C method of an extension type. If successful, mutates # this node into a NameNode and returns 1, otherwise # returns 0. type = self.obj.analyse_as_extension_type(env) if type: entry = type.scope.lookup_here(self.attribute) if entry and entry.is_cmethod: # Create a temporary entry describing the C method # as an ordinary function. ubcm_entry = Symtab.Entry(entry.name, "%s->%s" % (type.vtabptr_cname, entry.cname), entry.type) ubcm_entry.is_cfunction = 1 ubcm_entry.func_cname = entry.func_cname ubcm_entry.is_unbound_cmethod = 1 self.mutate_into_name_node(env, ubcm_entry, None) return 1 return 0 def analyse_as_type(self, env): module_scope = self.obj.analyse_as_module(env) if module_scope: return module_scope.lookup_type(self.attribute) if not self.obj.is_string_literal: base_type = self.obj.analyse_as_type(env) if base_type and hasattr(base_type, 'scope') and base_type.scope is not None: return base_type.scope.lookup_type(self.attribute) return None def analyse_as_extension_type(self, env): # Try to interpret this as a reference to an extension type # in a cimported module. Returns the extension type, or None. module_scope = self.obj.analyse_as_module(env) if module_scope: entry = module_scope.lookup_here(self.attribute) if entry and entry.is_type and entry.type.is_extension_type: return entry.type return None def analyse_as_module(self, env): # Try to interpret this as a reference to a cimported module # in another cimported module. Returns the module scope, or None. module_scope = self.obj.analyse_as_module(env) if module_scope: entry = module_scope.lookup_here(self.attribute) if entry and entry.as_module: return entry.as_module return None def mutate_into_name_node(self, env, entry, target): # Mutate this node into a NameNode and complete the # analyse_types phase. self.__class__ = NameNode self.name = self.attribute self.entry = entry del self.obj del self.attribute if target: NameNode.analyse_target_types(self, env) else: NameNode.analyse_rvalue_entry(self, env) def analyse_as_ordinary_attribute(self, env, target): self.obj.analyse_types(env) self.analyse_attribute(env) if self.entry and self.entry.is_cmethod and not self.is_called: # error(self.pos, "C method can only be called") pass ## Reference to C array turns into pointer to first element. #while self.type.is_array: # self.type = self.type.element_ptr_type() if self.is_py_attr: if not target: self.is_temp = 1 self.result_ctype = py_object_type elif target and self.obj.type.is_builtin_type: error(self.pos, "Assignment to an immutable object field") #elif self.type.is_memoryviewslice and not target: # self.is_temp = True def analyse_attribute(self, env, obj_type = None): # Look up attribute and set self.type and self.member. self.is_py_attr = 0 self.member = self.attribute if obj_type is None: if self.obj.type.is_string: self.obj = self.obj.coerce_to_pyobject(env) obj_type = self.obj.type else: if obj_type.is_string: obj_type = py_object_type if obj_type.is_ptr or obj_type.is_array: obj_type = obj_type.base_type self.op = "->" elif obj_type.is_extension_type or obj_type.is_builtin_type: self.op = "->" else: self.op = "." if obj_type.has_attributes: entry = None if obj_type.attributes_known(): if (obj_type.is_memoryviewslice and not obj_type.scope.lookup_here(self.attribute)): if self.attribute == 'T': self.is_memslice_transpose = True self.is_temp = True self.use_managed_ref = True self.type = self.obj.type return else: obj_type.declare_attribute(self.attribute) entry = obj_type.scope.lookup_here(self.attribute) if entry and entry.is_member: entry = None else: error(self.pos, "Cannot select attribute of incomplete type '%s'" % obj_type) self.type = PyrexTypes.error_type return self.entry = entry if entry: if obj_type.is_extension_type and entry.name == "__weakref__": error(self.pos, "Illegal use of special attribute __weakref__") # methods need the normal attribute lookup # because they do not have struct entries if entry.is_variable or entry.is_cmethod: self.type = entry.type self.member = entry.cname return else: # If it's not a variable or C method, it must be a Python # method of an extension type, so we treat it like a Python # attribute. pass # If we get here, the base object is not a struct/union/extension # type, or it is an extension type and the attribute is either not # declared or is declared as a Python method. Treat it as a Python # attribute reference. self.analyse_as_python_attribute(env, obj_type) def analyse_as_python_attribute(self, env, obj_type = None): if obj_type is None: obj_type = self.obj.type # mangle private '__*' Python attributes used inside of a class self.attribute = env.mangle_class_private_name(self.attribute) self.member = self.attribute self.type = py_object_type self.is_py_attr = 1 if not obj_type.is_pyobject and not obj_type.is_error: if obj_type.can_coerce_to_pyobject(env): self.obj = self.obj.coerce_to_pyobject(env) else: error(self.pos, "Object of type '%s' has no attribute '%s'" % (obj_type, self.attribute)) def nogil_check(self, env): if self.is_py_attr: self.gil_error() elif self.type.is_memoryviewslice: import MemoryView MemoryView.err_if_nogil_initialized_check(self.pos, env, 'attribute') gil_message = "Accessing Python attribute" def is_simple(self): if self.obj: return self.result_in_temp() or self.obj.is_simple() else: return NameNode.is_simple(self) def is_lvalue(self): if self.obj: return 1 else: return NameNode.is_lvalue(self) def is_ephemeral(self): if self.obj: return self.obj.is_ephemeral() else: return NameNode.is_ephemeral(self) def calculate_result_code(self): #print "AttributeNode.calculate_result_code:", self.member ### #print "...obj node =", self.obj, "code", self.obj.result() ### #print "...obj type", self.obj.type, "ctype", self.obj.ctype() ### obj = self.obj obj_code = obj.result_as(obj.type) #print "...obj_code =", obj_code ### if self.entry and self.entry.is_cmethod: if obj.type.is_extension_type and not self.entry.is_builtin_cmethod: if self.entry.final_func_cname: return self.entry.final_func_cname return "((struct %s *)%s%s%s)->%s" % ( obj.type.vtabstruct_cname, obj_code, self.op, obj.type.vtabslot_cname, self.member) else: return self.member elif obj.type.is_complex: return "__Pyx_C%s(%s)" % (self.member.upper(), obj_code) else: if obj.type.is_builtin_type and self.entry and self.entry.is_variable: # accessing a field of a builtin type, need to cast better than result_as() does obj_code = obj.type.cast_code(obj.result(), to_object_struct = True) return "%s%s%s" % (obj_code, self.op, self.member) def generate_result_code(self, code): if self.is_py_attr: code.putln( '%s = PyObject_GetAttr(%s, %s); %s' % ( self.result(), self.obj.py_result(), code.intern_identifier(self.attribute), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) elif self.type.is_memoryviewslice: if self.is_memslice_transpose: # transpose the slice for access, packing in self.type.axes: if access == 'ptr': error(self.pos, "Transposing not supported for slices " "with indirect dimensions") return code.putln("%s = %s;" % (self.result(), self.obj.result())) if self.obj.is_name or self.obj.is_attribute and self.obj.is_memslice_transpose: code.put_incref_memoryviewslice(self.result(), have_gil=True) T = "__pyx_memslice_transpose(&%s) == 0" code.putln(code.error_goto_if(T % self.result(), self.pos)) elif self.initialized_check: code.putln( 'if (unlikely(!%s.memview)) {' 'PyErr_SetString(PyExc_AttributeError,' '"Memoryview is not initialized");' '%s' '}' % (self.result(), code.error_goto(self.pos))) else: # result_code contains what is needed, but we may need to insert # a check and raise an exception if self.obj.type.is_extension_type: if self.needs_none_check and code.globalstate.directives['nonecheck']: self.put_nonecheck(code) elif self.entry and self.entry.is_cmethod and self.entry.utility_code: # C method implemented as function call with utility code code.globalstate.use_utility_code(self.entry.utility_code) def generate_assignment_code(self, rhs, code): self.obj.generate_evaluation_code(code) if self.is_py_attr: code.put_error_if_neg(self.pos, 'PyObject_SetAttr(%s, %s, %s)' % ( self.obj.py_result(), code.intern_identifier(self.attribute), rhs.py_result())) rhs.generate_disposal_code(code) rhs.free_temps(code) elif self.obj.type.is_complex: code.putln("__Pyx_SET_C%s(%s, %s);" % ( self.member.upper(), self.obj.result_as(self.obj.type), rhs.result_as(self.ctype()))) else: if (self.obj.type.needs_nonecheck() and self.needs_none_check and code.globalstate.directives['nonecheck']): self.put_nonecheck(code) select_code = self.result() if self.type.is_pyobject and self.use_managed_ref: rhs.make_owned_reference(code) code.put_giveref(rhs.py_result()) code.put_gotref(select_code) code.put_decref(select_code, self.ctype()) elif self.type.is_memoryviewslice: import MemoryView MemoryView.put_assign_to_memviewslice( select_code, rhs.result(), self.type, code, incref_rhs=rhs.is_name) if not self.type.is_memoryviewslice: code.putln( "%s = %s;" % ( select_code, rhs.result_as(self.ctype()))) #rhs.result())) rhs.generate_post_assignment_code(code) rhs.free_temps(code) self.obj.generate_disposal_code(code) self.obj.free_temps(code) def generate_deletion_code(self, code): self.obj.generate_evaluation_code(code) if self.is_py_attr or (isinstance(self.entry.scope, Symtab.PropertyScope) and u'__del__' in self.entry.scope.entries): code.put_error_if_neg(self.pos, 'PyObject_DelAttr(%s, %s)' % ( self.obj.py_result(), code.intern_identifier(self.attribute))) else: error(self.pos, "Cannot delete C attribute of extension type") self.obj.generate_disposal_code(code) self.obj.free_temps(code) def annotate(self, code): if self.is_py_attr: code.annotate(self.pos, AnnotationItem('py_attr', 'python attribute', size=len(self.attribute))) else: code.annotate(self.pos, AnnotationItem('c_attr', 'c attribute', size=len(self.attribute))) def put_nonecheck(self, code): code.globalstate.use_utility_code(raise_noneattr_error_utility_code) if self.obj.type.is_extension_type: test = "%s == Py_None" % self.obj.result_as(PyrexTypes.py_object_type) elif self.obj.type.is_memoryviewslice: test = "!%s.memview" % self.obj.result() else: assert False code.putln("if (%s) {" % code.unlikely(test)) code.putln("__Pyx_RaiseNoneAttributeError(\"%s\");" % self.attribute) code.putln(code.error_goto(self.pos)) code.putln("}") #------------------------------------------------------------------- # # Constructor nodes # #------------------------------------------------------------------- class StarredTargetNode(ExprNode): # A starred expression like "*a" # # This is only allowed in sequence assignment targets such as # # a, *b = (1,2,3,4) => a = 1 ; b = [2,3,4] # # and will be removed during type analysis (or generate an error # if it's found at unexpected places). # # target ExprNode subexprs = ['target'] is_starred = 1 type = py_object_type is_temp = 1 def __init__(self, pos, target): self.pos = pos self.target = target def analyse_declarations(self, env): error(self.pos, "can use starred expression only as assignment target") self.target.analyse_declarations(env) def analyse_types(self, env): error(self.pos, "can use starred expression only as assignment target") self.target.analyse_types(env) self.type = self.target.type def analyse_target_declaration(self, env): self.target.analyse_target_declaration(env) def analyse_target_types(self, env): self.target.analyse_target_types(env) self.type = self.target.type def calculate_result_code(self): return "" def generate_result_code(self, code): pass class SequenceNode(ExprNode): # Base class for list and tuple constructor nodes. # Contains common code for performing sequence unpacking. # # args [ExprNode] # unpacked_items [ExprNode] or None # coerced_unpacked_items [ExprNode] or None # mult_factor ExprNode the integer number of content repetitions ([1,2]*3) subexprs = ['args', 'mult_factor'] is_sequence_constructor = 1 unpacked_items = None mult_factor = None def compile_time_value_list(self, denv): return [arg.compile_time_value(denv) for arg in self.args] def replace_starred_target_node(self): # replace a starred node in the targets by the contained expression self.starred_assignment = False args = [] for arg in self.args: if arg.is_starred: if self.starred_assignment: error(arg.pos, "more than 1 starred expression in assignment") self.starred_assignment = True arg = arg.target arg.is_starred = True args.append(arg) self.args = args def analyse_target_declaration(self, env): self.replace_starred_target_node() for arg in self.args: arg.analyse_target_declaration(env) def analyse_types(self, env, skip_children=False): for i in range(len(self.args)): arg = self.args[i] if not skip_children: arg.analyse_types(env) self.args[i] = arg.coerce_to_pyobject(env) if self.mult_factor: self.mult_factor.analyse_types(env) if not self.mult_factor.type.is_int: if self.mult_factor.type.is_pyobject: self.mult_factor = self.mult_factor.coerce_to( PyrexTypes.c_py_ssize_t_type, env) else: error(self.pos, "can't multiply sequence by non-int of type '%s'" % self.mult_factor.type) self.is_temp = 1 # not setting self.type here, subtypes do this def may_be_none(self): return False def analyse_target_types(self, env): if self.mult_factor: error(arg.pos, "can't assign to multiplied sequence") self.unpacked_items = [] self.coerced_unpacked_items = [] self.any_coerced_items = False for arg in self.args: arg.analyse_target_types(env) if arg.is_starred: if not arg.type.assignable_from(Builtin.list_type): error(arg.pos, "starred target must have Python object (list) type") if arg.type is py_object_type: arg.type = Builtin.list_type unpacked_item = PyTempNode(self.pos, env) coerced_unpacked_item = unpacked_item.coerce_to(arg.type, env) if unpacked_item is not coerced_unpacked_item: self.any_coerced_items = True self.unpacked_items.append(unpacked_item) self.coerced_unpacked_items.append(coerced_unpacked_item) self.type = py_object_type def generate_result_code(self, code): self.generate_operation_code(code) def generate_sequence_packing_code(self, code): if self.type is Builtin.list_type: create_func, set_item_func = 'PyList_New', 'PyList_SET_ITEM' elif self.type is Builtin.tuple_type: create_func, set_item_func = 'PyTuple_New', 'PyTuple_SET_ITEM' else: raise InternalError("sequence unpacking for unexpected type %s" % self.type) if self.mult_factor: mult = self.mult_factor.result() if isinstance(self.mult_factor.constant_result, (int,long)) \ and self.mult_factor.constant_result > 0: size_factor = ' * %s' % self.mult_factor.constant_result else: size_factor = ' * ((%s<0) ? 0:%s)' % (mult, mult) else: size_factor = '' mult = '' arg_count = len(self.args) code.putln("%s = %s(%s%s); %s" % ( self.result(), create_func, arg_count, size_factor, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) if mult: # FIXME: can't use a temp variable here as the code may # end up in the constant building function. Temps # currently don't work there. #counter = code.funcstate.allocate_temp(self.mult_factor.type, manage_ref=False) counter = '__pyx_n' code.putln('{ Py_ssize_t %s;' % counter) if arg_count == 1: offset = counter + ' + ' else: offset = '%s * %s + ' % (counter, arg_count) code.putln('for (%s=0; %s < %s; %s++) {' % ( counter, counter, mult, counter )) else: offset = '' for i in xrange(arg_count): arg = self.args[i] if mult or not arg.result_in_temp(): code.put_incref(arg.result(), arg.ctype()) code.putln("%s(%s, %s%s, %s);" % ( set_item_func, self.result(), offset, i, arg.py_result())) code.put_giveref(arg.py_result()) if mult: code.putln('}') #code.funcstate.release_temp(counter) code.putln('}') def generate_subexpr_disposal_code(self, code): if self.mult_factor: super(SequenceNode, self).generate_subexpr_disposal_code(code) else: # We call generate_post_assignment_code here instead # of generate_disposal_code, because values were stored # in the tuple using a reference-stealing operation. for arg in self.args: arg.generate_post_assignment_code(code) # Should NOT call free_temps -- this is invoked by the default # generate_evaluation_code which will do that. def generate_assignment_code(self, rhs, code): if self.starred_assignment: self.generate_starred_assignment_code(rhs, code) else: self.generate_parallel_assignment_code(rhs, code) for item in self.unpacked_items: item.release(code) rhs.free_temps(code) _func_iternext_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType( PyrexTypes.py_object_type, [ PyrexTypes.CFuncTypeArg("it", PyrexTypes.py_object_type, None), ])) def generate_parallel_assignment_code(self, rhs, code): # Need to work around the fact that generate_evaluation_code # allocates the temps in a rather hacky way -- the assignment # is evaluated twice, within each if-block. for item in self.unpacked_items: item.allocate(code) special_unpack = (rhs.type is py_object_type or rhs.type in (tuple_type, list_type) or not rhs.type.is_builtin_type) if special_unpack: tuple_check = 'likely(PyTuple_CheckExact(%s))' % rhs.py_result() list_check = 'PyList_CheckExact(%s)' % rhs.py_result() if rhs.type is list_type: sequence_types = ['List'] sequence_type_test = list_check elif rhs.type is tuple_type: sequence_types = ['Tuple'] sequence_type_test = tuple_check else: sequence_types = ['Tuple', 'List'] sequence_type_test = "(%s) || (%s)" % (tuple_check, list_check) code.putln("if (%s) {" % sequence_type_test) code.putln("PyObject* sequence = %s;" % rhs.py_result()) if len(sequence_types) == 2: code.putln("if (likely(Py%s_CheckExact(sequence))) {" % sequence_types[0]) self.generate_special_parallel_unpacking_code(code, sequence_types[0]) if len(sequence_types) == 2: code.putln("} else {") self.generate_special_parallel_unpacking_code(code, sequence_types[1]) code.putln("}") for item in self.unpacked_items: code.put_incref(item.result(), item.ctype()) rhs.generate_disposal_code(code) code.putln("} else {") else: code.putln("{") if special_unpack and rhs.type is tuple_type: code.globalstate.use_utility_code(tuple_unpacking_error_code) code.putln("__Pyx_UnpackTupleError(%s, %s);" % ( rhs.py_result(), len(self.args))) code.putln(code.error_goto(self.pos)) else: self.generate_generic_parallel_unpacking_code(code, rhs) code.putln("}") for value_node in self.coerced_unpacked_items: value_node.generate_evaluation_code(code) for i in range(len(self.args)): self.args[i].generate_assignment_code( self.coerced_unpacked_items[i], code) def generate_special_parallel_unpacking_code(self, code, sequence_type): code.globalstate.use_utility_code(raise_need_more_values_to_unpack) code.globalstate.use_utility_code(raise_too_many_values_to_unpack) code.putln("if (unlikely(Py%s_GET_SIZE(sequence) != %d)) {" % ( sequence_type, len(self.args))) code.putln("if (Py%s_GET_SIZE(sequence) > %d) __Pyx_RaiseTooManyValuesError(%d);" % ( sequence_type, len(self.args), len(self.args))) code.putln("else __Pyx_RaiseNeedMoreValuesError(Py%s_GET_SIZE(sequence));" % sequence_type) code.putln(code.error_goto(self.pos)) code.putln("}") for i, item in enumerate(self.unpacked_items): code.putln("%s = Py%s_GET_ITEM(sequence, %d); " % (item.result(), sequence_type, i)) def generate_generic_parallel_unpacking_code(self, code, rhs): code.globalstate.use_utility_code(iternext_unpacking_end_utility_code) code.globalstate.use_utility_code(raise_need_more_values_to_unpack) code.putln("Py_ssize_t index = -1;") # must be at the start of a C block! iterator_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) code.putln( "%s = PyObject_GetIter(%s); %s" % ( iterator_temp, rhs.py_result(), code.error_goto_if_null(iterator_temp, self.pos))) code.put_gotref(iterator_temp) rhs.generate_disposal_code(code) iternext_func = code.funcstate.allocate_temp(self._func_iternext_type, manage_ref=False) code.putln("%s = Py_TYPE(%s)->tp_iternext;" % ( iternext_func, iterator_temp)) unpacking_error_label = code.new_label('unpacking_failed') code.use_label(unpacking_error_label) unpack_code = "%s(%s)" % (iternext_func, iterator_temp) for i in range(len(self.args)): item = self.unpacked_items[i] code.putln( "index = %d; %s = %s; if (unlikely(!%s)) goto %s;" % ( i, item.result(), typecast(item.ctype(), py_object_type, unpack_code), item.result(), unpacking_error_label)) code.put_gotref(item.py_result()) code.put_error_if_neg(self.pos, "__Pyx_IternextUnpackEndCheck(%s(%s), %d)" % ( iternext_func, iterator_temp, len(self.args))) code.put_decref_clear(iterator_temp, py_object_type) code.funcstate.release_temp(iterator_temp) code.funcstate.release_temp(iternext_func) unpacking_done_label = code.new_label('unpacking_done') code.put_goto(unpacking_done_label) code.put_label(unpacking_error_label) code.put_decref_clear(iterator_temp, py_object_type) code.putln("if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();") code.putln("if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);") code.putln(code.error_goto(self.pos)) code.put_label(unpacking_done_label) def generate_starred_assignment_code(self, rhs, code): for i, arg in enumerate(self.args): if arg.is_starred: starred_target = self.unpacked_items[i] fixed_args_left = self.args[:i] fixed_args_right = self.args[i+1:] break iterator_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) code.putln( "%s = PyObject_GetIter(%s); %s" % ( iterator_temp, rhs.py_result(), code.error_goto_if_null(iterator_temp, self.pos))) code.put_gotref(iterator_temp) rhs.generate_disposal_code(code) for item in self.unpacked_items: item.allocate(code) code.globalstate.use_utility_code(unpacking_utility_code) for i in range(len(fixed_args_left)): item = self.unpacked_items[i] unpack_code = "__Pyx_UnpackItem(%s, %d)" % ( iterator_temp, i) code.putln( "%s = %s; %s" % ( item.result(), typecast(item.ctype(), py_object_type, unpack_code), code.error_goto_if_null(item.result(), self.pos))) code.put_gotref(item.py_result()) value_node = self.coerced_unpacked_items[i] value_node.generate_evaluation_code(code) target_list = starred_target.result() code.putln("%s = PySequence_List(%s); %s" % ( target_list, iterator_temp, code.error_goto_if_null(target_list, self.pos))) code.put_gotref(target_list) if fixed_args_right: code.globalstate.use_utility_code(raise_need_more_values_to_unpack) unpacked_right_args = self.unpacked_items[-len(fixed_args_right):] code.putln("if (unlikely(PyList_GET_SIZE(%s) < %d)) {" % ( (target_list, len(unpacked_right_args)))) code.put("__Pyx_RaiseNeedMoreValuesError(%d+PyList_GET_SIZE(%s)); %s" % ( len(fixed_args_left), target_list, code.error_goto(self.pos))) code.putln('}') for i, (arg, coerced_arg) in enumerate(zip(unpacked_right_args[::-1], self.coerced_unpacked_items[::-1])): code.putln( "%s = PyList_GET_ITEM(%s, PyList_GET_SIZE(%s)-1); " % ( arg.py_result(), target_list, target_list)) # resize the list the hard way code.putln("((PyVarObject*)%s)->ob_size--;" % target_list) code.put_gotref(arg.py_result()) coerced_arg.generate_evaluation_code(code) code.put_decref_clear(iterator_temp, py_object_type) code.funcstate.release_temp(iterator_temp) for i in range(len(self.args)): self.args[i].generate_assignment_code( self.coerced_unpacked_items[i], code) def annotate(self, code): for arg in self.args: arg.annotate(code) if self.unpacked_items: for arg in self.unpacked_items: arg.annotate(code) for arg in self.coerced_unpacked_items: arg.annotate(code) class TupleNode(SequenceNode): # Tuple constructor. type = tuple_type gil_message = "Constructing Python tuple" def analyse_types(self, env, skip_children=False): if len(self.args) == 0: self.is_temp = 0 self.is_literal = 1 else: SequenceNode.analyse_types(self, env, skip_children) for child in self.args: if not child.is_literal: break else: self.is_temp = 0 self.is_literal = 1 def is_simple(self): # either temp or constant => always simple return True def nonlocally_immutable(self): # either temp or constant => always safe return True def calculate_result_code(self): if len(self.args) > 0: return self.result_code else: return Naming.empty_tuple def calculate_constant_result(self): self.constant_result = tuple([ arg.constant_result for arg in self.args]) def compile_time_value(self, denv): values = self.compile_time_value_list(denv) try: return tuple(values) except Exception, e: self.compile_time_value_error(e) def generate_operation_code(self, code): if len(self.args) == 0: # result_code is Naming.empty_tuple return if self.is_literal: # non-empty cached tuple => result is global constant, # creation code goes into separate code writer self.result_code = code.get_py_const(py_object_type, 'tuple_', cleanup_level=2) code = code.get_cached_constants_writer() code.mark_pos(self.pos) self.generate_sequence_packing_code(code) if self.is_literal: code.put_giveref(self.py_result()) class ListNode(SequenceNode): # List constructor. # obj_conversion_errors [PyrexError] used internally # orignial_args [ExprNode] used internally obj_conversion_errors = [] type = list_type gil_message = "Constructing Python list" def type_dependencies(self, env): return () def infer_type(self, env): # TOOD: Infer non-object list arrays. return list_type def analyse_expressions(self, env): SequenceNode.analyse_expressions(self, env) self.coerce_to_pyobject(env) def analyse_types(self, env): hold_errors() self.original_args = list(self.args) SequenceNode.analyse_types(self, env) self.obj_conversion_errors = held_errors() release_errors(ignore=True) def coerce_to(self, dst_type, env): if dst_type.is_pyobject: for err in self.obj_conversion_errors: report_error(err) self.obj_conversion_errors = [] if not self.type.subtype_of(dst_type): error(self.pos, "Cannot coerce list to type '%s'" % dst_type) elif self.mult_factor: error(self.pos, "Cannot coerce multiplied list to '%s'" % dst_type) elif dst_type.is_ptr and dst_type.base_type is not PyrexTypes.c_void_type: base_type = dst_type.base_type self.type = PyrexTypes.CArrayType(base_type, len(self.args)) for i in range(len(self.original_args)): arg = self.args[i] if isinstance(arg, CoerceToPyTypeNode): arg = arg.arg self.args[i] = arg.coerce_to(base_type, env) elif dst_type.is_struct: if len(self.args) > len(dst_type.scope.var_entries): error(self.pos, "Too may members for '%s'" % dst_type) else: if len(self.args) < len(dst_type.scope.var_entries): warning(self.pos, "Too few members for '%s'" % dst_type, 1) for i, (arg, member) in enumerate(zip(self.original_args, dst_type.scope.var_entries)): if isinstance(arg, CoerceToPyTypeNode): arg = arg.arg self.args[i] = arg.coerce_to(member.type, env) self.type = dst_type else: self.type = error_type error(self.pos, "Cannot coerce list to type '%s'" % dst_type) return self def release_temp(self, env): if self.type.is_array: # To be valid C++, we must allocate the memory on the stack # manually and be sure not to reuse it for something else. pass else: SequenceNode.release_temp(self, env) def calculate_constant_result(self): if self.mult_factor: raise ValueError() # may exceed the compile time memory self.constant_result = [ arg.constant_result for arg in self.args] def compile_time_value(self, denv): l = self.compile_time_value_list(denv) if self.mult_factor: l *= self.mult_factor.compile_time_value(denv) return l def generate_operation_code(self, code): if self.type.is_pyobject: for err in self.obj_conversion_errors: report_error(err) self.generate_sequence_packing_code(code) elif self.type.is_array: for i, arg in enumerate(self.args): code.putln("%s[%s] = %s;" % ( self.result(), i, arg.result())) elif self.type.is_struct: for arg, member in zip(self.args, self.type.scope.var_entries): code.putln("%s.%s = %s;" % ( self.result(), member.cname, arg.result())) else: raise InternalError("List type never specified") class ScopedExprNode(ExprNode): # Abstract base class for ExprNodes that have their own local # scope, such as generator expressions. # # expr_scope Scope the inner scope of the expression subexprs = [] expr_scope = None # does this node really have a local scope, e.g. does it leak loop # variables or not? non-leaking Py3 behaviour is default, except # for list comprehensions where the behaviour differs in Py2 and # Py3 (set in Parsing.py based on parser context) has_local_scope = True def init_scope(self, outer_scope, expr_scope=None): if expr_scope is not None: self.expr_scope = expr_scope elif self.has_local_scope: self.expr_scope = Symtab.GeneratorExpressionScope(outer_scope) else: self.expr_scope = None def analyse_declarations(self, env): self.init_scope(env) def analyse_scoped_declarations(self, env): # this is called with the expr_scope as env pass def analyse_types(self, env): # no recursion here, the children will be analysed separately below pass def analyse_scoped_expressions(self, env): # this is called with the expr_scope as env pass def generate_evaluation_code(self, code): # set up local variables and free their references on exit generate_inner_evaluation_code = super(ScopedExprNode, self).generate_evaluation_code if not self.has_local_scope or not self.expr_scope.var_entries: # no local variables => delegate, done generate_inner_evaluation_code(code) return code.putln('{ /* enter inner scope */') py_entries = [] for entry in self.expr_scope.var_entries: if not entry.in_closure: code.put_var_declaration(entry) if entry.type.is_pyobject and entry.used: py_entries.append(entry) if not py_entries: # no local Python references => no cleanup required generate_inner_evaluation_code(code) code.putln('} /* exit inner scope */') return # must free all local Python references at each exit point old_loop_labels = tuple(code.new_loop_labels()) old_error_label = code.new_error_label() generate_inner_evaluation_code(code) # normal (non-error) exit for entry in py_entries: code.put_var_decref(entry) # error/loop body exit points exit_scope = code.new_label('exit_scope') code.put_goto(exit_scope) for label, old_label in ([(code.error_label, old_error_label)] + list(zip(code.get_loop_labels(), old_loop_labels))): if code.label_used(label): code.put_label(label) for entry in py_entries: code.put_var_decref(entry) code.put_goto(old_label) code.put_label(exit_scope) code.putln('} /* exit inner scope */') code.set_loop_labels(old_loop_labels) code.error_label = old_error_label class ComprehensionNode(ScopedExprNode): subexprs = ["target"] child_attrs = ["loop"] def infer_type(self, env): return self.target.infer_type(env) def analyse_declarations(self, env): self.append.target = self # this is used in the PyList_Append of the inner loop self.init_scope(env) def analyse_scoped_declarations(self, env): self.loop.analyse_declarations(env) def analyse_types(self, env): self.target.analyse_expressions(env) self.type = self.target.type if not self.has_local_scope: self.loop.analyse_expressions(env) def analyse_scoped_expressions(self, env): if self.has_local_scope: self.loop.analyse_expressions(env) def may_be_none(self): return False def calculate_result_code(self): return self.target.result() def generate_result_code(self, code): self.generate_operation_code(code) def generate_operation_code(self, code): self.loop.generate_execution_code(code) def annotate(self, code): self.loop.annotate(code) class ComprehensionAppendNode(Node): # Need to be careful to avoid infinite recursion: # target must not be in child_attrs/subexprs child_attrs = ['expr'] type = PyrexTypes.c_int_type def analyse_expressions(self, env): self.expr.analyse_expressions(env) if not self.expr.type.is_pyobject: self.expr = self.expr.coerce_to_pyobject(env) def generate_execution_code(self, code): if self.target.type is list_type: function = "PyList_Append" elif self.target.type is set_type: function = "PySet_Add" else: raise InternalError( "Invalid type for comprehension node: %s" % self.target.type) self.expr.generate_evaluation_code(code) code.putln(code.error_goto_if("%s(%s, (PyObject*)%s)" % ( function, self.target.result(), self.expr.result() ), self.pos)) self.expr.generate_disposal_code(code) self.expr.free_temps(code) def generate_function_definitions(self, env, code): self.expr.generate_function_definitions(env, code) def annotate(self, code): self.expr.annotate(code) class DictComprehensionAppendNode(ComprehensionAppendNode): child_attrs = ['key_expr', 'value_expr'] def analyse_expressions(self, env): self.key_expr.analyse_expressions(env) if not self.key_expr.type.is_pyobject: self.key_expr = self.key_expr.coerce_to_pyobject(env) self.value_expr.analyse_expressions(env) if not self.value_expr.type.is_pyobject: self.value_expr = self.value_expr.coerce_to_pyobject(env) def generate_execution_code(self, code): self.key_expr.generate_evaluation_code(code) self.value_expr.generate_evaluation_code(code) code.putln(code.error_goto_if("PyDict_SetItem(%s, (PyObject*)%s, (PyObject*)%s)" % ( self.target.result(), self.key_expr.result(), self.value_expr.result() ), self.pos)) self.key_expr.generate_disposal_code(code) self.key_expr.free_temps(code) self.value_expr.generate_disposal_code(code) self.value_expr.free_temps(code) def generate_function_definitions(self, env, code): self.key_expr.generate_function_definitions(env, code) self.value_expr.generate_function_definitions(env, code) def annotate(self, code): self.key_expr.annotate(code) self.value_expr.annotate(code) class InlinedGeneratorExpressionNode(ScopedExprNode): # An inlined generator expression for which the result is # calculated inside of the loop. This will only be created by # transforms when replacing builtin calls on generator # expressions. # # loop ForStatNode the for-loop, not containing any YieldExprNodes # result_node ResultRefNode the reference to the result value temp # orig_func String the name of the builtin function this node replaces child_attrs = ["loop"] loop_analysed = False type = py_object_type def analyse_scoped_declarations(self, env): self.loop.analyse_declarations(env) def may_be_none(self): return False def annotate(self, code): self.loop.annotate(code) def infer_type(self, env): return self.result_node.infer_type(env) def analyse_types(self, env): if not self.has_local_scope: self.loop_analysed = True self.loop.analyse_expressions(env) self.type = self.result_node.type self.is_temp = True def analyse_scoped_expressions(self, env): self.loop_analysed = True if self.has_local_scope: self.loop.analyse_expressions(env) def coerce_to(self, dst_type, env): if self.orig_func == 'sum' and dst_type.is_numeric and not self.loop_analysed: # We can optimise by dropping the aggregation variable and # the add operations into C. This can only be done safely # before analysing the loop body, after that, the result # reference type will have infected expressions and # assignments. self.result_node.type = self.type = dst_type return self return super(InlinedGeneratorExpressionNode, self).coerce_to(dst_type, env) def generate_result_code(self, code): self.result_node.result_code = self.result() self.loop.generate_execution_code(code) class SetNode(ExprNode): # Set constructor. type = set_type subexprs = ['args'] gil_message = "Constructing Python set" def analyse_types(self, env): for i in range(len(self.args)): arg = self.args[i] arg.analyse_types(env) self.args[i] = arg.coerce_to_pyobject(env) self.type = set_type self.is_temp = 1 def may_be_none(self): return False def calculate_constant_result(self): self.constant_result = set([ arg.constant_result for arg in self.args]) def compile_time_value(self, denv): values = [arg.compile_time_value(denv) for arg in self.args] try: return set(values) except Exception, e: self.compile_time_value_error(e) def generate_evaluation_code(self, code): code.globalstate.use_utility_code(Builtin.py_set_utility_code) self.allocate_temp_result(code) code.putln( "%s = PySet_New(0); %s" % ( self.result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) for arg in self.args: arg.generate_evaluation_code(code) code.putln( code.error_goto_if_neg( "PySet_Add(%s, %s)" % (self.result(), arg.py_result()), self.pos)) arg.generate_disposal_code(code) arg.free_temps(code) class DictNode(ExprNode): # Dictionary constructor. # # key_value_pairs [DictItemNode] # exclude_null_values [boolean] Do not add NULL values to dict # # obj_conversion_errors [PyrexError] used internally subexprs = ['key_value_pairs'] is_temp = 1 exclude_null_values = False type = dict_type obj_conversion_errors = [] def calculate_constant_result(self): self.constant_result = dict([ item.constant_result for item in self.key_value_pairs]) def compile_time_value(self, denv): pairs = [(item.key.compile_time_value(denv), item.value.compile_time_value(denv)) for item in self.key_value_pairs] try: return dict(pairs) except Exception, e: self.compile_time_value_error(e) def type_dependencies(self, env): return () def infer_type(self, env): # TOOD: Infer struct constructors. return dict_type def analyse_types(self, env): hold_errors() for item in self.key_value_pairs: item.analyse_types(env) self.obj_conversion_errors = held_errors() release_errors(ignore=True) def may_be_none(self): return False def coerce_to(self, dst_type, env): if dst_type.is_pyobject: self.release_errors() if not self.type.subtype_of(dst_type): error(self.pos, "Cannot interpret dict as type '%s'" % dst_type) elif dst_type.is_struct_or_union: self.type = dst_type if not dst_type.is_struct and len(self.key_value_pairs) != 1: error(self.pos, "Exactly one field must be specified to convert to union '%s'" % dst_type) elif dst_type.is_struct and len(self.key_value_pairs) < len(dst_type.scope.var_entries): warning(self.pos, "Not all members given for struct '%s'" % dst_type, 1) for item in self.key_value_pairs: if isinstance(item.key, CoerceToPyTypeNode): item.key = item.key.arg if not item.key.is_string_literal: error(item.key.pos, "Invalid struct field identifier") item.key = StringNode(item.key.pos, value="<error>") else: key = str(item.key.value) # converts string literals to unicode in Py3 member = dst_type.scope.lookup_here(key) if not member: error(item.key.pos, "struct '%s' has no field '%s'" % (dst_type, key)) else: value = item.value if isinstance(value, CoerceToPyTypeNode): value = value.arg item.value = value.coerce_to(member.type, env) else: self.type = error_type error(self.pos, "Cannot interpret dict as type '%s'" % dst_type) return self def release_errors(self): for err in self.obj_conversion_errors: report_error(err) self.obj_conversion_errors = [] gil_message = "Constructing Python dict" def generate_evaluation_code(self, code): # Custom method used here because key-value # pairs are evaluated and used one at a time. code.mark_pos(self.pos) self.allocate_temp_result(code) if self.type.is_pyobject: self.release_errors() code.putln( "%s = PyDict_New(); %s" % ( self.result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) for item in self.key_value_pairs: item.generate_evaluation_code(code) if self.type.is_pyobject: if self.exclude_null_values: code.putln('if (%s) {' % item.value.py_result()) code.put_error_if_neg(self.pos, "PyDict_SetItem(%s, %s, %s)" % ( self.result(), item.key.py_result(), item.value.py_result())) if self.exclude_null_values: code.putln('}') else: code.putln("%s.%s = %s;" % ( self.result(), item.key.value, item.value.result())) item.generate_disposal_code(code) item.free_temps(code) def annotate(self, code): for item in self.key_value_pairs: item.annotate(code) class DictItemNode(ExprNode): # Represents a single item in a DictNode # # key ExprNode # value ExprNode subexprs = ['key', 'value'] nogil_check = None # Parent DictNode takes care of it def calculate_constant_result(self): self.constant_result = ( self.key.constant_result, self.value.constant_result) def analyse_types(self, env): self.key.analyse_types(env) self.value.analyse_types(env) self.key = self.key.coerce_to_pyobject(env) self.value = self.value.coerce_to_pyobject(env) def generate_evaluation_code(self, code): self.key.generate_evaluation_code(code) self.value.generate_evaluation_code(code) def generate_disposal_code(self, code): self.key.generate_disposal_code(code) self.value.generate_disposal_code(code) def free_temps(self, code): self.key.free_temps(code) self.value.free_temps(code) def __iter__(self): return iter([self.key, self.value]) class ModuleNameMixin(object): def set_mod_name(self, env): self.module_name = env.global_scope().qualified_name def get_py_mod_name(self, code): return code.get_py_string_const( self.module_name, identifier=True) class ClassNode(ExprNode, ModuleNameMixin): # Helper class used in the implementation of Python # class definitions. Constructs a class object given # a name, tuple of bases and class dictionary. # # name EncodedString Name of the class # bases ExprNode Base class tuple # dict ExprNode Class dict (not owned by this node) # doc ExprNode or None Doc string # module_name EncodedString Name of defining module subexprs = ['bases', 'doc'] def analyse_types(self, env): self.bases.analyse_types(env) if self.doc: self.doc.analyse_types(env) self.doc = self.doc.coerce_to_pyobject(env) self.type = py_object_type self.is_temp = 1 env.use_utility_code(create_class_utility_code); #TODO(craig,haoyu) This should be moved to a better place self.set_mod_name(env) def may_be_none(self): return True gil_message = "Constructing Python class" def generate_result_code(self, code): cname = code.intern_identifier(self.name) if self.doc: code.put_error_if_neg(self.pos, 'PyDict_SetItemString(%s, "__doc__", %s)' % ( self.dict.py_result(), self.doc.py_result())) py_mod_name = self.get_py_mod_name(code) code.putln( '%s = __Pyx_CreateClass(%s, %s, %s, %s); %s' % ( self.result(), self.bases.py_result(), self.dict.py_result(), cname, py_mod_name, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class Py3ClassNode(ExprNode): # Helper class used in the implementation of Python3+ # class definitions. Constructs a class object given # a name, tuple of bases and class dictionary. # # name EncodedString Name of the class # dict ExprNode Class dict (not owned by this node) # module_name EncodedString Name of defining module subexprs = [] def analyse_types(self, env): self.type = py_object_type self.is_temp = 1 def may_be_none(self): return True gil_message = "Constructing Python class" def generate_result_code(self, code): code.globalstate.use_utility_code(create_py3class_utility_code) cname = code.intern_identifier(self.name) code.putln( '%s = __Pyx_Py3ClassCreate(%s, %s, %s, %s, %s); %s' % ( self.result(), self.metaclass.result(), cname, self.bases.py_result(), self.dict.py_result(), self.mkw.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class KeywordArgsNode(ExprNode): # Helper class for keyword arguments. # # starstar_arg DictNode # keyword_args [DictItemNode] subexprs = ['starstar_arg', 'keyword_args'] is_temp = 1 type = dict_type def calculate_constant_result(self): result = dict(self.starstar_arg.constant_result) for item in self.keyword_args: key, value = item.constant_result if key in result: raise ValueError("duplicate keyword argument found: %s" % key) result[key] = value self.constant_result = result def compile_time_value(self, denv): result = self.starstar_arg.compile_time_value(denv) pairs = [ (item.key.compile_time_value(denv), item.value.compile_time_value(denv)) for item in self.keyword_args ] try: result = dict(result) for key, value in pairs: if key in result: raise ValueError("duplicate keyword argument found: %s" % key) result[key] = value except Exception, e: self.compile_time_value_error(e) return result def type_dependencies(self, env): return () def infer_type(self, env): return dict_type def analyse_types(self, env): self.starstar_arg.analyse_types(env) self.starstar_arg = self.starstar_arg.coerce_to_pyobject(env).as_none_safe_node( # FIXME: CPython's error message starts with the runtime function name 'argument after ** must be a mapping, not NoneType') for item in self.keyword_args: item.analyse_types(env) def may_be_none(self): return False gil_message = "Constructing Python dict" def generate_evaluation_code(self, code): code.mark_pos(self.pos) self.allocate_temp_result(code) self.starstar_arg.generate_evaluation_code(code) if self.starstar_arg.type is not Builtin.dict_type: # CPython supports calling functions with non-dicts, so do we code.putln('if (likely(PyDict_Check(%s))) {' % self.starstar_arg.py_result()) if self.keyword_args: code.putln( "%s = PyDict_Copy(%s); %s" % ( self.result(), self.starstar_arg.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) else: code.putln("%s = %s;" % ( self.result(), self.starstar_arg.py_result())) code.put_incref(self.result(), py_object_type) if self.starstar_arg.type is not Builtin.dict_type: code.putln('} else {') code.putln( "%s = PyObject_CallFunctionObjArgs(" "(PyObject*)&PyDict_Type, %s, NULL); %s" % ( self.result(), self.starstar_arg.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) code.putln('}') self.starstar_arg.generate_disposal_code(code) self.starstar_arg.free_temps(code) if not self.keyword_args: return code.globalstate.use_utility_code(Nodes.raise_double_keywords_utility_code) for item in self.keyword_args: item.generate_evaluation_code(code) code.putln("if (unlikely(PyDict_GetItem(%s, %s))) {" % ( self.result(), item.key.py_result())) # FIXME: find out function name at runtime! code.putln('__Pyx_RaiseDoubleKeywordsError("function", %s); %s' % ( item.key.py_result(), code.error_goto(self.pos))) code.putln("}") code.put_error_if_neg(self.pos, "PyDict_SetItem(%s, %s, %s)" % ( self.result(), item.key.py_result(), item.value.py_result())) item.generate_disposal_code(code) item.free_temps(code) def annotate(self, code): self.starstar_arg.annotate(code) for item in self.keyword_args: item.annotate(code) class PyClassMetaclassNode(ExprNode): # Helper class holds Python3 metaclass object # # bases ExprNode Base class tuple (not owned by this node) # mkw ExprNode Class keyword arguments (not owned by this node) subexprs = [] def analyse_types(self, env): self.type = py_object_type self.is_temp = True def may_be_none(self): return True def generate_result_code(self, code): code.putln( "%s = __Pyx_Py3MetaclassGet(%s, %s); %s" % ( self.result(), self.bases.result(), self.mkw.result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class PyClassNamespaceNode(ExprNode, ModuleNameMixin): # Helper class holds Python3 namespace object # # All this are not owned by this node # metaclass ExprNode Metaclass object # bases ExprNode Base class tuple # mkw ExprNode Class keyword arguments # doc ExprNode or None Doc string (owned) subexprs = ['doc'] def analyse_types(self, env): self.bases.analyse_types(env) if self.doc: self.doc.analyse_types(env) self.doc = self.doc.coerce_to_pyobject(env) self.type = py_object_type self.is_temp = 1 #TODO(craig,haoyu) This should be moved to a better place self.set_mod_name(env) def may_be_none(self): return True def generate_result_code(self, code): cname = code.intern_identifier(self.name) py_mod_name = self.get_py_mod_name(code) if self.doc: doc_code = self.doc.result() else: doc_code = '(PyObject *) NULL' code.putln( "%s = __Pyx_Py3MetaclassPrepare(%s, %s, %s, %s, %s, %s); %s" % ( self.result(), self.metaclass.result(), self.bases.result(), cname, self.mkw.result(), py_mod_name, doc_code, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class BoundMethodNode(ExprNode): # Helper class used in the implementation of Python # class definitions. Constructs an bound method # object from a class and a function. # # function ExprNode Function object # self_object ExprNode self object subexprs = ['function'] def analyse_types(self, env): self.function.analyse_types(env) self.type = py_object_type self.is_temp = 1 gil_message = "Constructing an bound method" def generate_result_code(self, code): code.putln( "%s = PyMethod_New(%s, %s, (PyObject*)%s->ob_type); %s" % ( self.result(), self.function.py_result(), self.self_object.py_result(), self.self_object.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class UnboundMethodNode(ExprNode): # Helper class used in the implementation of Python # class definitions. Constructs an unbound method # object from a class and a function. # # function ExprNode Function object type = py_object_type is_temp = 1 subexprs = ['function'] def analyse_types(self, env): self.function.analyse_types(env) def may_be_none(self): return False gil_message = "Constructing an unbound method" def generate_result_code(self, code): class_cname = code.pyclass_stack[-1].classobj.result() code.putln( "%s = PyMethod_New(%s, 0, %s); %s" % ( self.result(), self.function.py_result(), class_cname, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class PyCFunctionNode(ExprNode, ModuleNameMixin): # Helper class used in the implementation of Python # class definitions. Constructs a PyCFunction object # from a PyMethodDef struct. # # pymethdef_cname string PyMethodDef structure # self_object ExprNode or None # binding bool # module_name EncodedString Name of defining module # code_object CodeObjectNode the PyCodeObject creator node subexprs = ['code_object'] self_object = None code_object = None binding = False type = py_object_type is_temp = 1 def analyse_types(self, env): if self.binding: env.use_utility_code(binding_cfunc_utility_code) #TODO(craig,haoyu) This should be moved to a better place self.set_mod_name(env) def may_be_none(self): return False gil_message = "Constructing Python function" def self_result_code(self): if self.self_object is None: self_result = "NULL" else: self_result = self.self_object.py_result() return self_result def generate_result_code(self, code): if self.binding: constructor = "__Pyx_CyFunction_NewEx" if self.code_object: code_object_result = ', ' + self.code_object.py_result() else: code_object_result = ', NULL' else: constructor = "PyCFunction_NewEx" code_object_result = '' py_mod_name = self.get_py_mod_name(code) code.putln( '%s = %s(&%s, %s, %s%s); %s' % ( self.result(), constructor, self.pymethdef_cname, self.self_result_code(), py_mod_name, code_object_result, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class InnerFunctionNode(PyCFunctionNode): # Special PyCFunctionNode that depends on a closure class # binding = True needs_self_code = True def self_result_code(self): if self.needs_self_code: return "((PyObject*)%s)" % (Naming.cur_scope_cname) return "NULL" class CodeObjectNode(ExprNode): # Create a PyCodeObject for a CyFunction instance. # # def_node DefNode the Python function node # varnames TupleNode a tuple with all local variable names subexprs = ['varnames'] is_temp = False def __init__(self, def_node): ExprNode.__init__(self, def_node.pos, def_node=def_node) args = list(def_node.args) if def_node.star_arg: args.append(def_node.star_arg) if def_node.starstar_arg: args.append(def_node.starstar_arg) local_vars = [ arg for arg in def_node.local_scope.var_entries if arg.name ] self.varnames = TupleNode( def_node.pos, args = [ IdentifierStringNode(arg.pos, value=arg.name) for arg in args + local_vars ], is_temp = 0, is_literal = 1) def calculate_result_code(self): return self.result_code def generate_result_code(self, code): self.result_code = code.get_py_const(py_object_type, 'codeobj_', cleanup_level=2) code = code.get_cached_constants_writer() code.mark_pos(self.pos) func = self.def_node func_name = code.get_py_string_const( func.name, identifier=True, is_str=False, unicode_value=func.name) # FIXME: better way to get the module file path at module init time? Encoding to use? file_path = StringEncoding.BytesLiteral(func.pos[0].get_filenametable_entry().encode('utf8')) file_path_const = code.get_py_string_const(file_path, identifier=False, is_str=True) code.putln("%s = (PyObject*)__Pyx_PyCode_New(%d, %d, %d, 0, 0, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s); %s" % ( self.result_code, len(func.args), # argcount func.num_kwonly_args, # kwonlyargcount (Py3 only) len(self.varnames.args), # nlocals Naming.empty_bytes, # code Naming.empty_tuple, # consts Naming.empty_tuple, # names (FIXME) self.varnames.result(), # varnames Naming.empty_tuple, # freevars (FIXME) Naming.empty_tuple, # cellvars (FIXME) file_path_const, # filename func_name, # name self.pos[1], # firstlineno Naming.empty_bytes, # lnotab code.error_goto_if_null(self.result_code, self.pos), )) class LambdaNode(InnerFunctionNode): # Lambda expression node (only used as a function reference) # # args [CArgDeclNode] formal arguments # star_arg PyArgDeclNode or None * argument # starstar_arg PyArgDeclNode or None ** argument # lambda_name string a module-globally unique lambda name # result_expr ExprNode # def_node DefNode the underlying function 'def' node child_attrs = ['def_node'] def_node = None name = StringEncoding.EncodedString('<lambda>') def analyse_declarations(self, env): self.def_node.no_assignment_synthesis = True self.def_node.pymethdef_required = True self.def_node.analyse_declarations(env) self.pymethdef_cname = self.def_node.entry.pymethdef_cname env.add_lambda_def(self.def_node) def analyse_types(self, env): self.def_node.analyse_expressions(env) super(LambdaNode, self).analyse_types(env) def generate_result_code(self, code): self.def_node.generate_execution_code(code) super(LambdaNode, self).generate_result_code(code) class GeneratorExpressionNode(LambdaNode): # A generator expression, e.g. (i for i in range(10)) # # Result is a generator. # # loop ForStatNode the for-loop, containing a YieldExprNode # def_node DefNode the underlying generator 'def' node name = StringEncoding.EncodedString('genexpr') binding = False def analyse_declarations(self, env): super(GeneratorExpressionNode, self).analyse_declarations(env) # No pymethdef required self.def_node.pymethdef_required = False # Force genexpr signature self.def_node.entry.signature = TypeSlots.pyfunction_noargs def generate_result_code(self, code): code.putln( '%s = %s(%s, NULL); %s' % ( self.result(), self.def_node.entry.func_cname, self.self_result_code(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class YieldExprNode(ExprNode): # Yield expression node # # arg ExprNode the value to return from the generator # label_name string name of the C label used for this yield # label_num integer yield label number subexprs = ['arg'] type = py_object_type label_num = 0 def analyse_types(self, env): if not self.label_num: error(self.pos, "'yield' not supported here") self.is_temp = 1 if self.arg is not None: self.arg.analyse_types(env) if not self.arg.type.is_pyobject: self.arg = self.arg.coerce_to_pyobject(env) def generate_evaluation_code(self, code): self.label_name = code.new_label('resume_from_yield') code.use_label(self.label_name) if self.arg: self.arg.generate_evaluation_code(code) self.arg.make_owned_reference(code) code.putln( "%s = %s;" % ( Naming.retval_cname, self.arg.result_as(py_object_type))) self.arg.generate_post_assignment_code(code) #self.arg.generate_disposal_code(code) self.arg.free_temps(code) else: code.put_init_to_py_none(Naming.retval_cname, py_object_type) saved = [] code.funcstate.closure_temps.reset() for cname, type, manage_ref in code.funcstate.temps_in_use(): save_cname = code.funcstate.closure_temps.allocate_temp(type) saved.append((cname, save_cname, type)) if type.is_pyobject: code.put_xgiveref(cname) code.putln('%s->%s = %s;' % (Naming.cur_scope_cname, save_cname, cname)) code.put_xgiveref(Naming.retval_cname) code.put_finish_refcount_context() code.putln("/* return from generator, yielding value */") code.putln("%s->%s.resume_label = %d;" % (Naming.cur_scope_cname, Naming.obj_base_cname, self.label_num)) code.putln("return %s;" % Naming.retval_cname); code.put_label(self.label_name) for cname, save_cname, type in saved: code.putln('%s = %s->%s;' % (cname, Naming.cur_scope_cname, save_cname)) if type.is_pyobject: code.putln('%s->%s = 0;' % (Naming.cur_scope_cname, save_cname)) if type.is_pyobject: code.put_xgotref(cname) if self.result_is_used: self.allocate_temp_result(code) code.putln('%s = %s; %s' % (self.result(), Naming.sent_value_cname, code.error_goto_if_null(self.result(), self.pos))) code.put_incref(self.result(), py_object_type) else: code.putln(code.error_goto_if_null(Naming.sent_value_cname, self.pos)) class GlobalsExprNode(AtomicExprNode): type = dict_type is_temp = 1 def analyse_types(self, env): env.use_utility_code(Builtin.globals_utility_code) gil_message = "Constructing globals dict" def generate_result_code(self, code): code.putln('%s = __Pyx_Globals(); %s' % ( self.result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.result()) class FuncLocalsExprNode(DictNode): def __init__(self, pos, env): local_vars = [var.name for var in env.entries.values() if var.name] items = [DictItemNode(pos, key=IdentifierStringNode(pos, value=var), value=NameNode(pos, name=var, allow_null=True)) for var in local_vars] DictNode.__init__(self, pos, key_value_pairs=items, exclude_null_values=True) class PyClassLocalsExprNode(AtomicExprNode): def __init__(self, pos, pyclass_dict): AtomicExprNode.__init__(self, pos) self.pyclass_dict = pyclass_dict def analyse_types(self, env): self.type = self.pyclass_dict.type self.is_tmep = 0 def result(self): return self.pyclass_dict.result() def generate_result_code(self, code): pass def LocalsExprNode(pos, scope_node, env): if env.is_module_scope: return GlobalsExprNode(pos) if env.is_py_class_scope: return PyClassLocalsExprNode(pos, scope_node.dict) return FuncLocalsExprNode(pos, env) #------------------------------------------------------------------- # # Unary operator nodes # #------------------------------------------------------------------- compile_time_unary_operators = { 'not': operator.not_, '~': operator.inv, '-': operator.neg, '+': operator.pos, } class UnopNode(ExprNode): # operator string # operand ExprNode # # Processing during analyse_expressions phase: # # analyse_c_operation # Called when the operand is not a pyobject. # - Check operand type and coerce if needed. # - Determine result type and result code fragment. # - Allocate temporary for result if needed. subexprs = ['operand'] infix = True def calculate_constant_result(self): func = compile_time_unary_operators[self.operator] self.constant_result = func(self.operand.constant_result) def compile_time_value(self, denv): func = compile_time_unary_operators.get(self.operator) if not func: error(self.pos, "Unary '%s' not supported in compile-time expression" % self.operator) operand = self.operand.compile_time_value(denv) try: return func(operand) except Exception, e: self.compile_time_value_error(e) def infer_type(self, env): operand_type = self.operand.infer_type(env) if operand_type.is_pyobject: return py_object_type else: return operand_type def analyse_types(self, env): self.operand.analyse_types(env) if self.is_py_operation(): self.coerce_operand_to_pyobject(env) self.type = py_object_type self.is_temp = 1 elif self.is_cpp_operation(): self.analyse_cpp_operation(env) else: self.analyse_c_operation(env) def check_const(self): return self.operand.check_const() def is_py_operation(self): return self.operand.type.is_pyobject def nogil_check(self, env): if self.is_py_operation(): self.gil_error() def is_cpp_operation(self): type = self.operand.type return type.is_cpp_class def coerce_operand_to_pyobject(self, env): self.operand = self.operand.coerce_to_pyobject(env) def generate_result_code(self, code): if self.operand.type.is_pyobject: self.generate_py_operation_code(code) def generate_py_operation_code(self, code): function = self.py_operation_function() code.putln( "%s = %s(%s); %s" % ( self.result(), function, self.operand.py_result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) def type_error(self): if not self.operand.type.is_error: error(self.pos, "Invalid operand type for '%s' (%s)" % (self.operator, self.operand.type)) self.type = PyrexTypes.error_type def analyse_cpp_operation(self, env): type = self.operand.type if type.is_ptr: type = type.base_type function = type.scope.lookup("operator%s" % self.operator) if not function: error(self.pos, "'%s' operator not defined for %s" % (self.operator, type)) self.type_error() return func_type = function.type if func_type.is_ptr: func_type = func_type.base_type self.type = func_type.return_type class NotNode(ExprNode): # 'not' operator # # operand ExprNode type = PyrexTypes.c_bint_type subexprs = ['operand'] def calculate_constant_result(self): self.constant_result = not self.operand.constant_result def compile_time_value(self, denv): operand = self.operand.compile_time_value(denv) try: return not operand except Exception, e: self.compile_time_value_error(e) def infer_type(self, env): return PyrexTypes.c_bint_type def analyse_types(self, env): self.operand.analyse_types(env) self.operand = self.operand.coerce_to_boolean(env) def calculate_result_code(self): return "(!%s)" % self.operand.result() def generate_result_code(self, code): pass class UnaryPlusNode(UnopNode): # unary '+' operator operator = '+' def analyse_c_operation(self, env): self.type = PyrexTypes.widest_numeric_type( self.operand.type, PyrexTypes.c_int_type) def py_operation_function(self): return "PyNumber_Positive" def calculate_result_code(self): if self.is_cpp_operation(): return "(+%s)" % self.operand.result() else: return self.operand.result() class UnaryMinusNode(UnopNode): # unary '-' operator operator = '-' def analyse_c_operation(self, env): if self.operand.type.is_numeric: self.type = PyrexTypes.widest_numeric_type( self.operand.type, PyrexTypes.c_int_type) elif self.operand.type.is_enum: self.type = PyrexTypes.c_int_type else: self.type_error() if self.type.is_complex: self.infix = False def py_operation_function(self): return "PyNumber_Negative" def calculate_result_code(self): if self.infix: return "(-%s)" % self.operand.result() else: return "%s(%s)" % (self.operand.type.unary_op('-'), self.operand.result()) def get_constant_c_result_code(self): value = self.operand.get_constant_c_result_code() if value: return "(-%s)" % (value) class TildeNode(UnopNode): # unary '~' operator def analyse_c_operation(self, env): if self.operand.type.is_int: self.type = PyrexTypes.widest_numeric_type( self.operand.type, PyrexTypes.c_int_type) elif self.operand.type.is_enum: self.type = PyrexTypes.c_int_type else: self.type_error() def py_operation_function(self): return "PyNumber_Invert" def calculate_result_code(self): return "(~%s)" % self.operand.result() class CUnopNode(UnopNode): def is_py_operation(self): return False class DereferenceNode(CUnopNode): # unary * operator operator = '*' def analyse_c_operation(self, env): if self.operand.type.is_ptr: self.type = self.operand.type.base_type else: self.type_error() def calculate_result_code(self): return "(*%s)" % self.operand.result() class DecrementIncrementNode(CUnopNode): # unary ++/-- operator def analyse_c_operation(self, env): if self.operand.type.is_numeric: self.type = PyrexTypes.widest_numeric_type( self.operand.type, PyrexTypes.c_int_type) elif self.operand.type.is_ptr: self.type = self.operand.type else: self.type_error() def calculate_result_code(self): if self.is_prefix: return "(%s%s)" % (self.operator, self.operand.result()) else: return "(%s%s)" % (self.operand.result(), self.operator) def inc_dec_constructor(is_prefix, operator): return lambda pos, **kwds: DecrementIncrementNode(pos, is_prefix=is_prefix, operator=operator, **kwds) class AmpersandNode(ExprNode): # The C address-of operator. # # operand ExprNode subexprs = ['operand'] def infer_type(self, env): return PyrexTypes.c_ptr_type(self.operand.infer_type(env)) def analyse_types(self, env): self.operand.analyse_types(env) argtype = self.operand.type if not (argtype.is_cfunction or self.operand.is_lvalue()): self.error("Taking address of non-lvalue") return if argtype.is_pyobject: self.error("Cannot take address of Python variable") return self.type = PyrexTypes.c_ptr_type(argtype) def check_const(self): return self.operand.check_const_addr() def error(self, mess): error(self.pos, mess) self.type = PyrexTypes.error_type self.result_code = "<error>" def calculate_result_code(self): return "(&%s)" % self.operand.result() def generate_result_code(self, code): pass unop_node_classes = { "+": UnaryPlusNode, "-": UnaryMinusNode, "~": TildeNode, } def unop_node(pos, operator, operand): # Construct unnop node of appropriate class for # given operator. if isinstance(operand, IntNode) and operator == '-': return IntNode(pos = operand.pos, value = str(-Utils.str_to_number(operand.value))) elif isinstance(operand, UnopNode) and operand.operator == operator: warning(pos, "Python has no increment/decrement operator: %s%sx = %s(%sx) = x" % ((operator,)*4), 5) return unop_node_classes[operator](pos, operator = operator, operand = operand) class TypecastNode(ExprNode): # C type cast # # operand ExprNode # base_type CBaseTypeNode # declarator CDeclaratorNode # # If used from a transform, one can if wanted specify the attribute # "type" directly and leave base_type and declarator to None subexprs = ['operand'] base_type = declarator = type = None def type_dependencies(self, env): return () def infer_type(self, env): if self.type is None: base_type = self.base_type.analyse(env) _, self.type = self.declarator.analyse(base_type, env) return self.type def analyse_types(self, env): if self.type is None: base_type = self.base_type.analyse(env) _, self.type = self.declarator.analyse(base_type, env) if self.type.is_cfunction: error(self.pos, "Cannot cast to a function type") self.type = PyrexTypes.error_type self.operand.analyse_types(env) to_py = self.type.is_pyobject from_py = self.operand.type.is_pyobject if from_py and not to_py and self.operand.is_ephemeral() and not self.type.is_numeric: error(self.pos, "Casting temporary Python object to non-numeric non-Python type") if to_py and not from_py: if self.type is bytes_type and self.operand.type.is_int: # FIXME: the type cast node isn't needed in this case # and can be dropped once analyse_types() can return a # different node self.operand = CoerceIntToBytesNode(self.operand, env) elif self.operand.type.can_coerce_to_pyobject(env): self.result_ctype = py_object_type self.operand = self.operand.coerce_to_pyobject(env) else: if self.operand.type.is_ptr: if not (self.operand.type.base_type.is_void or self.operand.type.base_type.is_struct): error(self.pos, "Python objects cannot be cast from pointers of primitive types") else: # Should this be an error? warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.operand.type, self.type)) self.operand = self.operand.coerce_to_simple(env) elif from_py and not to_py: if self.type.create_from_py_utility_code(env): self.operand = self.operand.coerce_to(self.type, env) elif self.type.is_ptr: if not (self.type.base_type.is_void or self.type.base_type.is_struct): error(self.pos, "Python objects cannot be cast to pointers of primitive types") else: warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type)) elif from_py and to_py: if self.typecheck and self.type.is_extension_type: self.operand = PyTypeTestNode(self.operand, self.type, env, notnone=True) elif self.type.is_complex and self.operand.type.is_complex: self.operand = self.operand.coerce_to_simple(env) def is_simple(self): # either temp or a C cast => no side effects other than the operand's return self.operand.is_simple() def nonlocally_immutable(self): return self.operand.nonlocally_immutable() def nogil_check(self, env): if self.type and self.type.is_pyobject and self.is_temp: self.gil_error() def check_const(self): return self.operand.check_const() def calculate_constant_result(self): # we usually do not know the result of a type cast at code # generation time pass def calculate_result_code(self): if self.type.is_complex: operand_result = self.operand.result() if self.operand.type.is_complex: real_part = self.type.real_type.cast_code("__Pyx_CREAL(%s)" % operand_result) imag_part = self.type.real_type.cast_code("__Pyx_CIMAG(%s)" % operand_result) else: real_part = self.type.real_type.cast_code(operand_result) imag_part = "0" return "%s(%s, %s)" % ( self.type.from_parts, real_part, imag_part) else: return self.type.cast_code(self.operand.result()) def get_constant_c_result_code(self): operand_result = self.operand.get_constant_c_result_code() if operand_result: return self.type.cast_code(operand_result) def result_as(self, type): if self.type.is_pyobject and not self.is_temp: # Optimise away some unnecessary casting return self.operand.result_as(type) else: return ExprNode.result_as(self, type) def generate_result_code(self, code): if self.is_temp: code.putln( "%s = (PyObject *)%s;" % ( self.result(), self.operand.result())) code.put_incref(self.result(), self.ctype()) ERR_START = "Start may not be given" ERR_NOT_STOP = "Stop must be provided to indicate shape" ERR_STEPS = ("Strides may only be given to indicate contiguity. " "Consider slicing it after conversion") ERR_NOT_POINTER = "Can only create cython.array from pointer" ERR_BASE_TYPE = "Pointer base type does not match cython.array base type" class CythonArrayNode(ExprNode): """ Used when a pointer of base_type is cast to a memoryviewslice with that base type. i.e. <int[:M:1, :N]> p creates a fortran-contiguous cython.array. We leave the type set to object so coercions to object are more efficient and less work. Acquiring a memoryviewslice from this will be just as efficient. ExprNode.coerce_to() will do the additional typecheck on self.compile_time_type """ subexprs = ['operand', 'shapes'] shapes = None is_temp = True mode = "c" shape_type = PyrexTypes.c_py_ssize_t_type def analyse_types(self, env): import MemoryView self.type = error_type self.shapes = [] for axis_no, axis in enumerate(self.base_type_node.axes): if not axis.start.is_none: return error(axis.start.pos, ERR_START) if axis.stop.is_none: return error(axis.pos, ERR_NOT_STOP) axis.stop.analyse_types(env) shape = axis.stop.coerce_to(self.shape_type, env) if not shape.is_literal: shape.coerce_to_temp(env) self.shapes.append(shape) if not axis.stop.type.is_int: return error(axis.stop.pos, "Expected an integer type") first_or_last = axis_no in (0, len(self.base_type_node.axes) - 1) if not axis.step.is_none and first_or_last: axis.step.analyse_types(env) if (not axis.step.type.is_int and axis.step.is_literal and not axis.step.type.is_error): return error(axis.step.pos, "Expected an integer literal") if axis.step.compile_time_value(env) != 1: return error(axis.step.pos, ERR_STEPS) if axis_no == 0: self.mode = "fortran" elif axis.step and not first_or_last: return error(axis.step.pos, ERR_STEPS) self.operand.analyse_types(env) array_dtype = self.base_type_node.base_type_node.analyse(env) MemoryView.validate_memslice_dtype(self.pos, array_dtype) if not self.operand.type.is_ptr: return error(self.operand.pos, ERR_NOT_POINTER) elif not self.operand.type.base_type.same_as(array_dtype): return error(self.operand.pos, ERR_BASE_TYPE) if not self.operand.is_name: self.operand = self.operand.coerce_to_temp(env) axes = [('direct', 'follow')] * len(self.base_type_node.axes) if self.mode == "fortran": axes[0] = ('direct', 'contig') else: axes[-1] = ('direct', 'contig') self.coercion_type = PyrexTypes.MemoryViewSliceType(array_dtype, axes) #self.type = py_object_type self.type = self.get_cython_array_type(env) assert self.type env.use_utility_code(MemoryView.cython_array_utility_code) env.use_utility_code(MemoryView.typeinfo_to_format_code) def allocate_temp_result(self, code): if self.temp_code: raise RuntimeError("temp allocated mulitple times") self.temp_code = code.funcstate.allocate_temp(self.type, True) def infer_type(self, env): return self.get_cython_array_type(env) def get_cython_array_type(self, env): return env.global_scope().context.cython_scope.lookup("array").type def generate_result_code(self, code): import Buffer shapes = [self.shape_type.cast_code(shape.result()) for shape in self.shapes] dtype = self.coercion_type.dtype shapes_temp = code.funcstate.allocate_temp(py_object_type, True) format_temp = code.funcstate.allocate_temp(py_object_type, True) itemsize = "sizeof(%s)" % dtype.declaration_code("") type_info = Buffer.get_type_information_cname(code, dtype) code.putln("if (!%s) {" % self.operand.result()) code.putln( 'PyErr_SetString(PyExc_ValueError,' '"Cannot create cython.array from NULL pointer");') code.putln(code.error_goto(self.operand.pos)) code.putln("}") code.putln("%s = __pyx_format_from_typeinfo(&%s);" % (format_temp, type_info)) code.putln('%s = Py_BuildValue("(%s)", %s);' % (shapes_temp, "n" * len(shapes), ", ".join(shapes))) err = "!%s || !%s || !PyBytes_Check(%s)" % (format_temp, shapes_temp, format_temp) code.putln(code.error_goto_if(err, self.pos)) code.put_gotref(format_temp) code.put_gotref(shapes_temp) tup = (self.result(), shapes_temp, itemsize, format_temp, self.mode, self.operand.result()) code.putln('%s = __pyx_array_new(' '%s, %s, PyBytes_AS_STRING(%s), ' '(char *) "%s", (char *) %s);' % tup) code.putln(code.error_goto_if_null(self.result(), self.pos)) code.put_gotref(self.result()) def dispose(temp): code.put_decref_clear(temp, py_object_type) code.funcstate.release_temp(temp) dispose(shapes_temp) dispose(format_temp) class SizeofNode(ExprNode): # Abstract base class for sizeof(x) expression nodes. type = PyrexTypes.c_size_t_type def check_const(self): return True def generate_result_code(self, code): pass class SizeofTypeNode(SizeofNode): # C sizeof function applied to a type # # base_type CBaseTypeNode # declarator CDeclaratorNode subexprs = [] arg_type = None def analyse_types(self, env): # we may have incorrectly interpreted a dotted name as a type rather than an attribute # this could be better handled by more uniformly treating types as runtime-available objects if 0 and self.base_type.module_path: path = self.base_type.module_path obj = env.lookup(path[0]) if obj.as_module is None: operand = NameNode(pos=self.pos, name=path[0]) for attr in path[1:]: operand = AttributeNode(pos=self.pos, obj=operand, attribute=attr) operand = AttributeNode(pos=self.pos, obj=operand, attribute=self.base_type.name) self.operand = operand self.__class__ = SizeofVarNode self.analyse_types(env) return if self.arg_type is None: base_type = self.base_type.analyse(env) _, arg_type = self.declarator.analyse(base_type, env) self.arg_type = arg_type self.check_type() def check_type(self): arg_type = self.arg_type if arg_type.is_pyobject and not arg_type.is_extension_type: error(self.pos, "Cannot take sizeof Python object") elif arg_type.is_void: error(self.pos, "Cannot take sizeof void") elif not arg_type.is_complete(): error(self.pos, "Cannot take sizeof incomplete type '%s'" % arg_type) def calculate_result_code(self): if self.arg_type.is_extension_type: # the size of the pointer is boring # we want the size of the actual struct arg_code = self.arg_type.declaration_code("", deref=1) else: arg_code = self.arg_type.declaration_code("") return "(sizeof(%s))" % arg_code class SizeofVarNode(SizeofNode): # C sizeof function applied to a variable # # operand ExprNode subexprs = ['operand'] def analyse_types(self, env): # We may actually be looking at a type rather than a variable... # If we are, traditional analysis would fail... operand_as_type = self.operand.analyse_as_type(env) if operand_as_type: self.arg_type = operand_as_type self.__class__ = SizeofTypeNode self.check_type() else: self.operand.analyse_types(env) def calculate_result_code(self): return "(sizeof(%s))" % self.operand.result() def generate_result_code(self, code): pass class TypeofNode(ExprNode): # Compile-time type of an expression, as a string. # # operand ExprNode # literal StringNode # internal literal = None type = py_object_type subexprs = ['literal'] # 'operand' will be ignored after type analysis! def analyse_types(self, env): self.operand.analyse_types(env) self.literal = StringNode( self.pos, value=StringEncoding.EncodedString(str(self.operand.type))) self.literal.analyse_types(env) self.literal = self.literal.coerce_to_pyobject(env) def may_be_none(self): return False def generate_evaluation_code(self, code): self.literal.generate_evaluation_code(code) def calculate_result_code(self): return self.literal.calculate_result_code() #------------------------------------------------------------------- # # Binary operator nodes # #------------------------------------------------------------------- def _not_in(x, seq): return x not in seq compile_time_binary_operators = { '<': operator.lt, '<=': operator.le, '==': operator.eq, '!=': operator.ne, '>=': operator.ge, '>': operator.gt, 'is': operator.is_, 'is_not': operator.is_not, '+': operator.add, '&': operator.and_, '/': operator.truediv, '//': operator.floordiv, '<<': operator.lshift, '%': operator.mod, '*': operator.mul, '|': operator.or_, '**': operator.pow, '>>': operator.rshift, '-': operator.sub, '^': operator.xor, 'in': operator.contains, 'not_in': _not_in, } def get_compile_time_binop(node): func = compile_time_binary_operators.get(node.operator) if not func: error(node.pos, "Binary '%s' not supported in compile-time expression" % node.operator) return func class BinopNode(ExprNode): # operator string # operand1 ExprNode # operand2 ExprNode # # Processing during analyse_expressions phase: # # analyse_c_operation # Called when neither operand is a pyobject. # - Check operand types and coerce if needed. # - Determine result type and result code fragment. # - Allocate temporary for result if needed. subexprs = ['operand1', 'operand2'] inplace = False def calculate_constant_result(self): func = compile_time_binary_operators[self.operator] self.constant_result = func( self.operand1.constant_result, self.operand2.constant_result) def compile_time_value(self, denv): func = get_compile_time_binop(self) operand1 = self.operand1.compile_time_value(denv) operand2 = self.operand2.compile_time_value(denv) try: return func(operand1, operand2) except Exception, e: self.compile_time_value_error(e) def infer_type(self, env): return self.result_type(self.operand1.infer_type(env), self.operand2.infer_type(env)) def analyse_types(self, env): self.operand1.analyse_types(env) self.operand2.analyse_types(env) self.analyse_operation(env) def analyse_operation(self, env): if self.is_py_operation(): self.coerce_operands_to_pyobjects(env) self.type = self.result_type(self.operand1.type, self.operand2.type) assert self.type.is_pyobject self.is_temp = 1 elif self.is_cpp_operation(): self.analyse_cpp_operation(env) else: self.analyse_c_operation(env) def is_py_operation(self): return self.is_py_operation_types(self.operand1.type, self.operand2.type) def is_py_operation_types(self, type1, type2): return type1.is_pyobject or type2.is_pyobject def is_cpp_operation(self): return (self.operand1.type.is_cpp_class or self.operand2.type.is_cpp_class) def analyse_cpp_operation(self, env): type1 = self.operand1.type type2 = self.operand2.type entry = env.lookup_operator(self.operator, [self.operand1, self.operand2]) if not entry: self.type_error() return func_type = entry.type if func_type.is_ptr: func_type = func_type.base_type if len(func_type.args) == 1: self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) else: self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) self.type = func_type.return_type def result_type(self, type1, type2): if self.is_py_operation_types(type1, type2): if type2.is_string: type2 = Builtin.bytes_type if type1.is_string: type1 = Builtin.bytes_type elif self.operator == '%' \ and type1 in (Builtin.str_type, Builtin.unicode_type): # note that b'%s' % b'abc' doesn't work in Py3 return type1 if type1.is_builtin_type: if type1 is type2: if self.operator in '**%+|&^': # FIXME: at least these operators should be safe - others? return type1 elif self.operator == '*': if type1 in (Builtin.bytes_type, Builtin.str_type, Builtin.unicode_type): return type1 # multiplication of containers/numbers with an # integer value always (?) returns the same type if type2.is_int: return type1 elif type2.is_builtin_type and type1.is_int and self.operator == '*': # multiplication of containers/numbers with an # integer value always (?) returns the same type return type2 return py_object_type else: return self.compute_c_result_type(type1, type2) def nogil_check(self, env): if self.is_py_operation(): self.gil_error() def coerce_operands_to_pyobjects(self, env): self.operand1 = self.operand1.coerce_to_pyobject(env) self.operand2 = self.operand2.coerce_to_pyobject(env) def check_const(self): return self.operand1.check_const() and self.operand2.check_const() def generate_result_code(self, code): #print "BinopNode.generate_result_code:", self.operand1, self.operand2 ### if self.operand1.type.is_pyobject: function = self.py_operation_function() if self.operator == '**': extra_args = ", Py_None" else: extra_args = "" code.putln( "%s = %s(%s, %s%s); %s" % ( self.result(), function, self.operand1.py_result(), self.operand2.py_result(), extra_args, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) def type_error(self): if not (self.operand1.type.is_error or self.operand2.type.is_error): error(self.pos, "Invalid operand types for '%s' (%s; %s)" % (self.operator, self.operand1.type, self.operand2.type)) self.type = PyrexTypes.error_type class CBinopNode(BinopNode): def analyse_types(self, env): BinopNode.analyse_types(self, env) if self.is_py_operation(): self.type = PyrexTypes.error_type def py_operation_function(): return "" def calculate_result_code(self): return "(%s %s %s)" % ( self.operand1.result(), self.operator, self.operand2.result()) def c_binop_constructor(operator): def make_binop_node(pos, **operands): return CBinopNode(pos, operator=operator, **operands) return make_binop_node class NumBinopNode(BinopNode): # Binary operation taking numeric arguments. infix = True def analyse_c_operation(self, env): type1 = self.operand1.type type2 = self.operand2.type self.type = self.compute_c_result_type(type1, type2) if not self.type: self.type_error() return if self.type.is_complex: self.infix = False if not self.infix or (type1.is_numeric and type2.is_numeric): self.operand1 = self.operand1.coerce_to(self.type, env) self.operand2 = self.operand2.coerce_to(self.type, env) def compute_c_result_type(self, type1, type2): if self.c_types_okay(type1, type2): widest_type = PyrexTypes.widest_numeric_type(type1, type2) if widest_type is PyrexTypes.c_bint_type: if self.operator not in '|^&': # False + False == 0 # not False! widest_type = PyrexTypes.c_int_type else: widest_type = PyrexTypes.widest_numeric_type( widest_type, PyrexTypes.c_int_type) return widest_type else: return None def may_be_none(self): type1 = self.operand1.type type2 = self.operand2.type if type1 and type1.is_builtin_type and type2 and type2.is_builtin_type: # XXX: I can't think of any case where a binary operation # on builtin types evaluates to None - add a special case # here if there is one. return False return super(NumBinopNode, self).may_be_none() def get_constant_c_result_code(self): value1 = self.operand1.get_constant_c_result_code() value2 = self.operand2.get_constant_c_result_code() if value1 and value2: return "(%s %s %s)" % (value1, self.operator, value2) else: return None def c_types_okay(self, type1, type2): #print "NumBinopNode.c_types_okay:", type1, type2 ### return (type1.is_numeric or type1.is_enum) \ and (type2.is_numeric or type2.is_enum) def calculate_result_code(self): if self.infix: return "(%s %s %s)" % ( self.operand1.result(), self.operator, self.operand2.result()) else: func = self.type.binary_op(self.operator) if func is None: error(self.pos, "binary operator %s not supported for %s" % (self.operator, self.type)) return "%s(%s, %s)" % ( func, self.operand1.result(), self.operand2.result()) def is_py_operation_types(self, type1, type2): return (type1.is_unicode_char or type2.is_unicode_char or BinopNode.is_py_operation_types(self, type1, type2)) def py_operation_function(self): fuction = self.py_functions[self.operator] if self.inplace: fuction = fuction.replace('PyNumber_', 'PyNumber_InPlace') return fuction py_functions = { "|": "PyNumber_Or", "^": "PyNumber_Xor", "&": "PyNumber_And", "<<": "PyNumber_Lshift", ">>": "PyNumber_Rshift", "+": "PyNumber_Add", "-": "PyNumber_Subtract", "*": "PyNumber_Multiply", "/": "__Pyx_PyNumber_Divide", "//": "PyNumber_FloorDivide", "%": "PyNumber_Remainder", "**": "PyNumber_Power" } class IntBinopNode(NumBinopNode): # Binary operation taking integer arguments. def c_types_okay(self, type1, type2): #print "IntBinopNode.c_types_okay:", type1, type2 ### return (type1.is_int or type1.is_enum) \ and (type2.is_int or type2.is_enum) class AddNode(NumBinopNode): # '+' operator. def is_py_operation_types(self, type1, type2): if type1.is_string and type2.is_string: return 1 else: return NumBinopNode.is_py_operation_types(self, type1, type2) def compute_c_result_type(self, type1, type2): #print "AddNode.compute_c_result_type:", type1, self.operator, type2 ### if (type1.is_ptr or type1.is_array) and (type2.is_int or type2.is_enum): return type1 elif (type2.is_ptr or type2.is_array) and (type1.is_int or type1.is_enum): return type2 else: return NumBinopNode.compute_c_result_type( self, type1, type2) class SubNode(NumBinopNode): # '-' operator. def compute_c_result_type(self, type1, type2): if (type1.is_ptr or type1.is_array) and (type2.is_int or type2.is_enum): return type1 elif (type1.is_ptr or type1.is_array) and (type2.is_ptr or type2.is_array): return PyrexTypes.c_int_type else: return NumBinopNode.compute_c_result_type( self, type1, type2) class MulNode(NumBinopNode): # '*' operator. def is_py_operation_types(self, type1, type2): if (type1.is_string and type2.is_int) \ or (type2.is_string and type1.is_int): return 1 else: return NumBinopNode.is_py_operation_types(self, type1, type2) class DivNode(NumBinopNode): # '/' or '//' operator. cdivision = None truedivision = None # == "unknown" if operator == '/' ctruedivision = False cdivision_warnings = False zerodivision_check = None def find_compile_time_binary_operator(self, op1, op2): func = compile_time_binary_operators[self.operator] if self.operator == '/' and self.truedivision is None: # => true div for floats, floor div for integers if isinstance(op1, (int,long)) and isinstance(op2, (int,long)): func = compile_time_binary_operators['//'] return func def calculate_constant_result(self): op1 = self.operand1.constant_result op2 = self.operand2.constant_result func = self.find_compile_time_binary_operator(op1, op2) self.constant_result = func( self.operand1.constant_result, self.operand2.constant_result) def compile_time_value(self, denv): operand1 = self.operand1.compile_time_value(denv) operand2 = self.operand2.compile_time_value(denv) try: func = self.find_compile_time_binary_operator( operand1, operand2) return func(operand1, operand2) except Exception, e: self.compile_time_value_error(e) def analyse_operation(self, env): if self.cdivision or env.directives['cdivision']: self.ctruedivision = False else: self.ctruedivision = self.truedivision NumBinopNode.analyse_operation(self, env) if self.is_cpp_operation(): self.cdivision = True if not self.type.is_pyobject: self.zerodivision_check = ( self.cdivision is None and not env.directives['cdivision'] and (not self.operand2.has_constant_result() or self.operand2.constant_result == 0)) if self.zerodivision_check or env.directives['cdivision_warnings']: # Need to check ahead of time to warn or raise zero division error self.operand1 = self.operand1.coerce_to_simple(env) self.operand2 = self.operand2.coerce_to_simple(env) if env.nogil: error(self.pos, "Pythonic division not allowed without gil, consider using cython.cdivision(True)") def compute_c_result_type(self, type1, type2): if self.operator == '/' and self.ctruedivision: if not type1.is_float and not type2.is_float: widest_type = PyrexTypes.widest_numeric_type(type1, PyrexTypes.c_double_type) widest_type = PyrexTypes.widest_numeric_type(type2, widest_type) return widest_type return NumBinopNode.compute_c_result_type(self, type1, type2) def zero_division_message(self): if self.type.is_int: return "integer division or modulo by zero" else: return "float division" def generate_evaluation_code(self, code): if not self.type.is_pyobject and not self.type.is_complex: if self.cdivision is None: self.cdivision = (code.globalstate.directives['cdivision'] or not self.type.signed or self.type.is_float) if not self.cdivision: code.globalstate.use_utility_code(div_int_utility_code.specialize(self.type)) NumBinopNode.generate_evaluation_code(self, code) self.generate_div_warning_code(code) def generate_div_warning_code(self, code): if not self.type.is_pyobject: if self.zerodivision_check: if not self.infix: zero_test = "%s(%s)" % (self.type.unary_op('zero'), self.operand2.result()) else: zero_test = "%s == 0" % self.operand2.result() code.putln("if (unlikely(%s)) {" % zero_test) code.putln('PyErr_Format(PyExc_ZeroDivisionError, "%s");' % self.zero_division_message()) code.putln(code.error_goto(self.pos)) code.putln("}") if self.type.is_int and self.type.signed and self.operator != '%': code.globalstate.use_utility_code(division_overflow_test_code) code.putln("else if (sizeof(%s) == sizeof(long) && unlikely(%s == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {" % ( self.type.declaration_code(''), self.operand2.result(), self.operand1.result())) code.putln('PyErr_Format(PyExc_OverflowError, "value too large to perform division");') code.putln(code.error_goto(self.pos)) code.putln("}") if code.globalstate.directives['cdivision_warnings'] and self.operator != '/': code.globalstate.use_utility_code(cdivision_warning_utility_code) code.putln("if ((%s < 0) ^ (%s < 0)) {" % ( self.operand1.result(), self.operand2.result())) code.putln(code.set_error_info(self.pos)); code.put("if (__Pyx_cdivision_warning(%(FILENAME)s, " "%(LINENO)s)) " % { 'FILENAME': Naming.filename_cname, 'LINENO': Naming.lineno_cname, }) code.put_goto(code.error_label) code.putln("}") def calculate_result_code(self): if self.type.is_complex: return NumBinopNode.calculate_result_code(self) elif self.type.is_float and self.operator == '//': return "floor(%s / %s)" % ( self.operand1.result(), self.operand2.result()) elif self.truedivision or self.cdivision: op1 = self.operand1.result() op2 = self.operand2.result() if self.truedivision: if self.type != self.operand1.type: op1 = self.type.cast_code(op1) if self.type != self.operand2.type: op2 = self.type.cast_code(op2) return "(%s / %s)" % (op1, op2) else: return "__Pyx_div_%s(%s, %s)" % ( self.type.specialization_name(), self.operand1.result(), self.operand2.result()) class ModNode(DivNode): # '%' operator. def is_py_operation_types(self, type1, type2): return (type1.is_string or type2.is_string or NumBinopNode.is_py_operation_types(self, type1, type2)) def zero_division_message(self): if self.type.is_int: return "integer division or modulo by zero" else: return "float divmod()" def generate_evaluation_code(self, code): if not self.type.is_pyobject: if self.cdivision is None: self.cdivision = code.globalstate.directives['cdivision'] or not self.type.signed if not self.cdivision: if self.type.is_int: code.globalstate.use_utility_code(mod_int_utility_code.specialize(self.type)) else: code.globalstate.use_utility_code( mod_float_utility_code.specialize(self.type, math_h_modifier=self.type.math_h_modifier)) NumBinopNode.generate_evaluation_code(self, code) self.generate_div_warning_code(code) def calculate_result_code(self): if self.cdivision: if self.type.is_float: return "fmod%s(%s, %s)" % ( self.type.math_h_modifier, self.operand1.result(), self.operand2.result()) else: return "(%s %% %s)" % ( self.operand1.result(), self.operand2.result()) else: return "__Pyx_mod_%s(%s, %s)" % ( self.type.specialization_name(), self.operand1.result(), self.operand2.result()) class PowNode(NumBinopNode): # '**' operator. def analyse_c_operation(self, env): NumBinopNode.analyse_c_operation(self, env) if self.type.is_complex: if self.type.real_type.is_float: self.operand1 = self.operand1.coerce_to(self.type, env) self.operand2 = self.operand2.coerce_to(self.type, env) self.pow_func = "__Pyx_c_pow" + self.type.real_type.math_h_modifier else: error(self.pos, "complex int powers not supported") self.pow_func = "<error>" elif self.type.is_float: self.pow_func = "pow" + self.type.math_h_modifier else: self.pow_func = "__Pyx_pow_%s" % self.type.declaration_code('').replace(' ', '_') env.use_utility_code( int_pow_utility_code.specialize(func_name=self.pow_func, type=self.type.declaration_code(''))) def calculate_result_code(self): # Work around MSVC overloading ambiguity. def typecast(operand): if self.type == operand.type: return operand.result() else: return self.type.cast_code(operand.result()) return "%s(%s, %s)" % ( self.pow_func, typecast(self.operand1), typecast(self.operand2)) # Note: This class is temporarily "shut down" into an ineffective temp # allocation mode. # # More sophisticated temp reuse was going on before, one could have a # look at adding this again after /all/ classes are converted to the # new temp scheme. (The temp juggling cannot work otherwise). class BoolBinopNode(ExprNode): # Short-circuiting boolean operation. # # operator string # operand1 ExprNode # operand2 ExprNode subexprs = ['operand1', 'operand2'] def infer_type(self, env): type1 = self.operand1.infer_type(env) type2 = self.operand2.infer_type(env) return PyrexTypes.independent_spanning_type(type1, type2) def may_be_none(self): if self.operator == 'or': return self.operand2.may_be_none() else: return self.operand1.may_be_none() or self.operand2.may_be_none() def calculate_constant_result(self): if self.operator == 'and': self.constant_result = \ self.operand1.constant_result and \ self.operand2.constant_result else: self.constant_result = \ self.operand1.constant_result or \ self.operand2.constant_result def compile_time_value(self, denv): if self.operator == 'and': return self.operand1.compile_time_value(denv) \ and self.operand2.compile_time_value(denv) else: return self.operand1.compile_time_value(denv) \ or self.operand2.compile_time_value(denv) def coerce_to_boolean(self, env): return BoolBinopNode( self.pos, operator = self.operator, operand1 = self.operand1.coerce_to_boolean(env), operand2 = self.operand2.coerce_to_boolean(env), type = PyrexTypes.c_bint_type, is_temp = self.is_temp) def analyse_types(self, env): self.operand1.analyse_types(env) self.operand2.analyse_types(env) self.type = PyrexTypes.independent_spanning_type(self.operand1.type, self.operand2.type) self.operand1 = self.operand1.coerce_to(self.type, env) self.operand2 = self.operand2.coerce_to(self.type, env) # For what we're about to do, it's vital that # both operands be temp nodes. self.operand1 = self.operand1.coerce_to_simple(env) self.operand2 = self.operand2.coerce_to_simple(env) self.is_temp = 1 gil_message = "Truth-testing Python object" def check_const(self): return self.operand1.check_const() and self.operand2.check_const() def generate_evaluation_code(self, code): code.mark_pos(self.pos) self.operand1.generate_evaluation_code(code) test_result, uses_temp = self.generate_operand1_test(code) if self.operator == 'and': sense = "" else: sense = "!" code.putln( "if (%s%s) {" % ( sense, test_result)) if uses_temp: code.funcstate.release_temp(test_result) self.operand1.generate_disposal_code(code) self.operand2.generate_evaluation_code(code) self.allocate_temp_result(code) self.operand2.make_owned_reference(code) code.putln("%s = %s;" % (self.result(), self.operand2.result())) self.operand2.generate_post_assignment_code(code) self.operand2.free_temps(code) code.putln("} else {") self.operand1.make_owned_reference(code) code.putln("%s = %s;" % (self.result(), self.operand1.result())) self.operand1.generate_post_assignment_code(code) self.operand1.free_temps(code) code.putln("}") def generate_operand1_test(self, code): # Generate code to test the truth of the first operand. if self.type.is_pyobject: test_result = code.funcstate.allocate_temp(PyrexTypes.c_bint_type, manage_ref=False) code.putln( "%s = __Pyx_PyObject_IsTrue(%s); %s" % ( test_result, self.operand1.py_result(), code.error_goto_if_neg(test_result, self.pos))) else: test_result = self.operand1.result() return (test_result, self.type.is_pyobject) class CondExprNode(ExprNode): # Short-circuiting conditional expression. # # test ExprNode # true_val ExprNode # false_val ExprNode true_val = None false_val = None subexprs = ['test', 'true_val', 'false_val'] def type_dependencies(self, env): return self.true_val.type_dependencies(env) + self.false_val.type_dependencies(env) def infer_type(self, env): return PyrexTypes.independent_spanning_type(self.true_val.infer_type(env), self.false_val.infer_type(env)) def calculate_constant_result(self): if self.test.constant_result: self.constant_result = self.true_val.constant_result else: self.constant_result = self.false_val.constant_result def analyse_types(self, env): self.test.analyse_types(env) self.test = self.test.coerce_to_boolean(env) self.true_val.analyse_types(env) self.false_val.analyse_types(env) self.type = PyrexTypes.independent_spanning_type(self.true_val.type, self.false_val.type) if self.true_val.type.is_pyobject or self.false_val.type.is_pyobject: self.true_val = self.true_val.coerce_to(self.type, env) self.false_val = self.false_val.coerce_to(self.type, env) self.is_temp = 1 if self.type == PyrexTypes.error_type: self.type_error() def type_error(self): if not (self.true_val.type.is_error or self.false_val.type.is_error): error(self.pos, "Incompatable types in conditional expression (%s; %s)" % (self.true_val.type, self.false_val.type)) self.type = PyrexTypes.error_type def check_const(self): return (self.test.check_const() and self.true_val.check_const() and self.false_val.check_const()) def generate_evaluation_code(self, code): # Because subexprs may not be evaluated we can use a more optimal # subexpr allocation strategy than the default, so override evaluation_code. code.mark_pos(self.pos) self.allocate_temp_result(code) self.test.generate_evaluation_code(code) code.putln("if (%s) {" % self.test.result() ) self.eval_and_get(code, self.true_val) code.putln("} else {") self.eval_and_get(code, self.false_val) code.putln("}") self.test.generate_disposal_code(code) self.test.free_temps(code) def eval_and_get(self, code, expr): expr.generate_evaluation_code(code) expr.make_owned_reference(code) code.putln("%s = %s;" % (self.result(), expr.result())) expr.generate_post_assignment_code(code) expr.free_temps(code) richcmp_constants = { "<" : "Py_LT", "<=": "Py_LE", "==": "Py_EQ", "!=": "Py_NE", "<>": "Py_NE", ">" : "Py_GT", ">=": "Py_GE", } class CmpNode(object): # Mixin class containing code common to PrimaryCmpNodes # and CascadedCmpNodes. special_bool_cmp_function = None def infer_type(self, env): # TODO: Actually implement this (after merging with -unstable). return py_object_type def calculate_cascaded_constant_result(self, operand1_result): func = compile_time_binary_operators[self.operator] operand2_result = self.operand2.constant_result result = func(operand1_result, operand2_result) if self.cascade: self.cascade.calculate_cascaded_constant_result(operand2_result) if self.cascade.constant_result: self.constant_result = result and self.cascade.constant_result else: self.constant_result = result def cascaded_compile_time_value(self, operand1, denv): func = get_compile_time_binop(self) operand2 = self.operand2.compile_time_value(denv) try: result = func(operand1, operand2) except Exception, e: self.compile_time_value_error(e) result = None if result: cascade = self.cascade if cascade: # FIXME: I bet this must call cascaded_compile_time_value() result = result and cascade.cascaded_compile_time_value(operand2, denv) return result def is_cpp_comparison(self): return self.operand1.type.is_cpp_class or self.operand2.type.is_cpp_class def find_common_int_type(self, env, op, operand1, operand2): # type1 != type2 and at least one of the types is not a C int type1 = operand1.type type2 = operand2.type type1_can_be_int = False type2_can_be_int = False if operand1.is_string_literal and operand1.can_coerce_to_char_literal(): type1_can_be_int = True if operand2.is_string_literal and operand2.can_coerce_to_char_literal(): type2_can_be_int = True if type1.is_int: if type2_can_be_int: return type1 elif type2.is_int: if type1_can_be_int: return type2 elif type1_can_be_int: if type2_can_be_int: return PyrexTypes.c_uchar_type return None def find_common_type(self, env, op, operand1, common_type=None): operand2 = self.operand2 type1 = operand1.type type2 = operand2.type new_common_type = None # catch general errors if type1 == str_type and (type2.is_string or type2 in (bytes_type, unicode_type)) or \ type2 == str_type and (type1.is_string or type1 in (bytes_type, unicode_type)): error(self.pos, "Comparisons between bytes/unicode and str are not portable to Python 3") new_common_type = error_type # try to use numeric comparisons where possible elif type1.is_complex or type2.is_complex: if op not in ('==', '!=') \ and (type1.is_complex or type1.is_numeric) \ and (type2.is_complex or type2.is_numeric): error(self.pos, "complex types are unordered") new_common_type = error_type elif type1.is_pyobject: new_common_type = type1 elif type2.is_pyobject: new_common_type = type2 else: new_common_type = PyrexTypes.widest_numeric_type(type1, type2) elif type1.is_numeric and type2.is_numeric: new_common_type = PyrexTypes.widest_numeric_type(type1, type2) elif common_type is None or not common_type.is_pyobject: new_common_type = self.find_common_int_type(env, op, operand1, operand2) if new_common_type is None: # fall back to generic type compatibility tests if type1 == type2: new_common_type = type1 elif type1.is_pyobject or type2.is_pyobject: if type2.is_numeric or type2.is_string: if operand2.check_for_coercion_error(type1): new_common_type = error_type else: new_common_type = py_object_type elif type1.is_numeric or type1.is_string: if operand1.check_for_coercion_error(type2): new_common_type = error_type else: new_common_type = py_object_type elif py_object_type.assignable_from(type1) and py_object_type.assignable_from(type2): new_common_type = py_object_type else: # one Python type and one non-Python type, not assignable self.invalid_types_error(operand1, op, operand2) new_common_type = error_type elif type1.assignable_from(type2): new_common_type = type1 elif type2.assignable_from(type1): new_common_type = type2 else: # C types that we couldn't handle up to here are an error self.invalid_types_error(operand1, op, operand2) new_common_type = error_type if new_common_type.is_string and (isinstance(operand1, BytesNode) or isinstance(operand2, BytesNode)): # special case when comparing char* to bytes literal: must # compare string values! new_common_type = bytes_type # recursively merge types if common_type is None or new_common_type.is_error: common_type = new_common_type else: # we could do a lot better by splitting the comparison # into a non-Python part and a Python part, but this is # safer for now common_type = PyrexTypes.spanning_type(common_type, new_common_type) if self.cascade: common_type = self.cascade.find_common_type(env, self.operator, operand2, common_type) return common_type def invalid_types_error(self, operand1, op, operand2): error(self.pos, "Invalid types for '%s' (%s, %s)" % (op, operand1.type, operand2.type)) def is_python_comparison(self): return (not self.is_ptr_contains() and not self.is_c_string_contains() and (self.has_python_operands() or (self.cascade and self.cascade.is_python_comparison()) or self.operator in ('in', 'not_in'))) def coerce_operands_to(self, dst_type, env): operand2 = self.operand2 if operand2.type != dst_type: self.operand2 = operand2.coerce_to(dst_type, env) if self.cascade: self.cascade.coerce_operands_to(dst_type, env) def is_python_result(self): return ((self.has_python_operands() and self.special_bool_cmp_function is None and self.operator not in ('is', 'is_not', 'in', 'not_in') and not self.is_c_string_contains() and not self.is_ptr_contains()) or (self.cascade and self.cascade.is_python_result())) def is_c_string_contains(self): return self.operator in ('in', 'not_in') and \ ((self.operand1.type.is_int and (self.operand2.type.is_string or self.operand2.type is bytes_type)) or (self.operand1.type.is_unicode_char and self.operand2.type is unicode_type)) def is_ptr_contains(self): if self.operator in ('in', 'not_in'): container_type = self.operand2.type return (container_type.is_ptr or container_type.is_array) \ and not container_type.is_string def find_special_bool_compare_function(self, env): if self.operator in ('==', '!='): type1, type2 = self.operand1.type, self.operand2.type if type1.is_pyobject and type2.is_pyobject: if type1 is Builtin.unicode_type or type2 is Builtin.unicode_type: env.use_utility_code(pyunicode_equals_utility_code) self.special_bool_cmp_function = "__Pyx_PyUnicode_Equals" return True elif type1 is Builtin.bytes_type or type2 is Builtin.bytes_type: env.use_utility_code(pybytes_equals_utility_code) self.special_bool_cmp_function = "__Pyx_PyBytes_Equals" return True elif type1 is Builtin.str_type or type2 is Builtin.str_type: env.use_utility_code(pystr_equals_utility_code) self.special_bool_cmp_function = "__Pyx_PyString_Equals" return True return False def generate_operation_code(self, code, result_code, operand1, op , operand2): if self.type.is_pyobject: coerce_result = "__Pyx_PyBool_FromLong" else: coerce_result = "" if 'not' in op: negation = "!" else: negation = "" if self.special_bool_cmp_function: if operand1.type.is_pyobject: result1 = operand1.py_result() else: result1 = operand1.result() if operand2.type.is_pyobject: result2 = operand2.py_result() else: result2 = operand2.result() code.putln("%s = %s(%s, %s, %s); %s" % ( result_code, self.special_bool_cmp_function, result1, result2, richcmp_constants[op], code.error_goto_if_neg(result_code, self.pos))) elif op == 'in' or op == 'not_in': code.globalstate.use_utility_code(contains_utility_code) if self.type.is_pyobject: coerce_result = "__Pyx_PyBoolOrNull_FromLong" if op == 'not_in': negation = "__Pyx_NegateNonNeg" if operand2.type is dict_type: method = "PyDict_Contains" else: method = "PySequence_Contains" if self.type.is_pyobject: error_clause = code.error_goto_if_null got_ref = "__Pyx_XGOTREF(%s); " % result_code else: error_clause = code.error_goto_if_neg got_ref = "" code.putln( "%s = %s(%s(%s(%s, %s))); %s%s" % ( result_code, coerce_result, negation, method, operand2.py_result(), operand1.py_result(), got_ref, error_clause(result_code, self.pos))) elif (operand1.type.is_pyobject and op not in ('is', 'is_not')): code.putln("%s = PyObject_RichCompare(%s, %s, %s); %s" % ( result_code, operand1.py_result(), operand2.py_result(), richcmp_constants[op], code.error_goto_if_null(result_code, self.pos))) code.put_gotref(result_code) elif operand1.type.is_complex: if op == "!=": negation = "!" else: negation = "" code.putln("%s = %s(%s%s(%s, %s));" % ( result_code, coerce_result, negation, operand1.type.unary_op('eq'), operand1.result(), operand2.result())) else: type1 = operand1.type type2 = operand2.type if (type1.is_extension_type or type2.is_extension_type) \ and not type1.same_as(type2): common_type = py_object_type elif type1.is_numeric: common_type = PyrexTypes.widest_numeric_type(type1, type2) else: common_type = type1 code1 = operand1.result_as(common_type) code2 = operand2.result_as(common_type) code.putln("%s = %s(%s %s %s);" % ( result_code, coerce_result, code1, self.c_operator(op), code2)) def c_operator(self, op): if op == 'is': return "==" elif op == 'is_not': return "!=" else: return op contains_utility_code = UtilityCode( proto=""" static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) { return unlikely(b < 0) ? b : !b; } static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) { return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b); } """) char_in_bytes_utility_code = UtilityCode( proto=""" static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character); /*proto*/ """, impl=""" static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) { const Py_ssize_t length = PyBytes_GET_SIZE(bytes); char* char_start = PyBytes_AS_STRING(bytes); char* pos; for (pos=char_start; pos < char_start+length; pos++) { if (character == pos[0]) return 1; } return 0; } """) py_ucs4_in_unicode_utility_code = UtilityCode( proto=""" static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character); /*proto*/ static CYTHON_INLINE int __Pyx_PyUnicodeBufferContainsUCS4(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character); /*proto*/ """, # additionally handles surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds impl=""" static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) { #ifdef CYTHON_PEP393_ENABLED Py_ssize_t i; int kind; void* udata; Py_ssize_t length; kind = PyUnicode_KIND(unicode); if (likely(kind != PyUnicode_WCHAR_KIND)) { udata = PyUnicode_DATA(unicode); length = PyUnicode_GET_LENGTH(unicode); for (i=0; i < length; i++) { if (unlikely(character == PyUnicode_READ(kind, udata, i))) return 1; } return 0; } #endif return __Pyx_PyUnicodeBufferContainsUCS4( PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode), character); } static CYTHON_INLINE int __Pyx_PyUnicodeBufferContainsUCS4(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) { Py_UNICODE uchar; Py_UNICODE* pos; #if Py_UNICODE_SIZE == 2 if (character > 65535) { Py_UNICODE high_val, low_val; high_val = (Py_UNICODE) (0xD800 | (((character - 0x10000) >> 10) & ((1<<10)-1))); low_val = (Py_UNICODE) (0xDC00 | ( (character - 0x10000) & ((1<<10)-1))); for (pos=buffer; pos < buffer+length-1; pos++) { if (unlikely(high_val == pos[0]) & unlikely(low_val == pos[1])) return 1; } return 0; } #endif uchar = (Py_UNICODE) character; for (pos=buffer; pos < buffer+length; pos++) { if (unlikely(uchar == pos[0])) return 1; } return 0; } """) pyunicode_equals_utility_code = UtilityCode( proto=""" static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ """, impl=""" static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { if (s1 == s2) { /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */ return (equals == Py_EQ); } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) { #ifdef CYTHON_PEP393_ENABLED if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0)) return -1; if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) { return (equals == Py_NE); } else if (PyUnicode_GET_LENGTH(s1) == 1) { Py_UCS4 ch1 = PyUnicode_READ_CHAR(s1, 0); Py_UCS4 ch2 = PyUnicode_READ_CHAR(s2, 0); return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); """ ## currently disabled: may not be safe depending on who created the string # } else if (PyUnicode_MAX_CHAR_VALUE(s1) != PyUnicode_MAX_CHAR_VALUE(s2)) { # return (equals == Py_NE); """\ #else if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) { return (equals == Py_NE); } else if (PyUnicode_GET_SIZE(s1) == 1) { Py_UNICODE ch1 = PyUnicode_AS_UNICODE(s1)[0]; Py_UNICODE ch2 = PyUnicode_AS_UNICODE(s2)[0]; return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); #endif } else { int result = PyUnicode_Compare(s1, s2); if ((result == -1) && unlikely(PyErr_Occurred())) return -1; return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } } """) pybytes_equals_utility_code = UtilityCode( proto=""" static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ """, impl=""" static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { if (s1 == s2) { /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */ return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) { return (equals == Py_NE); } else if (PyBytes_GET_SIZE(s1) == 1) { if (equals == Py_EQ) return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]); else return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]); } else { int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1)); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } } """, requires=[Builtin.include_string_h_utility_code]) pystr_equals_utility_code = UtilityCode( proto=""" #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals #else #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif """, requires=[pybytes_equals_utility_code, pyunicode_equals_utility_code]) class PrimaryCmpNode(ExprNode, CmpNode): # Non-cascaded comparison or first comparison of # a cascaded sequence. # # operator string # operand1 ExprNode # operand2 ExprNode # cascade CascadedCmpNode # We don't use the subexprs mechanism, because # things here are too complicated for it to handle. # Instead, we override all the framework methods # which use it. child_attrs = ['operand1', 'operand2', 'cascade'] cascade = None def infer_type(self, env): # TODO: Actually implement this (after merging with -unstable). return py_object_type def type_dependencies(self, env): return () def calculate_constant_result(self): self.calculate_cascaded_constant_result(self.operand1.constant_result) def compile_time_value(self, denv): operand1 = self.operand1.compile_time_value(denv) return self.cascaded_compile_time_value(operand1, denv) def analyse_types(self, env): self.operand1.analyse_types(env) self.operand2.analyse_types(env) if self.is_cpp_comparison(): self.analyse_cpp_comparison(env) if self.cascade: error(self.pos, "Cascading comparison not yet supported for cpp types.") return if self.cascade: self.cascade.analyse_types(env) if self.operator in ('in', 'not_in'): if self.is_c_string_contains(): self.is_pycmp = False common_type = None if self.cascade: error(self.pos, "Cascading comparison not yet supported for 'int_val in string'.") return if self.operand2.type is unicode_type: env.use_utility_code(py_ucs4_in_unicode_utility_code) else: if self.operand1.type is PyrexTypes.c_uchar_type: self.operand1 = self.operand1.coerce_to(PyrexTypes.c_char_type, env) if self.operand2.type is not bytes_type: self.operand2 = self.operand2.coerce_to(bytes_type, env) env.use_utility_code(char_in_bytes_utility_code) self.operand2 = self.operand2.as_none_safe_node( "argument of type 'NoneType' is not iterable") elif self.is_ptr_contains(): if self.cascade: error(self.pos, "Cascading comparison not yet supported for 'val in sliced pointer'.") self.type = PyrexTypes.c_bint_type # Will be transformed by IterationTransform return else: if self.operand2.type is dict_type: self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") common_type = py_object_type self.is_pycmp = True elif self.find_special_bool_compare_function(env): common_type = None # if coercion needed, the method call above has already done it self.is_pycmp = False # result is bint self.is_temp = True # must check for error return else: common_type = self.find_common_type(env, self.operator, self.operand1) self.is_pycmp = common_type.is_pyobject if common_type is not None and not common_type.is_error: if self.operand1.type != common_type: self.operand1 = self.operand1.coerce_to(common_type, env) self.coerce_operands_to(common_type, env) if self.cascade: self.operand2 = self.operand2.coerce_to_simple(env) self.cascade.coerce_cascaded_operands_to_temp(env) if self.is_python_result(): self.type = PyrexTypes.py_object_type else: self.type = PyrexTypes.c_bint_type cdr = self.cascade while cdr: cdr.type = self.type cdr = cdr.cascade if self.is_pycmp or self.cascade: self.is_temp = 1 def analyse_cpp_comparison(self, env): type1 = self.operand1.type type2 = self.operand2.type entry = env.lookup_operator(self.operator, [self.operand1, self.operand2]) if entry is None: error(self.pos, "Invalid types for '%s' (%s, %s)" % (self.operator, type1, type2)) self.type = PyrexTypes.error_type self.result_code = "<error>" return func_type = entry.type if func_type.is_ptr: func_type = func_type.base_type if len(func_type.args) == 1: self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) else: self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) self.type = func_type.return_type def has_python_operands(self): return (self.operand1.type.is_pyobject or self.operand2.type.is_pyobject) def check_const(self): if self.cascade: self.not_const() return False else: return self.operand1.check_const() and self.operand2.check_const() def calculate_result_code(self): if self.operand1.type.is_complex: if self.operator == "!=": negation = "!" else: negation = "" return "(%s%s(%s, %s))" % ( negation, self.operand1.type.binary_op('=='), self.operand1.result(), self.operand2.result()) elif self.is_c_string_contains(): if self.operand2.type is unicode_type: method = "__Pyx_UnicodeContainsUCS4" else: method = "__Pyx_BytesContains" if self.operator == "not_in": negation = "!" else: negation = "" return "(%s%s(%s, %s))" % ( negation, method, self.operand2.result(), self.operand1.result()) else: return "(%s %s %s)" % ( self.operand1.result(), self.c_operator(self.operator), self.operand2.result()) def generate_evaluation_code(self, code): self.operand1.generate_evaluation_code(code) self.operand2.generate_evaluation_code(code) if self.is_temp: self.allocate_temp_result(code) self.generate_operation_code(code, self.result(), self.operand1, self.operator, self.operand2) if self.cascade: self.cascade.generate_evaluation_code(code, self.result(), self.operand2) self.operand1.generate_disposal_code(code) self.operand1.free_temps(code) self.operand2.generate_disposal_code(code) self.operand2.free_temps(code) def generate_subexpr_disposal_code(self, code): # If this is called, it is a non-cascaded cmp, # so only need to dispose of the two main operands. self.operand1.generate_disposal_code(code) self.operand2.generate_disposal_code(code) def free_subexpr_temps(self, code): # If this is called, it is a non-cascaded cmp, # so only need to dispose of the two main operands. self.operand1.free_temps(code) self.operand2.free_temps(code) def annotate(self, code): self.operand1.annotate(code) self.operand2.annotate(code) if self.cascade: self.cascade.annotate(code) class CascadedCmpNode(Node, CmpNode): # A CascadedCmpNode is not a complete expression node. It # hangs off the side of another comparison node, shares # its left operand with that node, and shares its result # with the PrimaryCmpNode at the head of the chain. # # operator string # operand2 ExprNode # cascade CascadedCmpNode child_attrs = ['operand2', 'cascade'] cascade = None constant_result = constant_value_not_set # FIXME: where to calculate this? def infer_type(self, env): # TODO: Actually implement this (after merging with -unstable). return py_object_type def type_dependencies(self, env): return () def has_constant_result(self): return self.constant_result is not constant_value_not_set and \ self.constant_result is not not_a_constant def analyse_types(self, env): self.operand2.analyse_types(env) if self.cascade: self.cascade.analyse_types(env) def has_python_operands(self): return self.operand2.type.is_pyobject def coerce_operands_to_pyobjects(self, env): self.operand2 = self.operand2.coerce_to_pyobject(env) if self.operand2.type is dict_type and self.operator in ('in', 'not_in'): self.operand2 = self.operand2.as_none_safe_node("'NoneType' object is not iterable") if self.cascade: self.cascade.coerce_operands_to_pyobjects(env) def coerce_cascaded_operands_to_temp(self, env): if self.cascade: #self.operand2 = self.operand2.coerce_to_temp(env) #CTT self.operand2 = self.operand2.coerce_to_simple(env) self.cascade.coerce_cascaded_operands_to_temp(env) def generate_evaluation_code(self, code, result, operand1): if self.type.is_pyobject: code.putln("if (__Pyx_PyObject_IsTrue(%s)) {" % result) code.put_decref(result, self.type) else: code.putln("if (%s) {" % result) self.operand2.generate_evaluation_code(code) self.generate_operation_code(code, result, operand1, self.operator, self.operand2) if self.cascade: self.cascade.generate_evaluation_code( code, result, self.operand2) # Cascaded cmp result is always temp self.operand2.generate_disposal_code(code) self.operand2.free_temps(code) code.putln("}") def annotate(self, code): self.operand2.annotate(code) if self.cascade: self.cascade.annotate(code) binop_node_classes = { "or": BoolBinopNode, "and": BoolBinopNode, "|": IntBinopNode, "^": IntBinopNode, "&": IntBinopNode, "<<": IntBinopNode, ">>": IntBinopNode, "+": AddNode, "-": SubNode, "*": MulNode, "/": DivNode, "//": DivNode, "%": ModNode, "**": PowNode } def binop_node(pos, operator, operand1, operand2, inplace=False): # Construct binop node of appropriate class for # given operator. return binop_node_classes[operator](pos, operator = operator, operand1 = operand1, operand2 = operand2, inplace = inplace) #------------------------------------------------------------------- # # Coercion nodes # # Coercion nodes are special in that they are created during # the analyse_types phase of parse tree processing. # Their __init__ methods consequently incorporate some aspects # of that phase. # #------------------------------------------------------------------- class CoercionNode(ExprNode): # Abstract base class for coercion nodes. # # arg ExprNode node being coerced subexprs = ['arg'] constant_result = not_a_constant def __init__(self, arg): self.pos = arg.pos self.arg = arg if debug_coercion: print("%s Coercing %s" % (self, self.arg)) def calculate_constant_result(self): # constant folding can break type coercion, so this is disabled pass def annotate(self, code): self.arg.annotate(code) if self.arg.type != self.type: file, line, col = self.pos code.annotate((file, line, col-1), AnnotationItem(style='coerce', tag='coerce', text='[%s] to [%s]' % (self.arg.type, self.type))) class CoerceToMemViewSliceNode(CoercionNode): def __init__(self, arg, dst_type, env): assert dst_type.is_memoryviewslice assert not arg.type.is_memoryviewslice CoercionNode.__init__(self, arg) self.type = dst_type self.is_temp = 1 self.env = env self.use_managed_ref = True self.arg = arg def generate_result_code(self, code): self.type.create_from_py_utility_code(self.env) code.putln("%s = %s(%s);" % (self.result(), self.type.from_py_function, self.arg.py_result())) error_cond = self.type.error_condition(self.result()) code.putln(code.error_goto_if(error_cond, self.pos)) class CastNode(CoercionNode): # Wrap a node in a C type cast. def __init__(self, arg, new_type): CoercionNode.__init__(self, arg) self.type = new_type def may_be_none(self): return self.arg.may_be_none() def calculate_result_code(self): return self.arg.result_as(self.type) def generate_result_code(self, code): self.arg.generate_result_code(code) class PyTypeTestNode(CoercionNode): # This node is used to check that a generic Python # object is an instance of a particular extension type. # This node borrows the result of its argument node. def __init__(self, arg, dst_type, env, notnone=False): # The arg is know to be a Python object, and # the dst_type is known to be an extension type. assert dst_type.is_extension_type or dst_type.is_builtin_type, "PyTypeTest on non extension type" CoercionNode.__init__(self, arg) self.type = dst_type self.result_ctype = arg.ctype() self.notnone = notnone nogil_check = Node.gil_error gil_message = "Python type test" def analyse_types(self, env): pass def may_be_none(self): if self.notnone: return False return self.arg.may_be_none() def is_simple(self): return self.arg.is_simple() def result_in_temp(self): return self.arg.result_in_temp() def is_ephemeral(self): return self.arg.is_ephemeral() def calculate_constant_result(self): # FIXME pass def calculate_result_code(self): return self.arg.result() def generate_result_code(self, code): if self.type.typeobj_is_available(): if not self.type.is_builtin_type: code.globalstate.use_utility_code(type_test_utility_code) code.putln( "if (!(%s)) %s" % ( self.type.type_test_code(self.arg.py_result(), self.notnone), code.error_goto(self.pos))) else: error(self.pos, "Cannot test type of extern C class " "without type object name specification") def generate_post_assignment_code(self, code): self.arg.generate_post_assignment_code(code) def free_temps(self, code): self.arg.free_temps(code) class NoneCheckNode(CoercionNode): # This node is used to check that a Python object is not None and # raises an appropriate exception (as specified by the creating # transform). def __init__(self, arg, exception_type_cname, exception_message, exception_format_args): CoercionNode.__init__(self, arg) self.type = arg.type self.result_ctype = arg.ctype() self.exception_type_cname = exception_type_cname self.exception_message = exception_message self.exception_format_args = tuple(exception_format_args or ()) def analyse_types(self, env): pass def may_be_none(self): return False def is_simple(self): return self.arg.is_simple() def result_in_temp(self): return self.arg.result_in_temp() def calculate_result_code(self): return self.arg.result() def generate_result_code(self, code): code.putln( "if (unlikely(%s == Py_None)) {" % self.arg.py_result()) escape = StringEncoding.escape_byte_string if self.exception_format_args: code.putln('PyErr_Format(%s, "%s", %s); %s ' % ( self.exception_type_cname, StringEncoding.escape_byte_string( self.exception_message.encode('UTF-8')), ', '.join([ '"%s"' % escape(str(arg).encode('UTF-8')) for arg in self.exception_format_args ]), code.error_goto(self.pos))) else: code.putln('PyErr_SetString(%s, "%s"); %s ' % ( self.exception_type_cname, escape(self.exception_message.encode('UTF-8')), code.error_goto(self.pos))) code.putln("}") def generate_post_assignment_code(self, code): self.arg.generate_post_assignment_code(code) def free_temps(self, code): self.arg.free_temps(code) class CoerceToPyTypeNode(CoercionNode): # This node is used to convert a C data type # to a Python object. type = py_object_type is_temp = 1 def __init__(self, arg, env, type=py_object_type): if not arg.type.create_to_py_utility_code(env): error(arg.pos, "Cannot convert '%s' to Python object" % arg.type) elif arg.type.is_complex: # special case: complex coercion is so complex that it # uses a macro ("__pyx_PyComplex_FromComplex()"), for # which the argument must be simple arg = arg.coerce_to_simple(env) CoercionNode.__init__(self, arg) if type is py_object_type: # be specific about some known types if arg.type.is_string: self.type = bytes_type elif arg.type.is_unicode_char: self.type = unicode_type elif arg.type.is_complex: self.type = Builtin.complex_type else: # FIXME: check that the target type and the resulting type are compatible pass if arg.type.is_memoryviewslice: # Register utility codes at this point arg.type.get_to_py_function(env, arg) self.env = env gil_message = "Converting to Python object" def may_be_none(self): # FIXME: is this always safe? return False def coerce_to_boolean(self, env): arg_type = self.arg.type if (arg_type == PyrexTypes.c_bint_type or (arg_type.is_pyobject and arg_type.name == 'bool')): return self.arg.coerce_to_temp(env) else: return CoerceToBooleanNode(self, env) def coerce_to_integer(self, env): # If not already some C integer type, coerce to longint. if self.arg.type.is_int: return self.arg else: return self.arg.coerce_to(PyrexTypes.c_long_type, env) def analyse_types(self, env): # The arg is always already analysed pass def generate_result_code(self, code): if self.arg.type.is_memoryviewslice: funccall = self.arg.type.get_to_py_function(self.env, self.arg) else: funccall = "%s(%s)" % (self.arg.type.to_py_function, self.arg.result()) code.putln('%s = %s; %s' % ( self.result(), funccall, code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.py_result()) class CoerceIntToBytesNode(CoerceToPyTypeNode): # This node is used to convert a C int type to a Python bytes # object. is_temp = 1 def __init__(self, arg, env): arg = arg.coerce_to_simple(env) CoercionNode.__init__(self, arg) self.type = Builtin.bytes_type def generate_result_code(self, code): arg = self.arg arg_result = arg.result() if arg.type not in (PyrexTypes.c_char_type, PyrexTypes.c_uchar_type, PyrexTypes.c_schar_type): if arg.type.signed: code.putln("if ((%s < 0) || (%s > 255)) {" % ( arg_result, arg_result)) else: code.putln("if (%s > 255) {" % arg_result) code.putln('PyErr_Format(PyExc_OverflowError, ' '"value too large to pack into a byte"); %s' % ( code.error_goto(self.pos))) code.putln('}') temp = None if arg.type is not PyrexTypes.c_char_type: temp = code.funcstate.allocate_temp(PyrexTypes.c_char_type, manage_ref=False) code.putln("%s = (char)%s;" % (temp, arg_result)) arg_result = temp code.putln('%s = PyBytes_FromStringAndSize(&%s, 1); %s' % ( self.result(), arg_result, code.error_goto_if_null(self.result(), self.pos))) if temp is not None: code.funcstate.release_temp(temp) code.put_gotref(self.py_result()) class CoerceFromPyTypeNode(CoercionNode): # This node is used to convert a Python object # to a C data type. def __init__(self, result_type, arg, env): CoercionNode.__init__(self, arg) self.type = result_type self.is_temp = 1 if not result_type.create_from_py_utility_code(env): error(arg.pos, "Cannot convert Python object to '%s'" % result_type) if self.type.is_string and self.arg.is_ephemeral(): error(arg.pos, "Obtaining char * from temporary Python value") def analyse_types(self, env): # The arg is always already analysed pass def generate_result_code(self, code): function = self.type.from_py_function operand = self.arg.py_result() rhs = "%s(%s)" % (function, operand) if self.type.is_enum: rhs = typecast(self.type, c_long_type, rhs) code.putln('%s = %s; %s' % ( self.result(), rhs, code.error_goto_if(self.type.error_condition(self.result()), self.pos))) if self.type.is_pyobject: code.put_gotref(self.py_result()) def nogil_check(self, env): error(self.pos, "Coercion from Python not allowed without the GIL") class CoerceToBooleanNode(CoercionNode): # This node is used when a result needs to be used # in a boolean context. type = PyrexTypes.c_bint_type _special_builtins = { Builtin.list_type : 'PyList_GET_SIZE', Builtin.tuple_type : 'PyTuple_GET_SIZE', Builtin.bytes_type : 'PyBytes_GET_SIZE', Builtin.unicode_type : 'PyUnicode_GET_SIZE', } def __init__(self, arg, env): CoercionNode.__init__(self, arg) if arg.type.is_pyobject: self.is_temp = 1 def nogil_check(self, env): if self.arg.type.is_pyobject and self._special_builtins.get(self.arg.type) is None: self.gil_error() gil_message = "Truth-testing Python object" def check_const(self): if self.is_temp: self.not_const() return False return self.arg.check_const() def calculate_result_code(self): return "(%s != 0)" % self.arg.result() def generate_result_code(self, code): if not self.is_temp: return test_func = self._special_builtins.get(self.arg.type) if test_func is not None: code.putln("%s = (%s != Py_None) && (%s(%s) != 0);" % ( self.result(), self.arg.py_result(), test_func, self.arg.py_result())) else: code.putln( "%s = __Pyx_PyObject_IsTrue(%s); %s" % ( self.result(), self.arg.py_result(), code.error_goto_if_neg(self.result(), self.pos))) class CoerceToComplexNode(CoercionNode): def __init__(self, arg, dst_type, env): if arg.type.is_complex: arg = arg.coerce_to_simple(env) self.type = dst_type CoercionNode.__init__(self, arg) dst_type.create_declaration_utility_code(env) def calculate_result_code(self): if self.arg.type.is_complex: real_part = "__Pyx_CREAL(%s)" % self.arg.result() imag_part = "__Pyx_CIMAG(%s)" % self.arg.result() else: real_part = self.arg.result() imag_part = "0" return "%s(%s, %s)" % ( self.type.from_parts, real_part, imag_part) def generate_result_code(self, code): pass class CoerceToTempNode(CoercionNode): # This node is used to force the result of another node # to be stored in a temporary. It is only used if the # argument node's result is not already in a temporary. def __init__(self, arg, env): CoercionNode.__init__(self, arg) self.type = self.arg.type self.constant_result = self.arg.constant_result self.is_temp = 1 if self.type.is_pyobject: self.result_ctype = py_object_type gil_message = "Creating temporary Python reference" def analyse_types(self, env): # The arg is always already analysed pass def coerce_to_boolean(self, env): self.arg = self.arg.coerce_to_boolean(env) if self.arg.is_simple(): return self.arg self.type = self.arg.type self.result_ctype = self.type return self def generate_result_code(self, code): #self.arg.generate_evaluation_code(code) # Already done # by generic generate_subexpr_evaluation_code! code.putln("%s = %s;" % ( self.result(), self.arg.result_as(self.ctype()))) if self.type.is_pyobject and self.use_managed_ref: code.put_incref(self.result(), self.ctype()) class CloneNode(CoercionNode): # This node is employed when the result of another node needs # to be used multiple times. The argument node's result must # be in a temporary. This node "borrows" the result from the # argument node, and does not generate any evaluation or # disposal code for it. The original owner of the argument # node is responsible for doing those things. subexprs = [] # Arg is not considered a subexpr nogil_check = None def __init__(self, arg): CoercionNode.__init__(self, arg) if hasattr(arg, 'type'): self.type = arg.type self.result_ctype = arg.result_ctype if hasattr(arg, 'entry'): self.entry = arg.entry def result(self): return self.arg.result() def may_be_none(self): return self.arg.may_be_none() def type_dependencies(self, env): return self.arg.type_dependencies(env) def infer_type(self, env): return self.arg.infer_type(env) def analyse_types(self, env): self.type = self.arg.type self.result_ctype = self.arg.result_ctype self.is_temp = 1 if hasattr(self.arg, 'entry'): self.entry = self.arg.entry def is_simple(self): return True # result is always in a temp (or a name) def generate_evaluation_code(self, code): pass def generate_result_code(self, code): pass def generate_disposal_code(self, code): pass def free_temps(self, code): pass class CMethodSelfCloneNode(CloneNode): # Special CloneNode for the self argument of builtin C methods # that accepts subtypes of the builtin type. This is safe only # for 'final' subtypes, as subtypes of the declared type may # override the C method. def coerce_to(self, dst_type, env): if dst_type.is_builtin_type and self.type.subtype_of(dst_type): return self return CloneNode.coerce_to(self, dst_type, env) class ModuleRefNode(ExprNode): # Simple returns the module object type = py_object_type is_temp = False subexprs = [] def analyse_types(self, env): pass def may_be_none(self): return False def calculate_result_code(self): return Naming.module_cname def generate_result_code(self, code): pass class DocstringRefNode(ExprNode): # Extracts the docstring of the body element subexprs = ['body'] type = py_object_type is_temp = True def __init__(self, pos, body): ExprNode.__init__(self, pos) assert body.type.is_pyobject self.body = body def analyse_types(self, env): pass def generate_result_code(self, code): code.putln('%s = __Pyx_GetAttrString(%s, "__doc__"); %s' % ( self.result(), self.body.result(), code.error_goto_if_null(self.result(), self.pos))) code.put_gotref(self.result()) #------------------------------------------------------------------------------------ # # Runtime support code # #------------------------------------------------------------------------------------ get_name_interned_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ """, impl = """ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); if (!result) { if (dict != %(BUILTINS)s) { PyErr_Clear(); result = PyObject_GetAttr(%(BUILTINS)s, name); } if (!result) { PyErr_SetObject(PyExc_NameError, name); } } return result; } """ % {'BUILTINS' : Naming.builtins_cname}) #------------------------------------------------------------------------------------ import_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ """, impl = """ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { PyObject *py_import = 0; PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; py_import = __Pyx_GetAttrString(%(BUILTINS)s, "__import__"); if (!py_import) goto bad; if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(%(GLOBALS)s); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; #if PY_VERSION_HEX >= 0x02050000 { PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); } #else if (level>0) { PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); goto bad; } module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, NULL); #endif bad: Py_XDECREF(empty_list); Py_XDECREF(py_import); Py_XDECREF(empty_dict); return module; } """ % { "BUILTINS": Naming.builtins_cname, "GLOBALS": Naming.module_cname, }) #------------------------------------------------------------------------------------ get_exception_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_GetExcValue(void); /*proto*/ """, impl = """ static PyObject *__Pyx_GetExcValue(void) { PyObject *type = 0, *value = 0, *tb = 0; PyObject *tmp_type, *tmp_value, *tmp_tb; PyObject *result = 0; PyThreadState *tstate = PyThreadState_Get(); PyErr_Fetch(&type, &value, &tb); PyErr_NormalizeException(&type, &value, &tb); if (PyErr_Occurred()) goto bad; if (!value) { value = Py_None; Py_INCREF(value); } tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; /* Make sure tstate is in a consistent state when we XDECREF these objects (XDECREF may run arbitrary code). */ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); result = value; Py_XINCREF(result); type = 0; value = 0; tb = 0; bad: Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(tb); return result; } """) #------------------------------------------------------------------------------------ type_test_utility_code = UtilityCode( proto = """ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ """, impl = """ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_Format(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } """) #------------------------------------------------------------------------------------ find_py2_metaclass_utility_code = UtilityCode( proto = ''' static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/ ''', impl = ''' static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) { PyObject *metaclass; /* Default metaclass */ #if PY_MAJOR_VERSION < 3 if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { PyObject *base = PyTuple_GET_ITEM(bases, 0); metaclass = PyObject_GetAttrString(base, (char *)"__class__"); if (!metaclass) { PyErr_Clear(); metaclass = (PyObject*) Py_TYPE(base); } } else { metaclass = (PyObject *) &PyClass_Type; } #else if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { PyObject *base = PyTuple_GET_ITEM(bases, 0); metaclass = (PyObject*) Py_TYPE(base); } else { metaclass = (PyObject *) &PyType_Type; } #endif Py_INCREF(metaclass); return metaclass; } ''') create_class_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, PyObject *modname); /*proto*/ """, impl = """ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, PyObject *modname) { PyObject *result; PyObject *metaclass; if (PyDict_SetItemString(dict, "__module__", modname) < 0) return NULL; /* Python2 __metaclass__ */ metaclass = PyDict_GetItemString(dict, "__metaclass__"); if (metaclass) { Py_INCREF(metaclass); } else { metaclass = __Pyx_FindPy2Metaclass(bases); } result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL); Py_DECREF(metaclass); return result; } """, requires = [find_py2_metaclass_utility_code]) #------------------------------------------------------------------------------------ create_py3class_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*/ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw); /*proto*/ """, impl = """ PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw) { PyObject *metaclass = PyDict_GetItemString(mkw, "metaclass"); if (metaclass) { Py_INCREF(metaclass); if (PyDict_DelItemString(mkw, "metaclass") < 0) { Py_DECREF(metaclass); return NULL; } return metaclass; } return __Pyx_FindPy2Metaclass(bases); } PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *prep; PyObject *pargs; PyObject *ns; PyObject *str; prep = PyObject_GetAttrString(metaclass, (char *)"__prepare__"); if (!prep) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) return NULL; PyErr_Clear(); return PyDict_New(); } pargs = PyTuple_New(2); if (!pargs) { Py_DECREF(prep); return NULL; } Py_INCREF(name); Py_INCREF(bases); PyTuple_SET_ITEM(pargs, 0, name); PyTuple_SET_ITEM(pargs, 1, bases); ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); if (ns == NULL) return NULL; /* Required here to emulate assignment order */ /* XXX: use consts here */ #if PY_MAJOR_VERSION >= 3 str = PyUnicode_FromString("__module__"); #else str = PyString_FromString("__module__"); #endif if (!str) { Py_DECREF(ns); return NULL; } if (PyObject_SetItem(ns, str, modname) < 0) { Py_DECREF(ns); Py_DECREF(str); return NULL; } Py_DECREF(str); if (doc) { #if PY_MAJOR_VERSION >= 3 str = PyUnicode_FromString("__doc__"); #else str = PyString_FromString("__doc__"); #endif if (!str) { Py_DECREF(ns); return NULL; } if (PyObject_SetItem(ns, str, doc) < 0) { Py_DECREF(ns); Py_DECREF(str); return NULL; } Py_DECREF(str); } return ns; } PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw) { PyObject *result; PyObject *margs = PyTuple_New(3); if (!margs) return NULL; Py_INCREF(name); Py_INCREF(bases); Py_INCREF(dict); PyTuple_SET_ITEM(margs, 0, name); PyTuple_SET_ITEM(margs, 1, bases); PyTuple_SET_ITEM(margs, 2, dict); result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); return result; } """, requires = [find_py2_metaclass_utility_code]) #------------------------------------------------------------------------------------ cpp_exception_utility_code = UtilityCode( proto = """ #ifndef __Pyx_CppExn2PyErr static void __Pyx_CppExn2PyErr() { // Catch a handful of different errors here and turn them into the // equivalent Python errors. try { if (PyErr_Occurred()) ; // let the latest Python exn pass through and ignore the current one else throw; } catch (const std::bad_alloc& exn) { PyErr_SetString(PyExc_MemoryError, exn.what()); } catch (const std::bad_cast& exn) { PyErr_SetString(PyExc_TypeError, exn.what()); } catch (const std::domain_error& exn) { PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::invalid_argument& exn) { PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::ios_base::failure& exn) { // Unfortunately, in standard C++ we have no way of distinguishing EOF // from other errors here; be careful with the exception mask PyErr_SetString(PyExc_IOError, exn.what()); } catch (const std::out_of_range& exn) { // Change out_of_range to IndexError PyErr_SetString(PyExc_IndexError, exn.what()); } catch (const std::overflow_error& exn) { PyErr_SetString(PyExc_OverflowError, exn.what()); } catch (const std::range_error& exn) { PyErr_SetString(PyExc_ArithmeticError, exn.what()); } catch (const std::underflow_error& exn) { PyErr_SetString(PyExc_ArithmeticError, exn.what()); } catch (const std::exception& exn) { PyErr_SetString(PyExc_RuntimeError, exn.what()); } catch (...) { PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); } } #endif """, impl = "" ) pyerr_occurred_withgil_utility_code= UtilityCode( proto = """ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */ """, impl = """ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) { int err; #ifdef WITH_THREAD PyGILState_STATE _save = PyGILState_Ensure(); #endif err = !!PyErr_Occurred(); #ifdef WITH_THREAD PyGILState_Release(_save); #endif return err; } """ ) #------------------------------------------------------------------------------------ raise_noneattr_error_utility_code = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseNoneAttributeError(const char* attrname); """, impl = ''' static CYTHON_INLINE void __Pyx_RaiseNoneAttributeError(const char* attrname) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", attrname); } ''') raise_noneindex_error_utility_code = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void); """, impl = ''' static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable"); } ''') raise_none_iter_error_utility_code = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); """, impl = ''' static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } ''') raise_unbound_local_error_utility_code = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); """, impl = """ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } """) raise_closure_name_error_utility_code = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); """, impl = """ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); } """) #------------------------------------------------------------------------------------ getitem_dict_utility_code = UtilityCode( proto = """ #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; if (unlikely(d == Py_None)) { __Pyx_RaiseNoneIndexingError(); return NULL; } value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) PyErr_SetObject(PyExc_KeyError, key); return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif """, requires = [raise_noneindex_error_utility_code]) #------------------------------------------------------------------------------------ getitem_int_pyunicode_utility_code = UtilityCode( proto = ''' #define __Pyx_GetItemInt_Unicode(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ __Pyx_GetItemInt_Unicode_Fast(o, i) : \\ __Pyx_GetItemInt_Unicode_Generic(o, to_py_func(i))) static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i) { const Py_ssize_t length = __Pyx_PyUnicode_GET_LENGTH(ustring); if (likely((0 <= i) & (i < length))) { return __Pyx_PyUnicode_READ_CHAR(ustring, i); } else if ((-length <= i) & (i < 0)) { return __Pyx_PyUnicode_READ_CHAR(ustring, i + length); } else { PyErr_SetString(PyExc_IndexError, "string index out of range"); return (Py_UCS4)-1; } } static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring, PyObject* j) { Py_UCS4 uchar; PyObject *uchar_string; if (!j) return (Py_UCS4)-1; uchar_string = PyObject_GetItem(ustring, j); Py_DECREF(j); if (!uchar_string) return (Py_UCS4)-1; uchar = __Pyx_PyUnicode_READ_CHAR(uchar_string, 0); Py_DECREF(uchar_string); return uchar; } ''') getitem_int_utility_code = UtilityCode( proto = """ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } """ + ''.join([ """ #define __Pyx_GetItemInt_%(type)s(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ __Pyx_GetItemInt_%(type)s_Fast(o, i) : \\ __Pyx_GetItemInt_Generic(o, to_py_func(i))) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_%(type)s_Fast(PyObject *o, Py_ssize_t i) { if (likely(o != Py_None)) { if (likely((0 <= i) & (i < Py%(type)s_GET_SIZE(o)))) { PyObject *r = Py%(type)s_GET_ITEM(o, i); Py_INCREF(r); return r; } else if ((-Py%(type)s_GET_SIZE(o) <= i) & (i < 0)) { PyObject *r = Py%(type)s_GET_ITEM(o, Py%(type)s_GET_SIZE(o) + i); Py_INCREF(r); return r; } } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } """ % {'type' : type_name} for type_name in ('List', 'Tuple') ]) + """ #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ __Pyx_GetItemInt_Fast(o, i) : \\ __Pyx_GetItemInt_Generic(o, to_py_func(i))) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) { PyObject *r; if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) { r = PyList_GET_ITEM(o, i); Py_INCREF(r); } else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); } else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) { r = PySequence_GetItem(o, i); } else { r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } return r; } """, impl = """ """) #------------------------------------------------------------------------------------ setitem_int_utility_code = UtilityCode( proto = """ #define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ __Pyx_SetItemInt_Fast(o, i, v) : \\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v)) static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (!j) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) { if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) { Py_INCREF(v); Py_DECREF(PyList_GET_ITEM(o, i)); PyList_SET_ITEM(o, i, v); return 1; } else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0))) return PySequence_SetItem(o, i, v); else { PyObject *j = PyInt_FromSsize_t(i); return __Pyx_SetItemInt_Generic(o, j, v); } } """, impl = """ """) #------------------------------------------------------------------------------------ delitem_int_utility_code = UtilityCode( proto = """ #define __Pyx_DelItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ __Pyx_DelItemInt_Fast(o, i) : \\ __Pyx_DelItem_Generic(o, to_py_func(i))) static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) { int r; if (!j) return -1; r = PyObject_DelItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i) { if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && likely(i >= 0)) return PySequence_DelItem(o, i); else { PyObject *j = PyInt_FromSsize_t(i); return __Pyx_DelItem_Generic(o, j); } } """, impl = """ """) #------------------------------------------------------------------------------------ raise_too_many_values_to_unpack = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); """, impl = ''' static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected); } ''') raise_need_more_values_to_unpack = UtilityCode( proto = """ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); """, impl = ''' static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack", index, (index == 1) ? "" : "s"); } ''') #------------------------------------------------------------------------------------ tuple_unpacking_error_code = UtilityCode( proto = """ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/ """, impl = """ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { if (t == Py_None) { __Pyx_RaiseNoneNotIterableError(); } else if (PyTuple_GET_SIZE(t) < index) { __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); } else { __Pyx_RaiseTooManyValuesError(index); } } """, requires = [raise_none_iter_error_utility_code, raise_need_more_values_to_unpack, raise_too_many_values_to_unpack] ) unpacking_utility_code = UtilityCode( proto = """ static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/ """, impl = """ static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) { PyObject *item; if (!(item = PyIter_Next(iter))) { if (!PyErr_Occurred()) { __Pyx_RaiseNeedMoreValuesError(index); } } return item; } """, requires = [raise_need_more_values_to_unpack] ) iternext_unpacking_end_utility_code = UtilityCode( proto = """ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ """, impl = """ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; } """, requires = [raise_too_many_values_to_unpack] ) #------------------------------------------------------------------------------------ # CPython supports calling functions with non-dict kwargs by # converting them to a dict first kwargs_call_utility_code = UtilityCode( proto = """ static PyObject* __Pyx_PyEval_CallObjectWithKeywords(PyObject*, PyObject*, PyObject*); /*proto*/ """, impl = """ static PyObject* __Pyx_PyEval_CallObjectWithKeywords(PyObject *callable, PyObject *args, PyObject *kwargs) { PyObject* result; if (likely(PyDict_Check(kwargs))) { return PyEval_CallObjectWithKeywords(callable, args, kwargs); } else { PyObject* real_dict; real_dict = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, kwargs, NULL); if (unlikely(!real_dict)) return NULL; result = PyEval_CallObjectWithKeywords(callable, args, real_dict); Py_DECREF(real_dict); return result; /* may be NULL */ } } """, ) #------------------------------------------------------------------------------------ int_pow_utility_code = UtilityCode( proto=""" static CYTHON_INLINE %(type)s %(func_name)s(%(type)s, %(type)s); /* proto */ """, impl=""" static CYTHON_INLINE %(type)s %(func_name)s(%(type)s b, %(type)s e) { %(type)s t = b; switch (e) { case 3: t *= b; case 2: t *= b; case 1: return t; case 0: return 1; } if (unlikely(e<0)) return 0; t = 1; while (likely(e)) { t *= (b * (e&1)) | ((~e)&1); /* 1 or b */ b *= b; e >>= 1; } return t; } """) # ------------------------------ Division ------------------------------------ div_int_utility_code = UtilityCode( proto=""" static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s, %(type)s); /* proto */ """, impl=""" static CYTHON_INLINE %(type)s __Pyx_div_%(type_name)s(%(type)s a, %(type)s b) { %(type)s q = a / b; %(type)s r = a - q*b; q -= ((r != 0) & ((r ^ b) < 0)); return q; } """) mod_int_utility_code = UtilityCode( proto=""" static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */ """, impl=""" static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) { %(type)s r = a %% b; r += ((r != 0) & ((r ^ b) < 0)) * b; return r; } """) mod_float_utility_code = UtilityCode( proto=""" static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s, %(type)s); /* proto */ """, impl=""" static CYTHON_INLINE %(type)s __Pyx_mod_%(type_name)s(%(type)s a, %(type)s b) { %(type)s r = fmod%(math_h_modifier)s(a, b); r += ((r != 0) & ((r < 0) ^ (b < 0))) * b; return r; } """) cdivision_warning_utility_code = UtilityCode( proto=""" static int __Pyx_cdivision_warning(const char *, int); /* proto */ """, impl=""" static int __Pyx_cdivision_warning(const char *filename, int lineno) { return PyErr_WarnExplicit(PyExc_RuntimeWarning, "division with oppositely signed operands, C and Python semantics differ", filename, lineno, __Pyx_MODULE_NAME, NULL); } """) # from intobject.c division_overflow_test_code = UtilityCode( proto=""" #define UNARY_NEG_WOULD_OVERFLOW(x) \ (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) """) binding_cfunc_utility_code = UtilityCode( proto=""" #define __Pyx_CyFunction_USED 1 #include <structmember.h> typedef struct { PyCFunctionObject func; PyObject *func_dict; PyObject *func_weakreflist; PyObject *func_name; PyObject *func_doc; PyObject *func_code; } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; static PyObject *__Pyx_CyFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module, PyObject* code); static int __Pyx_CyFunction_init(void); """ % Naming.__dict__, impl=""" static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (op->func_doc == NULL && op->func.m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); #else op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); #endif } if (op->func_doc == 0) { Py_INCREF(Py_None); return Py_None; } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp = op->func_doc; if (value == NULL) op->func_doc = Py_None; /* Mark as deleted */ else op->func_doc = value; Py_INCREF(op->func_doc); Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) { if (op->func_name == NULL) { #if PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); #else op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); #endif } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (value == NULL || !PyUnicode_Check(value)) { #else if (value == NULL || !PyString_Check(value)) { #endif PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) { PyObject *self; self = m->func.m_self; if (self == NULL) self = Py_None; Py_INCREF(self); return self; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) { if (op->func_dict == NULL) { op->func_dict = PyDict_New(); if (op->func_dict == NULL) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; if (value == NULL) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; } """ + ( # TODO: we implicitly use the global module to get func_globals. This # will need to be passed into __Pyx_CyFunction_NewEx() if we share # this type accross modules. We currently avoid doing this to reduce # the overhead of creating a function object, and to avoid keeping a # reference to the module dict as long as we don't need to. """ static PyObject * __Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op) { PyObject* dict = PyModule_GetDict(%(module_cname)s); Py_XINCREF(dict); return dict; } """ % Naming.__dict__ ) + """ static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {0, 0, 0, 0, 0} }; #ifndef PY_WRITE_RESTRICTED /* < Py2.5 */ #define PY_WRITE_RESTRICTED WRITE_RESTRICTED #endif static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(m->func.m_ml->ml_name); #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; static PyObject *__Pyx_CyFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType); if (op == NULL) return NULL; op->func_weakreflist = NULL; op->func.m_ml = ml; Py_XINCREF(self); op->func.m_self = self; Py_XINCREF(module); op->func.m_module = module; op->func_dict = NULL; op->func_name = NULL; op->func_doc = NULL; Py_XINCREF(code); op->func_code = code; PyObject_GC_Track(op); return (PyObject *)op; } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); if (m->func_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) m); Py_XDECREF(m->func.m_self); Py_XDECREF(m->func.m_module); Py_XDECREF(m->func_dict); Py_XDECREF(m->func_name); Py_XDECREF(m->func_doc); Py_XDECREF(m->func_code); PyObject_GC_Del(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func.m_self); Py_VISIT(m->func.m_module); Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_doc); Py_VISIT(m->func_code); return 0; } static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) { if (obj == Py_None) obj = NULL; return PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { PyObject *func_name = __Pyx_CyFunction_get_name(op); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("<cyfunction %U at %p>", func_name, op); #else return PyString_FromFormat("<cyfunction %s at %p>", PyString_AsString(func_name), op); #endif } static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/ sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #else 0, /*reserved*/ #endif (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ PyCFunction_Call, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/ 0, /*tp_doc*/ (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_CyFunction_methods, /*tp_methods*/ __pyx_CyFunction_members, /*tp_members*/ __pyx_CyFunction_getsets, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ __Pyx_CyFunction_descr_get, /*tp_descr_get*/ 0, /*tp_descr_set*/ offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ 0, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif }; static int __Pyx_CyFunction_init(void) { if (PyType_Ready(&__pyx_CyFunctionType_type) < 0) return -1; __pyx_CyFunctionType = &__pyx_CyFunctionType_type; return 0; } """) generator_utility_code = UtilityCode( proto=""" static PyObject *__Pyx_Generator_Next(PyObject *self); static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value); static PyObject *__Pyx_Generator_Close(PyObject *self); static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args, CYTHON_UNUSED PyObject *kwds); typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *); """, impl=""" static CYTHON_INLINE void __Pyx_Generator_ExceptionClear(struct __pyx_Generator_object *self) { Py_XDECREF(self->exc_type); Py_XDECREF(self->exc_value); Py_XDECREF(self->exc_traceback); self->exc_type = NULL; self->exc_value = NULL; self->exc_traceback = NULL; } static CYTHON_INLINE PyObject *__Pyx_Generator_SendEx(struct __pyx_Generator_object *self, PyObject *value) { PyObject *retval; if (self->is_running) { PyErr_SetString(PyExc_ValueError, "generator already executing"); return NULL; } if (self->resume_label == 0) { if (value && value != Py_None) { PyErr_SetString(PyExc_TypeError, "can't send non-None value to a " "just-started generator"); return NULL; } } if (self->resume_label == -1) { PyErr_SetNone(PyExc_StopIteration); return NULL; } if (value) __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback); else __Pyx_Generator_ExceptionClear(self); self->is_running = 1; retval = self->body((PyObject *) self, value); self->is_running = 0; if (retval) __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback); else __Pyx_Generator_ExceptionClear(self); return retval; } static PyObject *__Pyx_Generator_Next(PyObject *self) { return __Pyx_Generator_SendEx((struct __pyx_Generator_object *) self, Py_None); } static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) { return __Pyx_Generator_SendEx((struct __pyx_Generator_object *) self, value); } static PyObject *__Pyx_Generator_Close(PyObject *self) { struct __pyx_Generator_object *generator = (struct __pyx_Generator_object *) self; PyObject *retval; #if PY_VERSION_HEX < 0x02050000 PyErr_SetNone(PyExc_StopIteration); #else PyErr_SetNone(PyExc_GeneratorExit); #endif retval = __Pyx_Generator_SendEx(generator, NULL); if (retval) { Py_DECREF(retval); PyErr_SetString(PyExc_RuntimeError, "generator ignored GeneratorExit"); return NULL; } #if PY_VERSION_HEX < 0x02050000 if (PyErr_ExceptionMatches(PyExc_StopIteration)) #else if (PyErr_ExceptionMatches(PyExc_StopIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) #endif { PyErr_Clear(); /* ignore these errors */ Py_INCREF(Py_None); return Py_None; } return NULL; } static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args, CYTHON_UNUSED PyObject *kwds) { struct __pyx_Generator_object *generator = (struct __pyx_Generator_object *) self; PyObject *typ; PyObject *tb = NULL; PyObject *val = NULL; if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) return NULL; __Pyx_Raise(typ, val, tb, NULL); return __Pyx_Generator_SendEx(generator, NULL); } """, proto_block='utility_code_proto_before_types', requires=[Nodes.raise_utility_code, Nodes.swap_exception_utility_code], )
hpfem/cython
Cython/Compiler/ExprNodes.py
Python
apache-2.0
371,587
[ "VisIt" ]
0e9a2408ff9dabd687f401ca1f111fb3d8b2865e286f4b17f4f37dd0eeb0d663
# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # # Copyright (c) 2008-2013 Raoul Snyman # # Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # # Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # # Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # # Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # # Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # # Frode Woldsund, Martin Zibricky, Patrick Zimmermann # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # # Software Foundation; version 2 of the License. # # # # This program is distributed in the hope that it will be useful, but WITHOUT # # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # # more details. # # # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate from openlp.core.lib.ui import create_button_box from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB class Ui_EditBibleDialog(object): def setupUi(self, edit_bible_dialog): edit_bible_dialog.setObjectName('edit_bible_dialog') edit_bible_dialog.resize(520, 400) edit_bible_dialog.setWindowIcon(build_icon(':/icon/openlp-logo-16x16.png')) edit_bible_dialog.setModal(True) self.dialog_layout = QtGui.QVBoxLayout(edit_bible_dialog) self.dialog_layout.setSpacing(8) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setObjectName('dialog_layout') self.bible_tab_widget = QtGui.QTabWidget(edit_bible_dialog) self.bible_tab_widget.setObjectName('BibleTabWidget') # Meta tab self.meta_tab = QtGui.QWidget() self.meta_tab.setObjectName('meta_tab') self.meta_tab_layout = QtGui.QVBoxLayout(self.meta_tab) self.meta_tab_layout.setObjectName('meta_tab_layout') self.license_details_group_box = QtGui.QGroupBox(self.meta_tab) self.license_details_group_box.setObjectName('license_details_group_box') self.license_details_layout = QtGui.QFormLayout(self.license_details_group_box) self.license_details_layout.setObjectName('license_details_layout') self.version_name_label = QtGui.QLabel(self.license_details_group_box) self.version_name_label.setObjectName('version_name_label') self.version_name_edit = QtGui.QLineEdit(self.license_details_group_box) self.version_name_edit.setObjectName('version_name_edit') self.version_name_label.setBuddy(self.version_name_edit) self.license_details_layout.addRow(self.version_name_label, self.version_name_edit) self.copyright_label = QtGui.QLabel(self.license_details_group_box) self.copyright_label.setObjectName('copyright_label') self.copyright_edit = QtGui.QLineEdit(self.license_details_group_box) self.copyright_edit.setObjectName('copyright_edit') self.copyright_label.setBuddy(self.copyright_edit) self.license_details_layout.addRow(self.copyright_label, self.copyright_edit) self.permissions_label = QtGui.QLabel(self.license_details_group_box) self.permissions_label.setObjectName('permissions_label') self.permissions_edit = QtGui.QLineEdit(self.license_details_group_box) self.permissions_edit.setObjectName('permissions_edit') self.permissions_label.setBuddy(self.permissions_edit) self.license_details_layout.addRow(self.permissions_label, self.permissions_edit) self.meta_tab_layout.addWidget(self.license_details_group_box) self.language_selection_group_box = QtGui.QGroupBox(self.meta_tab) self.language_selection_group_box.setObjectName('language_selection_group_box') self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box) self.language_selection_label = QtGui.QLabel(self.language_selection_group_box) self.language_selection_label.setObjectName('language_selection_label') self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box) self.language_selection_combo_box.setObjectName('language_selection_combo_box') self.language_selection_combo_box.addItems(['', '', '', '']) self.language_selection_layout.addWidget(self.language_selection_label) self.language_selection_layout.addWidget(self.language_selection_combo_box) self.meta_tab_layout.addWidget(self.language_selection_group_box) self.meta_tab_layout.addStretch() self.bible_tab_widget.addTab(self.meta_tab, '') # Book name tab self.book_name_tab = QtGui.QWidget() self.book_name_tab.setObjectName('book_name_tab') self.book_name_tab_layout = QtGui.QVBoxLayout(self.book_name_tab) self.book_name_tab_layout.setObjectName('book_name_tab_layout') self.book_name_notice = QtGui.QLabel(self.book_name_tab) self.book_name_notice.setObjectName('book_name_notice') self.book_name_notice.setWordWrap(True) self.book_name_tab_layout.addWidget(self.book_name_notice) self.scroll_area = QtGui.QScrollArea(self.book_name_tab) self.scroll_area.setWidgetResizable(True) self.scroll_area.setObjectName('scroll_area') self.scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.book_name_widget = QtGui.QWidget(self.scroll_area) self.book_name_widget.setObjectName('book_name_widget') self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget) self.book_name_widget_layout.setObjectName('book_name_widget_layout') self.book_name_label = {} self.book_name_edit= {} for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']] = QtGui.QLabel(self.book_name_widget) self.book_name_label[book['abbreviation']].setObjectName('book_name_label[%s]' % book['abbreviation']) self.book_name_edit[book['abbreviation']] = QtGui.QLineEdit(self.book_name_widget) self.book_name_edit[book['abbreviation']].setObjectName('book_name_edit[%s]' % book['abbreviation']) self.book_name_widget_layout.addRow( self.book_name_label[book['abbreviation']], self.book_name_edit[book['abbreviation']]) self.scroll_area.setWidget(self.book_name_widget) self.book_name_tab_layout.addWidget(self.scroll_area) self.book_name_tab_layout.addStretch() self.bible_tab_widget.addTab(self.book_name_tab, '') # Last few bits self.dialog_layout.addWidget(self.bible_tab_widget) self.button_box = create_button_box(edit_bible_dialog, 'button_box', ['cancel', 'save']) self.dialog_layout.addWidget(self.button_box) self.retranslateUi(edit_bible_dialog) QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog) def retranslateUi(self, edit_bible_dialog): self.book_names = BibleStrings().BookNames edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) # Meta tab self.bible_tab_widget.setTabText( self.bible_tab_widget.indexOf(self.meta_tab), translate('SongsPlugin.EditBibleForm', 'Meta Data')) self.license_details_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details')) self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:')) self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:')) self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:')) self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language')) self.language_selection_label.setText(translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and on display:')) self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1, translate('BiblesPlugin.EditBibleForm', 'Bible Language')) self.language_selection_combo_box.setItemText(LanguageSelection.Application + 1, translate('BiblesPlugin.EditBibleForm', 'Application Language')) self.language_selection_combo_box.setItemText(LanguageSelection.English + 1, translate('BiblesPlugin.EditBibleForm', 'English')) # Book name tab self.bible_tab_widget.setTabText(self.bible_tab_widget.indexOf(self.book_name_tab), translate('SongsPlugin.EditBibleForm', 'Custom Book Names')) for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']].setText('%s:' % str(self.book_names[book['abbreviation']]))
marmyshev/item_title
openlp/plugins/bibles/forms/editbibledialog.py
Python
gpl-2.0
10,299
[ "Brian" ]
bc08fd0479ecf8723c5314b40b0f944bbbe98dc13789681c245bd224cbf26306
class SWRLObjectVisitor(object): """Marker class""" def visit(self, node): """ :param node: an object of one of the following classes: - owlapy.model.SWRLRule - owlapy.model.SWRLClassAtom - owlapy.model.SWRLDataRangeAtom - owlapy.model.SWRLObjectPropertyAtom - owlapy.model.SWRLDataPropertyAtom - owlapy.model.SWRLBuiltInAtom - owlapy.model.SWRLVariable - owlapy.model.SWRLIndividualArgument - owlapy.model.SWRLLiteralArgument - owlapy.model.SWRLSameIndividualAtom - owlapy.model.SWRLDifferentIndividualsAtom """ raise NotImplementedError() class SWRLObjectVisitorEx(object): """Marker class""" def visit(self, node): """ :param node: an object of one of the following classes: - owlapy.model.SWRLRule - owlapy.model.SWRLClassAtom - owlapy.model.SWRLDataRangeAtom - owlapy.model.SWRLObjectPropertyAtom - owlapy.model.SWRLDataPropertyAtom - owlapy.model.SWRLBuiltInAtom - owlapy.model.SWRLVariable - owlapy.model.SWRLIndividualArgument - owlapy.model.SWRLLiteralArgument - owlapy.model.SWRLSameIndividualAtom - owlapy.model.SWRLDifferentIndividualsAtom """ raise NotImplementedError()
patrickwestphal/owlapy
owlapy/model/swrlobjectvisitor.py
Python
gpl-3.0
1,432
[ "VisIt" ]
945075352134a62810c170932c2bc5005c677a92b1f9f1419daaf89ffbb18397
#!/usr/bin/env python # coding: utf-8 # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tool for uploading diffs from a version control system to the codereview app. Usage summary: upload.py [options] [-- diff_options] [path...] Diff options are passed to the diff command of the underlying system. Supported version control systems: Git Mercurial Subversion Perforce CVS It is important for Git/Mercurial users to specify a tree/node/branch to diff against by using the '--rev' option. """ # This code is derived from appcfg.py in the App Engine SDK (open source), # and from ASPN recipe #146306. import BaseHTTPServer import ConfigParser import cookielib import errno import fnmatch import getpass import logging import marshal import mimetypes import optparse import os import re import socket import subprocess import sys import urllib import urllib2 import urlparse import webbrowser from multiprocessing.pool import ThreadPool # The md5 module was deprecated in Python 2.5. try: from hashlib import md5 except ImportError: from md5 import md5 try: import readline except ImportError: pass try: import keyring except ImportError: keyring = None # The logging verbosity: # 0: Errors only. # 1: Status messages. # 2: Info logs. # 3: Debug logs. verbosity = 1 LOGGER = logging.getLogger('upload') # The account type used for authentication. # This line could be changed by the review server (see handler for # upload.py). AUTH_ACCOUNT_TYPE = "GOOGLE" # URL of the default review server. As for AUTH_ACCOUNT_TYPE, this line could be # changed by the review server (see handler for upload.py). DEFAULT_REVIEW_SERVER = "codereview.appspot.com" # Max size of patch or base file. MAX_UPLOAD_SIZE = 900 * 1024 # Constants for version control names. Used by GuessVCSName. VCS_GIT = "Git" VCS_MERCURIAL = "Mercurial" VCS_SUBVERSION = "Subversion" VCS_PERFORCE = "Perforce" VCS_CVS = "CVS" VCS_UNKNOWN = "Unknown" VCS = [ { 'name': VCS_MERCURIAL, 'aliases': ['hg', 'mercurial'], }, { 'name': VCS_SUBVERSION, 'aliases': ['svn', 'subversion'], }, { 'name': VCS_PERFORCE, 'aliases': ['p4', 'perforce'], }, { 'name': VCS_GIT, 'aliases': ['git'], }, { 'name': VCS_CVS, 'aliases': ['cvs'], }] VCS_SHORT_NAMES = [] # hg, svn, ... VCS_ABBREVIATIONS = {} # alias: name, ... for vcs in VCS: VCS_SHORT_NAMES.append(min(vcs['aliases'], key=len)) VCS_ABBREVIATIONS.update((alias, vcs['name']) for alias in vcs['aliases']) # OAuth 2.0-Related Constants LOCALHOST_IP = '127.0.0.1' DEFAULT_OAUTH2_PORT = 8001 ACCESS_TOKEN_PARAM = 'access_token' ERROR_PARAM = 'error' OAUTH_DEFAULT_ERROR_MESSAGE = 'OAuth 2.0 error occurred.' OAUTH_PATH = '/get-access-token' OAUTH_PATH_PORT_TEMPLATE = OAUTH_PATH + '?port=%(port)d' AUTH_HANDLER_RESPONSE = """\ <html> <head> <title>Authentication Status</title> <script> window.onload = function() { window.close(); } </script> </head> <body> <p>The authentication flow has completed.</p> </body> </html> """ # Borrowed from google-api-python-client OPEN_LOCAL_MESSAGE_TEMPLATE = """\ Your browser has been opened to visit: %s If your browser is on a different machine then exit and re-run upload.py with the command-line parameter --no_oauth2_webbrowser """ NO_OPEN_LOCAL_MESSAGE_TEMPLATE = """\ Go to the following link in your browser: %s and copy the access token. """ # The result of parsing Subversion's [auto-props] setting. svn_auto_props_map = None def GetEmail(prompt): """Prompts the user for their email address and returns it. The last used email address is saved to a file and offered up as a suggestion to the user. If the user presses enter without typing in anything the last used email address is used. If the user enters a new address, it is saved for next time we prompt. """ last_email_file_name = os.path.expanduser("~/.last_codereview_email_address") last_email = "" if os.path.exists(last_email_file_name): try: last_email_file = open(last_email_file_name, "r") last_email = last_email_file.readline().strip("\n") last_email_file.close() prompt += " [%s]" % last_email except IOError as e: pass email = raw_input(prompt + ": ").strip() if email: try: last_email_file = open(last_email_file_name, "w") last_email_file.write(email) last_email_file.close() except IOError as e: pass else: email = last_email return email def StatusUpdate(msg): """Print a status message to stdout. If 'verbosity' is greater than 0, print the message. Args: msg: The string to print. """ if verbosity > 0: print msg def ErrorExit(msg): """Print an error message to stderr and exit.""" sys.stderr.write(msg) sys.stderr.write('\n') sys.exit(1) class ClientLoginError(urllib2.HTTPError): """Raised to indicate there was an error authenticating with ClientLogin.""" def __init__(self, url, code, msg, headers, args): urllib2.HTTPError.__init__(self, url, code, msg, headers, None) self.args = args self._reason = args["Error"] self.info = args.get("Info", None) @property def reason(self): # reason is a property on python 2.7 but a member variable on <=2.6. # self.args is modified so it cannot be used as-is so save the value in # self._reason. return self._reason class AbstractRpcServer(object): """Provides a common interface for a simple RPC server.""" def __init__(self, host, auth_function, host_override=None, extra_headers=None, save_cookies=False, account_type=AUTH_ACCOUNT_TYPE): """Creates a new AbstractRpcServer. Args: host: The host to send requests to. auth_function: A function that takes no arguments and returns an (email, password) tuple when called. Will be called if authentication is required. host_override: The host header to send to the server (defaults to host). extra_headers: A dict of extra headers to append to every request. save_cookies: If True, save the authentication cookies to local disk. If False, use an in-memory cookiejar instead. Subclasses must implement this functionality. Defaults to False. account_type: Account type used for authentication. Defaults to AUTH_ACCOUNT_TYPE. """ self.host = host if (not self.host.startswith("http://") and not self.host.startswith("https://")): self.host = "http://" + self.host self.host_override = host_override self.auth_function = auth_function self.authenticated = False self.extra_headers = extra_headers or {} self.save_cookies = save_cookies self.account_type = account_type self.opener = self._GetOpener() if self.host_override: LOGGER.info("Server: %s; Host: %s", self.host, self.host_override) else: LOGGER.info("Server: %s", self.host) def _GetOpener(self): """Returns an OpenerDirector for making HTTP requests. Returns: A urllib2.OpenerDirector object. """ raise NotImplementedError() def _CreateRequest(self, url, data=None): """Creates a new urllib request.""" LOGGER.debug("Creating request for: '%s' with payload:\n%s", url, data) req = urllib2.Request(url, data=data, headers={"Accept": "text/plain"}) if self.host_override: req.add_header("Host", self.host_override) for key, value in self.extra_headers.iteritems(): req.add_header(key, value) return req def _GetAuthToken(self, email, password): """Uses ClientLogin to authenticate the user, returning an auth token. Args: email: The user's email address password: The user's password Raises: ClientLoginError: If there was an error authenticating with ClientLogin. HTTPError: If there was some other form of HTTP error. Returns: The authentication token returned by ClientLogin. """ account_type = self.account_type if self.host.endswith(".google.com"): # Needed for use inside Google. account_type = "HOSTED" req = self._CreateRequest( url="https://www.google.com/accounts/ClientAuth", data=urllib.urlencode({ "Email": email, "Passwd": password, "service": "ah", "source": "rietveld-codereview-upload", "accountType": account_type, }), ) try: response = self.opener.open(req) response_body = response.read() response_dict = dict(x.split("=") for x in response_body.split("\n") if x) return response_dict["Auth"] except urllib2.HTTPError as e: if e.code == 403: body = e.read() response_dict = dict(x.split("=", 1) for x in body.split("\n") if x) raise ClientLoginError(req.get_full_url(), e.code, e.msg, e.headers, response_dict) else: raise def _GetAuthCookie(self, auth_token): """Fetches authentication cookies for an authentication token. Args: auth_token: The authentication token returned by ClientLogin. Raises: HTTPError: If there was an error fetching the authentication cookies. """ # This is a dummy value to allow us to identify when we're successful. continue_location = "http://localhost/" args = {"continue": continue_location, "auth": auth_token} req = self._CreateRequest("%s/_ah/login?%s" % (self.host, urllib.urlencode(args))) try: response = self.opener.open(req) except urllib2.HTTPError as e: response = e if (response.code != 302 or response.info()["location"] != continue_location): raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg, response.headers, response.fp) self.authenticated = True def _Authenticate(self): """Authenticates the user. The authentication process works as follows: 1) We get a username and password from the user 2) We use ClientLogin to obtain an AUTH token for the user (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). 3) We pass the auth token to /_ah/login on the server to obtain an authentication cookie. If login was successful, it tries to redirect us to the URL we provided. If we attempt to access the upload API without first obtaining an authentication cookie, it returns a 401 response (or a 302) and directs us to authenticate ourselves with ClientLogin. """ for i in range(3): credentials = self.auth_function() try: auth_token = self._GetAuthToken(credentials[0], credentials[1]) except ClientLoginError as e: sys.stderr.write('\n') if e.reason == "BadAuthentication": if e.info == "InvalidSecondFactor": sys.stderr.write( "Use an application-specific password instead " "of your regular account password.\n" "See http://www.google.com/" "support/accounts/bin/answer.py?answer=185833\n") else: sys.stderr.write("Invalid username or password.\n") elif e.reason == "CaptchaRequired": sys.stderr.write( "Please go to\n" "https://www.google.com/accounts/DisplayUnlockCaptcha\n" "and verify you are a human. Then try again.\n" "If you are using a Google Apps account the URL is:\n" "https://www.google.com/a/yourdomain.com/UnlockCaptcha\n") elif e.reason == "NotVerified": sys.stderr.write("Account not verified.\n") elif e.reason == "TermsNotAgreed": sys.stderr.write("User has not agreed to TOS.\n") elif e.reason == "AccountDeleted": sys.stderr.write("The user account has been deleted.\n") elif e.reason == "AccountDisabled": sys.stderr.write("The user account has been disabled.\n") break elif e.reason == "ServiceDisabled": sys.stderr.write("The user's access to the service has been " "disabled.\n") elif e.reason == "ServiceUnavailable": sys.stderr.write("The service is not available; try again later.\n") else: # Unknown error. raise sys.stderr.write('\n') continue self._GetAuthCookie(auth_token) return def Send(self, request_path, payload=None, content_type="application/octet-stream", timeout=None, extra_headers=None, **kwargs): """Sends an RPC and returns the response. Args: request_path: The path to send the request to, eg /api/appversion/create. payload: The body of the request, or None to send an empty request. content_type: The Content-Type header to use. timeout: timeout in seconds; default None i.e. no timeout. (Note: for large requests on OS X, the timeout doesn't work right.) extra_headers: Dict containing additional HTTP headers that should be included in the request (string header names mapped to their values), or None to not include any additional headers. kwargs: Any keyword arguments are converted into query string parameters. Returns: The response body, as a string. """ # TODO: Don't require authentication. Let the server say # whether it is necessary. if not self.authenticated and self.auth_function: self._Authenticate() old_timeout = socket.getdefaulttimeout() socket.setdefaulttimeout(timeout) try: tries = 0 while True: tries += 1 args = dict(kwargs) url = "%s%s" % (self.host, request_path) if args: url += "?" + urllib.urlencode(args) req = self._CreateRequest(url=url, data=payload) req.add_header("Content-Type", content_type) if extra_headers: for header, value in extra_headers.items(): req.add_header(header, value) try: f = self.opener.open(req, timeout=70) response = f.read() f.close() return response except urllib2.HTTPError as e: if tries > 3: raise elif e.code == 401 or e.code == 302: if not self.auth_function: raise self._Authenticate() elif e.code == 301: # Handle permanent redirect manually. url = e.info()["location"] url_loc = urlparse.urlparse(url) self.host = '%s://%s' % (url_loc[0], url_loc[1]) elif e.code >= 500: # TODO: We should error out on a 500, but the server is too flaky # for that at the moment. StatusUpdate('Upload got a 500 response: %d' % e.code) else: raise finally: socket.setdefaulttimeout(old_timeout) class HttpRpcServer(AbstractRpcServer): """Provides a simplified RPC-style interface for HTTP requests.""" def _Authenticate(self): """Save the cookie jar after authentication.""" if isinstance(self.auth_function, OAuth2Creds): access_token = self.auth_function() if access_token is not None: self.extra_headers['Authorization'] = 'OAuth %s' % (access_token,) self.authenticated = True else: super(HttpRpcServer, self)._Authenticate() if self.save_cookies: StatusUpdate("Saving authentication cookies to %s" % self.cookie_file) self.cookie_jar.save() def _GetOpener(self): """Returns an OpenerDirector that supports cookies and ignores redirects. Returns: A urllib2.OpenerDirector object. """ opener = urllib2.OpenerDirector() opener.add_handler(urllib2.ProxyHandler()) opener.add_handler(urllib2.UnknownHandler()) opener.add_handler(urllib2.HTTPHandler()) opener.add_handler(urllib2.HTTPDefaultErrorHandler()) opener.add_handler(urllib2.HTTPSHandler()) opener.add_handler(urllib2.HTTPErrorProcessor()) if self.save_cookies: self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies") self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file) if os.path.exists(self.cookie_file): try: self.cookie_jar.load() self.authenticated = True StatusUpdate("Loaded authentication cookies from %s" % self.cookie_file) except (cookielib.LoadError, IOError): # Failed to load cookies - just ignore them. pass else: # Create an empty cookie file with mode 600 fd = os.open(self.cookie_file, os.O_CREAT, 0o600) os.close(fd) # Always chmod the cookie file os.chmod(self.cookie_file, 0o600) else: # Don't save cookies across runs of update.py. self.cookie_jar = cookielib.CookieJar() opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar)) return opener class CondensedHelpFormatter(optparse.IndentedHelpFormatter): """Frees more horizontal space by removing indentation from group options and collapsing arguments between short and long, e.g. '-o ARG, --opt=ARG' to -o --opt ARG""" def format_heading(self, heading): return "%s:\n" % heading def format_option(self, option): self.dedent() res = optparse.HelpFormatter.format_option(self, option) self.indent() return res def format_option_strings(self, option): self.set_long_opt_delimiter(" ") optstr = optparse.HelpFormatter.format_option_strings(self, option) optlist = optstr.split(", ") if len(optlist) > 1: if option.takes_value(): # strip METAVAR from all but the last option optlist = [x.split()[0] for x in optlist[:-1]] + optlist[-1:] optstr = " ".join(optlist) return optstr parser = optparse.OptionParser( usage=("%prog [options] [-- diff_options] [path...]\n" "See also: https://github.com/rietveld-codereview/rietveld/wiki/upload.py-Usage"), add_help_option=False, formatter=CondensedHelpFormatter() ) parser.add_option("-h", "--help", action="store_true", help="Show this help message and exit.") parser.add_option("-y", "--assume_yes", action="store_true", dest="assume_yes", default=False, help="Assume that the answer to yes/no questions is 'yes'.") # Logging group = parser.add_option_group("Logging options") group.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="Print errors only.") group.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=1, help="Print info level logs.") group.add_option("--noisy", action="store_const", const=3, dest="verbose", help="Print all logs.") group.add_option("--print_diffs", dest="print_diffs", action="store_true", help="Print full diffs.") # Review server group = parser.add_option_group("Review server options") group.add_option("-s", "--server", action="store", dest="server", default=DEFAULT_REVIEW_SERVER, metavar="SERVER", help=("The server to upload to. The format is host[:port]. " "Defaults to '%default'.")) group.add_option("-e", "--email", action="store", dest="email", metavar="EMAIL", default=None, help="The username to use. Will prompt if omitted.") group.add_option("-H", "--host", action="store", dest="host", metavar="HOST", default=None, help="Overrides the Host header sent with all RPCs.") group.add_option("--no_cookies", action="store_false", dest="save_cookies", default=True, help="Do not save authentication cookies to local disk.") group.add_option("--oauth2", action="store_true", dest="use_oauth2", default=False, help="Use OAuth 2.0 instead of a password.") group.add_option("--oauth2_port", action="store", type="int", dest="oauth2_port", default=DEFAULT_OAUTH2_PORT, help=("Port to use to handle OAuth 2.0 redirect. Must be an " "integer in the range 1024-49151, defaults to " "'%default'.")) group.add_option("--no_oauth2_webbrowser", action="store_false", dest="open_oauth2_local_webbrowser", default=True, help="Don't open a browser window to get an access token.") group.add_option("--account_type", action="store", dest="account_type", metavar="TYPE", default=AUTH_ACCOUNT_TYPE, choices=["GOOGLE", "HOSTED"], help=("Override the default account type " "(defaults to '%default', " "valid choices are 'GOOGLE' and 'HOSTED').")) group.add_option("-j", "--number-parallel-uploads", dest="num_upload_threads", default=8, help="Number of uploads to do in parallel.") # Issue group = parser.add_option_group("Issue options") group.add_option("-t", "--title", action="store", dest="title", help="New issue subject or new patch set title") group.add_option("-m", "--message", action="store", dest="message", default=None, help="New issue description or new patch set message") group.add_option("-F", "--file", action="store", dest="file", default=None, help="Read the message above from file.") group.add_option("-r", "--reviewers", action="store", dest="reviewers", metavar="REVIEWERS", default=None, help="Add reviewers (comma separated email addresses).") group.add_option("--cc", action="store", dest="cc", metavar="CC", default=None, help="Add CC (comma separated email addresses).") group.add_option("--private", action="store_true", dest="private", default=False, help="Make the issue restricted to reviewers and those CCed") # Upload options group = parser.add_option_group("Patch options") group.add_option("-i", "--issue", type="int", action="store", metavar="ISSUE", default=None, help="Issue number to which to add. Defaults to new issue.") group.add_option("--base_url", action="store", dest="base_url", default=None, help="Base URL path for files (listed as \"Base URL\" when " "viewing issue). If omitted, will be guessed automatically " "for SVN repos and left blank for others.") group.add_option("--download_base", action="store_true", dest="download_base", default=False, help="Base files will be downloaded by the server " "(side-by-side diffs may not work on files with CRs).") group.add_option("--rev", action="store", dest="revision", metavar="REV", default=None, help="Base revision/branch/tree to diff against. Use " "rev1:rev2 range to review already committed changeset.") group.add_option("--send_mail", action="store_true", dest="send_mail", default=False, help="Send notification email to reviewers.") group.add_option("-p", "--send_patch", action="store_true", dest="send_patch", default=False, help="Same as --send_mail, but include diff as an " "attachment, and prepend email subject with 'PATCH:'.") group.add_option("--vcs", action="store", dest="vcs", metavar="VCS", default=None, help=("Explicitly specify version control system (%s)" % ", ".join(VCS_SHORT_NAMES))) group.add_option("--emulate_svn_auto_props", action="store_true", dest="emulate_svn_auto_props", default=False, help=("Emulate Subversion's auto properties feature.")) # Git-specific group = parser.add_option_group("Git-specific options") group.add_option("--git_similarity", action="store", dest="git_similarity", metavar="SIM", type="int", default=50, help=("Set the minimum similarity percentage for detecting " "renames and copies. See `git diff -C`. (default 50).")) group.add_option("--git_only_search_patch", action="store_false", default=True, dest='git_find_copies_harder', help="Removes --find-copies-harder when seaching for copies") group.add_option("--git_no_find_copies", action="store_false", default=True, dest="git_find_copies", help=("Prevents git from looking for copies (default off).")) # Perforce-specific group = parser.add_option_group("Perforce-specific options " "(overrides P4 environment variables)") group.add_option("--p4_port", action="store", dest="p4_port", metavar="P4_PORT", default=None, help=("Perforce server and port (optional)")) group.add_option("--p4_changelist", action="store", dest="p4_changelist", metavar="P4_CHANGELIST", default=None, help=("Perforce changelist id")) group.add_option("--p4_client", action="store", dest="p4_client", metavar="P4_CLIENT", default=None, help=("Perforce client/workspace")) group.add_option("--p4_user", action="store", dest="p4_user", metavar="P4_USER", default=None, help=("Perforce user")) # OAuth 2.0 Methods and Helpers class ClientRedirectServer(BaseHTTPServer.HTTPServer): """A server for redirects back to localhost from the associated server. Waits for a single request and parses the query parameters for an access token or an error and then stops serving. """ access_token = None error = None class ClientRedirectHandler(BaseHTTPServer.BaseHTTPRequestHandler): """A handler for redirects back to localhost from the associated server. Waits for a single request and parses the query parameters into the server's access_token or error and then stops serving. """ def SetResponseValue(self): """Stores the access token or error from the request on the server. Will only do this if exactly one query parameter was passed in to the request and that query parameter used 'access_token' or 'error' as the key. """ query_string = urlparse.urlparse(self.path).query query_params = urlparse.parse_qs(query_string) if len(query_params) == 1: if ACCESS_TOKEN_PARAM in query_params: access_token_list = query_params[ACCESS_TOKEN_PARAM] if len(access_token_list) == 1: self.server.access_token = access_token_list[0] else: error_list = query_params.get(ERROR_PARAM, []) if len(error_list) == 1: self.server.error = error_list[0] def do_GET(self): """Handle a GET request. Parses and saves the query parameters and prints a message that the server has completed its lone task (handling a redirect). Note that we can't detect if an error occurred. """ self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.SetResponseValue() self.wfile.write(AUTH_HANDLER_RESPONSE) def log_message(self, format, *args): """Do not log messages to stdout while running as command line program.""" pass def OpenOAuth2ConsentPage(server=DEFAULT_REVIEW_SERVER, port=DEFAULT_OAUTH2_PORT): """Opens the OAuth 2.0 consent page or prints instructions how to. Uses the webbrowser module to open the OAuth server side page in a browser. Args: server: String containing the review server URL. Defaults to DEFAULT_REVIEW_SERVER. port: Integer, the port where the localhost server receiving the redirect is serving. Defaults to DEFAULT_OAUTH2_PORT. Returns: A boolean indicating whether the page opened successfully. """ path = OAUTH_PATH_PORT_TEMPLATE % {'port': port} parsed_url = urlparse.urlparse(server) scheme = parsed_url[0] or 'https' if scheme != 'https': ErrorExit('Using OAuth requires a review server with SSL enabled.') # If no scheme was given on command line the server address ends up in # parsed_url.path otherwise in netloc. host = parsed_url[1] or parsed_url[2] page = '%s://%s%s' % (scheme, host, path) page_opened = webbrowser.open(page, new=1, autoraise=True) if page_opened: print OPEN_LOCAL_MESSAGE_TEMPLATE % (page,) return page_opened def WaitForAccessToken(port=DEFAULT_OAUTH2_PORT): """Spins up a simple HTTP Server to handle a single request. Intended to handle a single redirect from the production server after the user authenticated via OAuth 2.0 with the server. Args: port: Integer, the port where the localhost server receiving the redirect is serving. Defaults to DEFAULT_OAUTH2_PORT. Returns: The access token passed to the localhost server, or None if no access token was passed. """ httpd = ClientRedirectServer((LOCALHOST_IP, port), ClientRedirectHandler) # Wait to serve just one request before deferring control back # to the caller of wait_for_refresh_token httpd.handle_request() if httpd.access_token is None: ErrorExit(httpd.error or OAUTH_DEFAULT_ERROR_MESSAGE) return httpd.access_token def GetAccessToken(server=DEFAULT_REVIEW_SERVER, port=DEFAULT_OAUTH2_PORT, open_local_webbrowser=True): """Gets an Access Token for the current user. Args: server: String containing the review server URL. Defaults to DEFAULT_REVIEW_SERVER. port: Integer, the port where the localhost server receiving the redirect is serving. Defaults to DEFAULT_OAUTH2_PORT. open_local_webbrowser: Boolean, defaults to True. If set, opens a page in the user's browser. Returns: A string access token that was sent to the local server. If the serving page via WaitForAccessToken does not receive an access token, this method returns None. """ access_token = None if open_local_webbrowser: page_opened = OpenOAuth2ConsentPage(server=server, port=port) if page_opened: try: access_token = WaitForAccessToken(port=port) except socket.error as e: print 'Can\'t start local webserver. Socket Error: %s\n' % (e.strerror,) if access_token is None: # TODO(dhermes): Offer to add to clipboard using xsel, xclip, pbcopy, etc. page = 'https://%s%s' % (server, OAUTH_PATH) print NO_OPEN_LOCAL_MESSAGE_TEMPLATE % (page,) access_token = raw_input('Enter access token: ').strip() return access_token class KeyringCreds(object): def __init__(self, server, host, email): self.server = server # Explicitly cast host to str to work around bug in old versions of Keyring # (versions before 0.10). Even though newer versions of Keyring fix this, # some modern linuxes (such as Ubuntu 12.04) still bundle a version with # the bug. self.host = str(host) self.email = email self.accounts_seen = set() def GetUserCredentials(self): """Prompts the user for a username and password. Only use keyring on the initial call. If the keyring contains the wrong password, we want to give the user a chance to enter another one. """ # Create a local alias to the email variable to avoid Python's crazy # scoping rules. global keyring email = self.email if email is None: email = GetEmail("Email (login for uploading to %s)" % self.server) password = None if keyring and not email in self.accounts_seen: try: password = keyring.get_password(self.host, email) except: # Sadly, we have to trap all errors here as # gnomekeyring.IOError inherits from object. :/ print "Failed to get password from keyring" keyring = None if password is not None: print "Using password from system keyring." self.accounts_seen.add(email) else: password = getpass.getpass("Password for %s: " % email) if keyring: answer = raw_input("Store password in system keyring?(y/N) ").strip() if answer == "y": keyring.set_password(self.host, email, password) self.accounts_seen.add(email) return (email, password) class OAuth2Creds(object): """Simple object to hold server and port to be passed to GetAccessToken.""" def __init__(self, server, port, open_local_webbrowser=True): self.server = server self.port = port self.open_local_webbrowser = open_local_webbrowser def __call__(self): """Uses stored server and port to retrieve OAuth 2.0 access token.""" return GetAccessToken(server=self.server, port=self.port, open_local_webbrowser=self.open_local_webbrowser) def GetRpcServer(server, email=None, host_override=None, save_cookies=True, account_type=AUTH_ACCOUNT_TYPE, use_oauth2=False, oauth2_port=DEFAULT_OAUTH2_PORT, open_oauth2_local_webbrowser=True): """Returns an instance of an AbstractRpcServer. Args: server: String containing the review server URL. email: String containing user's email address. host_override: If not None, string containing an alternate hostname to use in the host header. save_cookies: Whether authentication cookies should be saved to disk. account_type: Account type for authentication, either 'GOOGLE' or 'HOSTED'. Defaults to AUTH_ACCOUNT_TYPE. use_oauth2: Boolean indicating whether OAuth 2.0 should be used for authentication. oauth2_port: Integer, the port where the localhost server receiving the redirect is serving. Defaults to DEFAULT_OAUTH2_PORT. open_oauth2_local_webbrowser: Boolean, defaults to True. If True and using OAuth, this opens a page in the user's browser to obtain a token. Returns: A new HttpRpcServer, on which RPC calls can be made. """ # If this is the dev_appserver, use fake authentication. host = (host_override or server).lower() if re.match(r'(http://)?localhost([:/]|$)', host): if email is None: email = "test@example.com" LOGGER.info("Using debug user %s. Override with --email" % email) server = HttpRpcServer( server, lambda: (email, "password"), host_override=host_override, extra_headers={"Cookie": 'dev_appserver_login="%s:False"' % email}, save_cookies=save_cookies, account_type=account_type) # Don't try to talk to ClientLogin. server.authenticated = True return server positional_args = [server] if use_oauth2: positional_args.append( OAuth2Creds(server, oauth2_port, open_oauth2_local_webbrowser)) else: positional_args.append(KeyringCreds(server, host, email).GetUserCredentials) return HttpRpcServer(*positional_args, host_override=host_override, save_cookies=save_cookies, account_type=account_type) def EncodeMultipartFormData(fields, files): """Encode form fields for multipart/form-data. Args: fields: A sequence of (name, value) elements for regular form fields. files: A sequence of (name, filename, value) elements for data to be uploaded as files. Returns: (content_type, body) ready for httplib.HTTP instance. Source: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 """ BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-' CRLF = '\r\n' lines = [] for (key, value) in fields: lines.append('--' + BOUNDARY) lines.append('Content-Disposition: form-data; name="%s"' % key) lines.append('') if isinstance(value, unicode): value = value.encode('utf-8') lines.append(value) for (key, filename, value) in files: lines.append('--' + BOUNDARY) lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename)) lines.append('Content-Type: %s' % GetContentType(filename)) lines.append('') if isinstance(value, unicode): value = value.encode('utf-8') lines.append(value) lines.append('--' + BOUNDARY + '--') lines.append('') body = CRLF.join(lines) content_type = 'multipart/form-data; boundary=%s' % BOUNDARY return content_type, body def GetContentType(filename): """Helper to guess the content-type from the filename.""" return mimetypes.guess_type(filename)[0] or 'application/octet-stream' # Use a shell for subcommands on Windows to get a PATH search. use_shell = sys.platform.startswith("win") def RunShellWithReturnCodeAndStderr(command, print_output=False, universal_newlines=True, env=os.environ): """Executes a command and returns the output from stdout, stderr and the return code. Args: command: Command to execute. print_output: If True, the output is printed to stdout. If False, both stdout and stderr are ignored. universal_newlines: Use universal_newlines flag (default: True). Returns: Tuple (stdout, stderr, return code) """ LOGGER.info("Running %s", command) env = env.copy() env['LC_MESSAGES'] = 'C' p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=use_shell, universal_newlines=universal_newlines, env=env) if print_output: output_array = [] while True: line = p.stdout.readline() if not line: break print line.strip("\n") output_array.append(line) output = "".join(output_array) else: output = p.stdout.read() p.wait() errout = p.stderr.read() if print_output and errout: sys.stderr.write(errout + '\n') p.stdout.close() p.stderr.close() return output, errout, p.returncode def RunShellWithReturnCode(command, print_output=False, universal_newlines=True, env=os.environ): """Executes a command and returns the output from stdout and the return code.""" out, err, retcode = RunShellWithReturnCodeAndStderr(command, print_output, universal_newlines, env) return out, retcode def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False, env=os.environ): data, retcode = RunShellWithReturnCode(command, print_output, universal_newlines, env) if retcode: ErrorExit("Got error status from %s:\n%s" % (command, data)) if not silent_ok and not data: ErrorExit("No output from %s" % command) return data class VersionControlSystem(object): """Abstract base class providing an interface to the VCS.""" def __init__(self, options): """Constructor. Args: options: Command line options. """ self.options = options def GetGUID(self): """Return string to distinguish the repository from others, for example to query all opened review issues for it""" raise NotImplementedError( "abstract method -- subclass %s must override" % self.__class__) def PostProcessDiff(self, diff): """Return the diff with any special post processing this VCS needs, e.g. to include an svn-style "Index:".""" return diff def GenerateDiff(self, args): """Return the current diff as a string. Args: args: Extra arguments to pass to the diff command. """ raise NotImplementedError( "abstract method -- subclass %s must override" % self.__class__) def GetUnknownFiles(self): """Return a list of files unknown to the VCS.""" raise NotImplementedError( "abstract method -- subclass %s must override" % self.__class__) def CheckForUnknownFiles(self): """Show an "are you sure?" prompt if there are unknown files.""" unknown_files = self.GetUnknownFiles() if unknown_files: print "The following files are not added to version control:" for line in unknown_files: print line prompt = "Are you sure to continue?(y/N) " answer = raw_input(prompt).strip() if answer != "y": ErrorExit("User aborted") def GetBaseFile(self, filename): """Get the content of the upstream version of a file. Returns: A tuple (base_content, new_content, is_binary, status) base_content: The contents of the base file. new_content: For text files, this is empty. For binary files, this is the contents of the new file, since the diff output won't contain information to reconstruct the current file. is_binary: True iff the file is binary. status: The status of the file. """ raise NotImplementedError( "abstract method -- subclass %s must override" % self.__class__) def GetBaseFiles(self, diff): """Helper that calls GetBase file for each file in the patch. Returns: A dictionary that maps from filename to GetBaseFile's tuple. Filenames are retrieved based on lines that start with "Index:" or "Property changes on:". """ files = {} for line in diff.splitlines(True): if line.startswith('Index:') or line.startswith('Property changes on:'): unused, filename = line.split(':', 1) # On Windows if a file has property changes its filename uses '\' # instead of '/'. filename = filename.strip().replace('\\', '/') files[filename] = self.GetBaseFile(filename) return files def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options, files): """Uploads the base files (and if necessary, the current ones as well).""" def UploadFile(filename, file_id, content, is_binary, status, is_base): """Uploads a file to the server.""" file_too_large = False if is_base: type = "base" else: type = "current" if len(content) > MAX_UPLOAD_SIZE: result = ("Not uploading the %s file for %s because it's too large." % (type, filename)) file_too_large = True content = "" elif options.verbose: result = "Uploading %s file for %s" % (type, filename) checksum = md5(content).hexdigest() url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id) form_fields = [("filename", filename), ("status", status), ("checksum", checksum), ("is_binary", str(is_binary)), ("is_current", str(not is_base)), ] if file_too_large: form_fields.append(("file_too_large", "1")) if options.email: form_fields.append(("user", options.email)) ctype, body = EncodeMultipartFormData(form_fields, [("data", filename, content)]) try: response_body = rpc_server.Send(url, body, content_type=ctype) except urllib2.HTTPError as e: response_body = ("Failed to upload file for %s. Got %d status code." % (filename, e.code)) if not response_body.startswith("OK"): StatusUpdate(" --> %s" % response_body) sys.exit(1) return result patches = dict() [patches.setdefault(v, k) for k, v in patch_list] threads = [] thread_pool = ThreadPool(options.num_upload_threads) for filename in patches.keys(): base_content, new_content, is_binary, status = files[filename] file_id_str = patches.get(filename) if file_id_str.find("nobase") != -1: base_content = None file_id_str = file_id_str[file_id_str.rfind("_") + 1:] file_id = int(file_id_str) if base_content != None: t = thread_pool.apply_async(UploadFile, args=(filename, file_id, base_content, is_binary, status, True)) threads.append(t) if new_content != None: t = thread_pool.apply_async(UploadFile, args=(filename, file_id, new_content, is_binary, status, False)) threads.append(t) for t in threads: print t.get(timeout=60) def IsImage(self, filename): """Returns true if the filename has an image extension.""" mimetype = mimetypes.guess_type(filename)[0] if not mimetype: return False return mimetype.startswith("image/") and not mimetype.startswith("image/svg") def IsBinaryData(self, data): """Returns true if data contains a null byte.""" # Derived from how Mercurial's heuristic, see # http://selenic.com/hg/file/848a6658069e/mercurial/util.py#l229 return bool(data and "\0" in data) class SubversionVCS(VersionControlSystem): """Implementation of the VersionControlSystem interface for Subversion.""" def __init__(self, options): super(SubversionVCS, self).__init__(options) if self.options.revision: match = re.match(r"(\d+)(:(\d+))?", self.options.revision) if not match: ErrorExit("Invalid Subversion revision %s." % self.options.revision) self.rev_start = match.group(1) self.rev_end = match.group(3) else: self.rev_start = self.rev_end = None # Cache output from "svn list -r REVNO dirname". # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev). self.svnls_cache = {} # Base URL is required to fetch files deleted in an older revision. # Result is cached to not guess it over and over again in GetBaseFile(). required = self.options.download_base or self.options.revision is not None self.svn_base = self._GuessBase(required) def GetGUID(self): return self._GetInfo("Repository UUID") def GuessBase(self, required): """Wrapper for _GuessBase.""" return self.svn_base def _GuessBase(self, required): """Returns base URL for current diff. Args: required: If true, exits if the url can't be guessed, otherwise None is returned. """ url = self._GetInfo("URL") if url: scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) guess = "" # TODO(anatoli) - repository specific hacks should be handled by server if netloc == "svn.python.org" and scheme == "svn+ssh": path = "projects" + path scheme = "http" guess = "Python " elif netloc.endswith(".googlecode.com"): scheme = "http" guess = "Google Code " path = path + "/" base = urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) LOGGER.info("Guessed %sbase = %s", guess, base) return base if required: ErrorExit("Can't find URL in output from svn info") return None def _GetInfo(self, key): """Parses 'svn info' for current dir. Returns value for key or None""" for line in RunShell(["svn", "info"]).splitlines(): if line.startswith(key + ": "): return line.split(":", 1)[1].strip() def _EscapeFilename(self, filename): """Escapes filename for SVN commands.""" if "@" in filename and not filename.endswith("@"): filename = "%s@" % filename return filename def GenerateDiff(self, args): cmd = ["svn", "diff", "--internal-diff"] if self.options.revision: cmd += ["-r", self.options.revision] cmd.extend(args) data = RunShell(cmd) count = 0 for line in data.splitlines(): if line.startswith("Index:") or line.startswith("Property changes on:"): count += 1 LOGGER.info(line) if not count: ErrorExit("No valid patches found in output from svn diff") return data def _CollapseKeywords(self, content, keyword_str): """Collapses SVN keywords.""" # svn cat translates keywords but svn diff doesn't. As a result of this # behavior patching.PatchChunks() fails with a chunk mismatch error. # This part was originally written by the Review Board development team # who had the same problem (http://reviews.review-board.org/r/276/). # Mapping of keywords to known aliases svn_keywords = { # Standard keywords 'Date': ['Date', 'LastChangedDate'], 'Revision': ['Revision', 'LastChangedRevision', 'Rev'], 'Author': ['Author', 'LastChangedBy'], 'HeadURL': ['HeadURL', 'URL'], 'Id': ['Id'], # Aliases 'LastChangedDate': ['LastChangedDate', 'Date'], 'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'], 'LastChangedBy': ['LastChangedBy', 'Author'], 'URL': ['URL', 'HeadURL'], } def repl(m): if m.group(2): return "$%s::%s$" % (m.group(1), " " * len(m.group(3))) return "$%s$" % m.group(1) keywords = [keyword for name in keyword_str.split(" ") for keyword in svn_keywords.get(name, [])] return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content) def GetUnknownFiles(self): status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True) unknown_files = [] for line in status.split("\n"): if line and line[0] == "?": unknown_files.append(line) return unknown_files def ReadFile(self, filename): """Returns the contents of a file.""" file = open(filename, 'rb') result = "" try: result = file.read() finally: file.close() return result def GetStatus(self, filename): """Returns the status of a file.""" if not self.options.revision: status = RunShell(["svn", "status", "--ignore-externals", self._EscapeFilename(filename)]) if not status: ErrorExit("svn status returned no output for %s" % filename) status_lines = status.splitlines() # If file is in a cl, the output will begin with # "\n--- Changelist 'cl_name':\n". See # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt if (len(status_lines) == 3 and not status_lines[0] and status_lines[1].startswith("--- Changelist")): status = status_lines[2] else: status = status_lines[0] # If we have a revision to diff against we need to run "svn list" # for the old and the new revision and compare the results to get # the correct status for a file. else: dirname, relfilename = os.path.split(filename) if dirname not in self.svnls_cache: cmd = ["svn", "list", "-r", self.rev_start, self._EscapeFilename(dirname) or "."] out, err, returncode = RunShellWithReturnCodeAndStderr(cmd) if returncode: # Directory might not yet exist at start revison # svn: Unable to find repository location for 'abc' in revision nnn if re.match('^svn: Unable to find repository location for .+ in revision \d+', err): old_files = () else: ErrorExit("Failed to get status for %s:\n%s" % (filename, err)) else: old_files = out.splitlines() args = ["svn", "list"] if self.rev_end: args += ["-r", self.rev_end] cmd = args + [self._EscapeFilename(dirname) or "."] out, returncode = RunShellWithReturnCode(cmd) if returncode: ErrorExit("Failed to run command %s" % cmd) self.svnls_cache[dirname] = (old_files, out.splitlines()) old_files, new_files = self.svnls_cache[dirname] if relfilename in old_files and relfilename not in new_files: status = "D " elif relfilename in old_files and relfilename in new_files: status = "M " else: status = "A " return status def GetBaseFile(self, filename): status = self.GetStatus(filename) base_content = None new_content = None # If a file is copied its status will be "A +", which signifies # "addition-with-history". See "svn st" for more information. We need to # upload the original file or else diff parsing will fail if the file was # edited. if status[0] == "A" and status[3] != "+": # We'll need to upload the new content if we're adding a binary file # since diff's output won't contain it. mimetype = RunShell(["svn", "propget", "svn:mime-type", self._EscapeFilename(filename)], silent_ok=True) base_content = "" is_binary = bool(mimetype) and not mimetype.startswith("text/") if is_binary: new_content = self.ReadFile(filename) elif (status[0] in ("M", "D", "R") or (status[0] == "A" and status[3] == "+") or # Copied file. (status[0] == " " and status[1] == "M")): # Property change. args = [] if self.options.revision: # filename must not be escaped. We already add an ampersand here. url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) else: # Don't change filename, it's needed later. url = filename args += ["-r", "BASE"] cmd = ["svn"] + args + ["propget", "svn:mime-type", url] mimetype, returncode = RunShellWithReturnCode(cmd) if returncode: # File does not exist in the requested revision. # Reset mimetype, it contains an error message. mimetype = "" else: mimetype = mimetype.strip() get_base = False # this test for binary is exactly the test prescribed by the # official SVN docs at # http://subversion.apache.org/faq.html#binary-files is_binary = (bool(mimetype) and not mimetype.startswith("text/") and mimetype not in ("image/x-xbitmap", "image/x-xpixmap")) if status[0] == " ": # Empty base content just to force an upload. base_content = "" elif is_binary: get_base = True if status[0] == "M": if not self.rev_end: new_content = self.ReadFile(filename) else: url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end) new_content = RunShell(["svn", "cat", url], universal_newlines=True, silent_ok=True) else: get_base = True if get_base: if is_binary: universal_newlines = False else: universal_newlines = True if self.rev_start: # "svn cat -r REV delete_file.txt" doesn't work. cat requires # the full URL with "@REV" appended instead of using "-r" option. url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) base_content = RunShell(["svn", "cat", url], universal_newlines=universal_newlines, silent_ok=True) else: base_content, ret_code = RunShellWithReturnCode( ["svn", "cat", self._EscapeFilename(filename)], universal_newlines=universal_newlines) if ret_code and status[0] == "R": # It's a replaced file without local history (see issue208). # The base file needs to be fetched from the server. url = "%s/%s" % (self.svn_base, filename) base_content = RunShell(["svn", "cat", url], universal_newlines=universal_newlines, silent_ok=True) elif ret_code: ErrorExit("Got error status from 'svn cat %s'" % filename) if not is_binary: args = [] if self.rev_start: url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start) else: url = filename args += ["-r", "BASE"] cmd = ["svn"] + args + ["propget", "svn:keywords", url] keywords, returncode = RunShellWithReturnCode(cmd) if keywords and not returncode: base_content = self._CollapseKeywords(base_content, keywords) else: StatusUpdate("svn status returned unexpected output: %s" % status) sys.exit(1) return base_content, new_content, is_binary, status[0:5] class GitVCS(VersionControlSystem): """Implementation of the VersionControlSystem interface for Git.""" def __init__(self, options): super(GitVCS, self).__init__(options) # Map of filename -> (hash before, hash after) of base file. # Hashes for "no such file" are represented as None. self.hashes = {} # Map of new filename -> old filename for renames. self.renames = {} def GetGUID(self): revlist = RunShell("git rev-list --parents HEAD".split()).splitlines() # M-A: Return the 1st root hash, there could be multiple when a # subtree is merged. In that case, more analysis would need to # be done to figure out which HEAD is the 'most representative'. for r in revlist: if ' ' not in r: return r def PostProcessDiff(self, gitdiff): """Converts the diff output to include an svn-style "Index:" line as well as record the hashes of the files, so we can upload them along with our diff.""" # Special used by git to indicate "no such content". NULL_HASH = "0"*40 def IsFileNew(filename): return filename in self.hashes and self.hashes[filename][0] is None def AddSubversionPropertyChange(filename): """Add svn's property change information into the patch if given file is new file. We use Subversion's auto-props setting to retrieve its property. See http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2 for Subversion's [auto-props] setting. """ if self.options.emulate_svn_auto_props and IsFileNew(filename): svnprops = GetSubversionPropertyChanges(filename) if svnprops: svndiff.append("\n" + svnprops + "\n") svndiff = [] filecount = 0 filename = None for line in gitdiff.splitlines(): match = re.match(r"diff --git a/(.*) b/(.*)$", line) if match: # Add auto property here for previously seen file. if filename is not None: AddSubversionPropertyChange(filename) filecount += 1 # Intentionally use the "after" filename so we can show renames. filename = match.group(2) svndiff.append("Index: %s\n" % filename) if match.group(1) != match.group(2): self.renames[match.group(2)] = match.group(1) else: # The "index" line in a git diff looks like this (long hashes elided): # index 82c0d44..b2cee3f 100755 # We want to save the left hash, as that identifies the base file. match = re.match(r"index (\w+)\.\.(\w+)", line) if match: before, after = (match.group(1), match.group(2)) if before == NULL_HASH: before = None if after == NULL_HASH: after = None self.hashes[filename] = (before, after) svndiff.append(line + "\n") if not filecount: ErrorExit("No valid patches found in output from git diff") # Add auto property for the last seen file. assert filename is not None AddSubversionPropertyChange(filename) return "".join(svndiff) def GenerateDiff(self, extra_args): extra_args = extra_args[:] if self.options.revision: if ":" in self.options.revision: extra_args = self.options.revision.split(":", 1) + extra_args else: extra_args = [self.options.revision] + extra_args # --no-ext-diff is broken in some versions of Git, so try to work around # this by overriding the environment (but there is still a problem if the # git config key "diff.external" is used). env = os.environ.copy() if "GIT_EXTERNAL_DIFF" in env: del env["GIT_EXTERNAL_DIFF"] # -M/-C will not print the diff for the deleted file when a file is renamed. # This is confusing because the original file will not be shown on the # review when a file is renamed. So, get a diff with ONLY deletes, then # append a diff (with rename detection), without deletes. cmd = [ "git", "diff", "--no-color", "--no-ext-diff", "--full-index", "--ignore-submodules", "--src-prefix=a/", "--dst-prefix=b/", ] diff = RunShell( cmd + ["--no-renames", "--diff-filter=D"] + extra_args, env=env, silent_ok=True) assert 0 <= self.options.git_similarity <= 100 if self.options.git_find_copies: similarity_options = ["-l100000", "-C%d%%" % self.options.git_similarity] if self.options.git_find_copies_harder: similarity_options.append("--find-copies-harder") else: similarity_options = ["-M%d%%" % self.options.git_similarity ] diff += RunShell( cmd + ["--diff-filter=AMCRT"] + similarity_options + extra_args, env=env, silent_ok=True) # The CL could be only file deletion or not. So accept silent diff for both # commands then check for an empty diff manually. if not diff: ErrorExit("No output from %s" % (cmd + extra_args)) return diff def GetUnknownFiles(self): status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], silent_ok=True) return status.splitlines() def GetFileContent(self, file_hash): """Returns the content of a file identified by its git hash.""" data, retcode = RunShellWithReturnCode(["git", "show", file_hash], universal_newlines=False) if retcode: ErrorExit("Got error status from 'git show %s'" % file_hash) return data def GetBaseFile(self, filename): hash_before, hash_after = self.hashes.get(filename, (None,None)) base_content = None new_content = None status = None if filename in self.renames: status = "A +" # Match svn attribute name for renames. if filename not in self.hashes: # If a rename doesn't change the content, we never get a hash. base_content = RunShell( ["git", "show", "HEAD:" + filename], silent_ok=True, universal_newlines=False) elif not hash_before: status = "A" base_content = "" elif not hash_after: status = "D" else: status = "M" # Grab the before/after content if we need it. # Grab the base content if we don't have it already. if base_content is None and hash_before: base_content = self.GetFileContent(hash_before) is_binary = self.IsImage(filename) if base_content: is_binary = is_binary or self.IsBinaryData(base_content) # Only include the "after" file if it's an image; otherwise it # it is reconstructed from the diff. if hash_after: new_content = self.GetFileContent(hash_after) is_binary = is_binary or self.IsBinaryData(new_content) if not is_binary: new_content = None return (base_content, new_content, is_binary, status) class CVSVCS(VersionControlSystem): """Implementation of the VersionControlSystem interface for CVS.""" def __init__(self, options): super(CVSVCS, self).__init__(options) def GetGUID(self): """For now we don't know how to get repository ID for CVS""" return def GetOriginalContent_(self, filename): RunShell(["cvs", "up", filename], silent_ok=True) # TODO need detect file content encoding content = open(filename).read() return content.replace("\r\n", "\n") def GetBaseFile(self, filename): base_content = None new_content = None status = "A" output, retcode = RunShellWithReturnCode(["cvs", "status", filename]) if retcode: ErrorExit("Got error status from 'cvs status %s'" % filename) if output.find("Status: Locally Modified") != -1: status = "M" temp_filename = "%s.tmp123" % filename os.rename(filename, temp_filename) base_content = self.GetOriginalContent_(filename) os.rename(temp_filename, filename) elif output.find("Status: Locally Added"): status = "A" base_content = "" elif output.find("Status: Needs Checkout"): status = "D" base_content = self.GetOriginalContent_(filename) return (base_content, new_content, self.IsBinaryData(base_content), status) def GenerateDiff(self, extra_args): cmd = ["cvs", "diff", "-u", "-N"] if self.options.revision: cmd += ["-r", self.options.revision] cmd.extend(extra_args) data, retcode = RunShellWithReturnCode(cmd) count = 0 if retcode in [0, 1]: for line in data.splitlines(): if line.startswith("Index:"): count += 1 LOGGER.info(line) if not count: ErrorExit("No valid patches found in output from cvs diff") return data def GetUnknownFiles(self): data, retcode = RunShellWithReturnCode(["cvs", "diff"]) if retcode not in [0, 1]: ErrorExit("Got error status from 'cvs diff':\n%s" % (data,)) unknown_files = [] for line in data.split("\n"): if line and line[0] == "?": unknown_files.append(line) return unknown_files class MercurialVCS(VersionControlSystem): """Implementation of the VersionControlSystem interface for Mercurial.""" def __init__(self, options, repo_dir): super(MercurialVCS, self).__init__(options) # Absolute path to repository (we can be in a subdir) self.repo_dir = os.path.normpath(repo_dir) # Compute the subdir cwd = os.path.normpath(os.getcwd()) assert cwd.startswith(self.repo_dir) self.subdir = cwd[len(self.repo_dir):].lstrip(r"\/") if self.options.revision: self.base_rev = self.options.revision else: parent = RunShell(["hg", "parent", "-q"], silent_ok=True) if parent: self.base_rev = parent.split(':')[1].strip() else: self.base_rev = '0' def GetGUID(self): # See chapter "Uniquely identifying a repository" # http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html info = RunShell("hg log -r0 --template {node}".split()) return info.strip() def _GetRelPath(self, filename): """Get relative path of a file according to the current directory, given its logical path in the repo.""" absname = os.path.join(self.repo_dir, filename) return os.path.relpath(absname) def GenerateDiff(self, extra_args): cmd = ["hg", "diff", "--git", "-r", self.base_rev] + extra_args data = RunShell(cmd, silent_ok=True) svndiff = [] filecount = 0 for line in data.splitlines(): m = re.match("diff --git a/(\S+) b/(\S+)", line) if m: # Modify line to make it look like as it comes from svn diff. # With this modification no changes on the server side are required # to make upload.py work with Mercurial repos. # NOTE: for proper handling of moved/copied files, we have to use # the second filename. filename = m.group(2) svndiff.append("Index: %s" % filename) svndiff.append("=" * 67) filecount += 1 LOGGER.info(line) else: svndiff.append(line) if not filecount: ErrorExit("No valid patches found in output from hg diff") return "\n".join(svndiff) + "\n" def GetUnknownFiles(self): """Return a list of files unknown to the VCS.""" args = [] status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."], silent_ok=True) unknown_files = [] for line in status.splitlines(): st, fn = line.split(" ", 1) if st == "?": unknown_files.append(fn) return unknown_files def GetBaseFile(self, filename): # "hg status" and "hg cat" both take a path relative to the current subdir, # but "hg diff" has given us the path relative to the repo root. base_content = "" new_content = None is_binary = False oldrelpath = relpath = self._GetRelPath(filename) # "hg status -C" returns two lines for moved/copied files, one otherwise out = RunShell(["hg", "status", "-C", "--rev", self.base_rev, relpath]) out = out.splitlines() # HACK: strip error message about missing file/directory if it isn't in # the working copy if out[0].startswith('%s: ' % relpath): out = out[1:] status, _ = out[0].split(' ', 1) if len(out) > 1 and status == "A": # Moved/copied => considered as modified, use old filename to # retrieve base contents oldrelpath = out[1].strip() status = "M" if ":" in self.base_rev: base_rev = self.base_rev.split(":", 1)[0] else: base_rev = self.base_rev if status != "A": base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], silent_ok=True) is_binary = self.IsBinaryData(base_content) if status != "R": new_content = open(relpath, "rb").read() is_binary = is_binary or self.IsBinaryData(new_content) if is_binary and base_content: # Fetch again without converting newlines base_content = RunShell(["hg", "cat", "-r", base_rev, oldrelpath], silent_ok=True, universal_newlines=False) if not is_binary: new_content = None return base_content, new_content, is_binary, status class PerforceVCS(VersionControlSystem): """Implementation of the VersionControlSystem interface for Perforce.""" def __init__(self, options): def ConfirmLogin(): # Make sure we have a valid perforce session while True: data, retcode = self.RunPerforceCommandWithReturnCode( ["login", "-s"], marshal_output=True) if not data: ErrorExit("Error checking perforce login") if not retcode and (not "code" in data or data["code"] != "error"): break print "Enter perforce password: " self.RunPerforceCommandWithReturnCode(["login"]) super(PerforceVCS, self).__init__(options) self.p4_changelist = options.p4_changelist if not self.p4_changelist: ErrorExit("A changelist id is required") if (options.revision): ErrorExit("--rev is not supported for perforce") self.p4_port = options.p4_port self.p4_client = options.p4_client self.p4_user = options.p4_user ConfirmLogin() if not options.title: description = self.RunPerforceCommand(["describe", self.p4_changelist], marshal_output=True) if description and "desc" in description: # Rietveld doesn't support multi-line descriptions raw_title = description["desc"].strip() lines = raw_title.splitlines() if len(lines): options.title = lines[0] def GetGUID(self): """For now we don't know how to get repository ID for Perforce""" return def RunPerforceCommandWithReturnCode(self, extra_args, marshal_output=False, universal_newlines=True): args = ["p4"] if marshal_output: # -G makes perforce format its output as marshalled python objects args.extend(["-G"]) if self.p4_port: args.extend(["-p", self.p4_port]) if self.p4_client: args.extend(["-c", self.p4_client]) if self.p4_user: args.extend(["-u", self.p4_user]) args.extend(extra_args) data, retcode = RunShellWithReturnCode( args, print_output=False, universal_newlines=universal_newlines) if marshal_output and data: data = marshal.loads(data) return data, retcode def RunPerforceCommand(self, extra_args, marshal_output=False, universal_newlines=True): # This might be a good place to cache call results, since things like # describe or fstat might get called repeatedly. data, retcode = self.RunPerforceCommandWithReturnCode( extra_args, marshal_output, universal_newlines) if retcode: ErrorExit("Got error status from %s:\n%s" % (extra_args, data)) return data def GetFileProperties(self, property_key_prefix = "", command = "describe"): description = self.RunPerforceCommand(["describe", self.p4_changelist], marshal_output=True) changed_files = {} file_index = 0 # Try depotFile0, depotFile1, ... until we don't find a match while True: file_key = "depotFile%d" % file_index if file_key in description: filename = description[file_key] change_type = description[property_key_prefix + str(file_index)] changed_files[filename] = change_type file_index += 1 else: break return changed_files def GetChangedFiles(self): return self.GetFileProperties("action") def GetUnknownFiles(self): # Perforce doesn't detect new files, they have to be explicitly added return [] def IsBaseBinary(self, filename): base_filename = self.GetBaseFilename(filename) return self.IsBinaryHelper(base_filename, "files") def IsPendingBinary(self, filename): return self.IsBinaryHelper(filename, "describe") def IsBinaryHelper(self, filename, command): file_types = self.GetFileProperties("type", command) if not filename in file_types: ErrorExit("Trying to check binary status of unknown file %s." % filename) # This treats symlinks, macintosh resource files, temporary objects, and # unicode as binary. See the Perforce docs for more details: # http://www.perforce.com/perforce/doc.current/manuals/cmdref/o.ftypes.html return not file_types[filename].endswith("text") def GetFileContent(self, filename, revision, is_binary): file_arg = filename if revision: file_arg += "#" + revision # -q suppresses the initial line that displays the filename and revision return self.RunPerforceCommand(["print", "-q", file_arg], universal_newlines=not is_binary) def GetBaseFilename(self, filename): actionsWithDifferentBases = [ "move/add", # p4 move "branch", # p4 integrate (to a new file), similar to hg "add" "add", # p4 integrate (to a new file), after modifying the new file ] # We only see a different base for "add" if this is a downgraded branch # after a file was branched (integrated), then edited. if self.GetAction(filename) in actionsWithDifferentBases: # -Or shows information about pending integrations/moves fstat_result = self.RunPerforceCommand(["fstat", "-Or", filename], marshal_output=True) baseFileKey = "resolveFromFile0" # I think it's safe to use only file0 if baseFileKey in fstat_result: return fstat_result[baseFileKey] return filename def GetBaseRevision(self, filename): base_filename = self.GetBaseFilename(filename) have_result = self.RunPerforceCommand(["have", base_filename], marshal_output=True) if "haveRev" in have_result: return have_result["haveRev"] def GetLocalFilename(self, filename): where = self.RunPerforceCommand(["where", filename], marshal_output=True) if "path" in where: return where["path"] def GenerateDiff(self, args): class DiffData: def __init__(self, perforceVCS, filename, action): self.perforceVCS = perforceVCS self.filename = filename self.action = action self.base_filename = perforceVCS.GetBaseFilename(filename) self.file_body = None self.base_rev = None self.prefix = None self.working_copy = True self.change_summary = None def GenerateDiffHeader(diffData): header = [] header.append("Index: %s" % diffData.filename) header.append("=" * 67) if diffData.base_filename != diffData.filename: if diffData.action.startswith("move"): verb = "rename" else: verb = "copy" header.append("%s from %s" % (verb, diffData.base_filename)) header.append("%s to %s" % (verb, diffData.filename)) suffix = "\t(revision %s)" % diffData.base_rev header.append("--- " + diffData.base_filename + suffix) if diffData.working_copy: suffix = "\t(working copy)" header.append("+++ " + diffData.filename + suffix) if diffData.change_summary: header.append(diffData.change_summary) return header def GenerateMergeDiff(diffData, args): # -du generates a unified diff, which is nearly svn format diffData.file_body = self.RunPerforceCommand( ["diff", "-du", diffData.filename] + args) diffData.base_rev = self.GetBaseRevision(diffData.filename) diffData.prefix = "" # We have to replace p4's file status output (the lines starting # with +++ or ---) to match svn's diff format lines = diffData.file_body.splitlines() first_good_line = 0 while (first_good_line < len(lines) and not lines[first_good_line].startswith("@@")): first_good_line += 1 diffData.file_body = "\n".join(lines[first_good_line:]) return diffData def GenerateAddDiff(diffData): fstat = self.RunPerforceCommand(["fstat", diffData.filename], marshal_output=True) if "headRev" in fstat: diffData.base_rev = fstat["headRev"] # Re-adding a deleted file else: diffData.base_rev = "0" # Brand new file diffData.working_copy = False rel_path = self.GetLocalFilename(diffData.filename) diffData.file_body = open(rel_path, 'r').read() # Replicate svn's list of changed lines line_count = len(diffData.file_body.splitlines()) diffData.change_summary = "@@ -0,0 +1" if line_count > 1: diffData.change_summary += ",%d" % line_count diffData.change_summary += " @@" diffData.prefix = "+" return diffData def GenerateDeleteDiff(diffData): diffData.base_rev = self.GetBaseRevision(diffData.filename) is_base_binary = self.IsBaseBinary(diffData.filename) # For deletes, base_filename == filename diffData.file_body = self.GetFileContent(diffData.base_filename, None, is_base_binary) # Replicate svn's list of changed lines line_count = len(diffData.file_body.splitlines()) diffData.change_summary = "@@ -1" if line_count > 1: diffData.change_summary += ",%d" % line_count diffData.change_summary += " +0,0 @@" diffData.prefix = "-" return diffData changed_files = self.GetChangedFiles() svndiff = [] filecount = 0 for (filename, action) in changed_files.items(): svn_status = self.PerforceActionToSvnStatus(action) if svn_status == "SKIP": continue diffData = DiffData(self, filename, action) # Is it possible to diff a branched file? Stackoverflow says no: # http://stackoverflow.com/questions/1771314/in-perforce-command-line-how-to-diff-a-file-reopened-for-add if svn_status == "M": diffData = GenerateMergeDiff(diffData, args) elif svn_status == "A": diffData = GenerateAddDiff(diffData) elif svn_status == "D": diffData = GenerateDeleteDiff(diffData) else: ErrorExit("Unknown file action %s (svn action %s)." % \ (action, svn_status)) svndiff += GenerateDiffHeader(diffData) for line in diffData.file_body.splitlines(): svndiff.append(diffData.prefix + line) filecount += 1 if not filecount: ErrorExit("No valid patches found in output from p4 diff") return "\n".join(svndiff) + "\n" def PerforceActionToSvnStatus(self, status): # Mirroring the list at http://permalink.gmane.org/gmane.comp.version-control.mercurial.devel/28717 # Is there something more official? return { "add" : "A", "branch" : "A", "delete" : "D", "edit" : "M", # Also includes changing file types. "integrate" : "M", "move/add" : "M", "move/delete": "SKIP", "purge" : "D", # How does a file's status become "purge"? }[status] def GetAction(self, filename): changed_files = self.GetChangedFiles() if not filename in changed_files: ErrorExit("Trying to get base version of unknown file %s." % filename) return changed_files[filename] def GetBaseFile(self, filename): base_filename = self.GetBaseFilename(filename) base_content = "" new_content = None status = self.PerforceActionToSvnStatus(self.GetAction(filename)) if status != "A": revision = self.GetBaseRevision(base_filename) if not revision: ErrorExit("Couldn't find base revision for file %s" % filename) is_base_binary = self.IsBaseBinary(base_filename) base_content = self.GetFileContent(base_filename, revision, is_base_binary) is_binary = self.IsPendingBinary(filename) if status != "D" and status != "SKIP": relpath = self.GetLocalFilename(filename) if is_binary: new_content = open(relpath, "rb").read() return base_content, new_content, is_binary, status # NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync. def SplitPatch(data): """Splits a patch into separate pieces for each file. Args: data: A string containing the output of svn diff. Returns: A list of 2-tuple (filename, text) where text is the svn diff output pertaining to filename. """ patches = [] filename = None diff = [] for line in data.splitlines(True): new_filename = None if line.startswith('Index:'): unused, new_filename = line.split(':', 1) new_filename = new_filename.strip() elif line.startswith('Property changes on:'): unused, temp_filename = line.split(':', 1) # When a file is modified, paths use '/' between directories, however # when a property is modified '\' is used on Windows. Make them the same # otherwise the file shows up twice. temp_filename = temp_filename.strip().replace('\\', '/') if temp_filename != filename: # File has property changes but no modifications, create a new diff. new_filename = temp_filename if new_filename: if filename and diff: patches.append((filename, ''.join(diff))) filename = new_filename diff = [line] continue if diff is not None: diff.append(line) if filename and diff: patches.append((filename, ''.join(diff))) return patches def UploadSeparatePatches(issue, rpc_server, patchset, data, options): """Uploads a separate patch for each file in the diff output. Returns a list of [patch_key, filename] for each file. """ def UploadFile(filename, data): form_fields = [("filename", filename)] if not options.download_base: form_fields.append(("content_upload", "1")) files = [("data", "data.diff", data)] ctype, body = EncodeMultipartFormData(form_fields, files) url = "/%d/upload_patch/%d" % (int(issue), int(patchset)) try: response_body = rpc_server.Send(url, body, content_type=ctype) except urllib2.HTTPError as e: response_body = ("Failed to upload patch for %s. Got %d status code." % (filename, e.code)) lines = response_body.splitlines() if not lines or lines[0] != "OK": StatusUpdate(" --> %s" % response_body) sys.exit(1) return ("Uploaded patch for " + filename, [lines[1], filename]) threads = [] thread_pool = ThreadPool(options.num_upload_threads) patches = SplitPatch(data) rv = [] for patch in patches: if len(patch[1]) > MAX_UPLOAD_SIZE: print ("Not uploading the patch for " + patch[0] + " because the file is too large.") continue filename = patch[0] data = patch[1] t = thread_pool.apply_async(UploadFile, args=(filename, data)) threads.append(t) for t in threads: result = t.get(timeout=60) print result[0] rv.append(result[1]) return rv def GuessVCSName(options): """Helper to guess the version control system. This examines the current directory, guesses which VersionControlSystem we're using, and returns an string indicating which VCS is detected. Returns: A pair (vcs, output). vcs is a string indicating which VCS was detected and is one of VCS_GIT, VCS_MERCURIAL, VCS_SUBVERSION, VCS_PERFORCE, VCS_CVS, or VCS_UNKNOWN. Since local perforce repositories can't be easily detected, this method will only guess VCS_PERFORCE if any perforce options have been specified. output is a string containing any interesting output from the vcs detection routine, or None if there is nothing interesting. """ for attribute, value in options.__dict__.iteritems(): if attribute.startswith("p4") and value != None: return (VCS_PERFORCE, None) def RunDetectCommand(vcs_type, command): """Helper to detect VCS by executing command. Returns: A pair (vcs, output) or None. Throws exception on error. """ try: out, returncode = RunShellWithReturnCode(command) if returncode == 0: return (vcs_type, out.strip()) except OSError as e: (errcode, message) = e.args if errcode != errno.ENOENT: # command not found code raise # Mercurial has a command to get the base directory of a repository # Try running it, but don't die if we don't have hg installed. # NOTE: we try Mercurial first as it can sit on top of an SVN working copy. res = RunDetectCommand(VCS_MERCURIAL, ["hg", "root"]) if res != None: return res # Subversion from 1.7 has a single centralized .svn folder # ( see http://subversion.apache.org/docs/release-notes/1.7.html#wc-ng ) # That's why we use 'svn info' instead of checking for .svn dir res = RunDetectCommand(VCS_SUBVERSION, ["svn", "info"]) if res != None: return res # Git has a command to test if you're in a git tree. # Try running it, but don't die if we don't have git installed. res = RunDetectCommand(VCS_GIT, ["git", "rev-parse", "--is-inside-work-tree"]) if res != None: return res # detect CVS repos use `cvs status && $? == 0` rules res = RunDetectCommand(VCS_CVS, ["cvs", "status"]) if res != None: return res return (VCS_UNKNOWN, None) def GuessVCS(options): """Helper to guess the version control system. This verifies any user-specified VersionControlSystem (by command line or environment variable). If the user didn't specify one, this examines the current directory, guesses which VersionControlSystem we're using, and returns an instance of the appropriate class. Exit with an error if we can't figure it out. Returns: A VersionControlSystem instance. Exits if the VCS can't be guessed. """ vcs = options.vcs if not vcs: vcs = os.environ.get("CODEREVIEW_VCS") if vcs: v = VCS_ABBREVIATIONS.get(vcs.lower()) if v is None: ErrorExit("Unknown version control system %r specified." % vcs) (vcs, extra_output) = (v, None) else: (vcs, extra_output) = GuessVCSName(options) if vcs == VCS_MERCURIAL: if extra_output is None: extra_output = RunShell(["hg", "root"]).strip() return MercurialVCS(options, extra_output) elif vcs == VCS_SUBVERSION: return SubversionVCS(options) elif vcs == VCS_PERFORCE: return PerforceVCS(options) elif vcs == VCS_GIT: return GitVCS(options) elif vcs == VCS_CVS: return CVSVCS(options) ErrorExit(("Could not guess version control system. " "Are you in a working copy directory?")) def CheckReviewer(reviewer): """Validate a reviewer -- either a nickname or an email addres. Args: reviewer: A nickname or an email address. Calls ErrorExit() if it is an invalid email address. """ if "@" not in reviewer: return # Assume nickname parts = reviewer.split("@") if len(parts) > 2: ErrorExit("Invalid email address: %r" % reviewer) assert len(parts) == 2 if "." not in parts[1]: ErrorExit("Invalid email address: %r" % reviewer) def LoadSubversionAutoProperties(): """Returns the content of [auto-props] section of Subversion's config file as a dictionary. Returns: A dictionary whose key-value pair corresponds the [auto-props] section's key-value pair. In following cases, returns empty dictionary: - config file doesn't exist, or - 'enable-auto-props' is not set to 'true-like-value' in [miscellany]. """ if os.name == 'nt': subversion_config = os.environ.get("APPDATA") + "\\Subversion\\config" else: subversion_config = os.path.expanduser("~/.subversion/config") if not os.path.exists(subversion_config): return {} config = ConfigParser.ConfigParser() config.read(subversion_config) if (config.has_section("miscellany") and config.has_option("miscellany", "enable-auto-props") and config.getboolean("miscellany", "enable-auto-props") and config.has_section("auto-props")): props = {} for file_pattern in config.options("auto-props"): props[file_pattern] = ParseSubversionPropertyValues( config.get("auto-props", file_pattern)) return props else: return {} def ParseSubversionPropertyValues(props): """Parse the given property value which comes from [auto-props] section and returns a list whose element is a (svn_prop_key, svn_prop_value) pair. See the following doctest for example. >>> ParseSubversionPropertyValues('svn:eol-style=LF') [('svn:eol-style', 'LF')] >>> ParseSubversionPropertyValues('svn:mime-type=image/jpeg') [('svn:mime-type', 'image/jpeg')] >>> ParseSubversionPropertyValues('svn:eol-style=LF;svn:executable') [('svn:eol-style', 'LF'), ('svn:executable', '*')] """ key_value_pairs = [] for prop in props.split(";"): key_value = prop.split("=") assert len(key_value) <= 2 if len(key_value) == 1: # If value is not given, use '*' as a Subversion's convention. key_value_pairs.append((key_value[0], "*")) else: key_value_pairs.append((key_value[0], key_value[1])) return key_value_pairs def GetSubversionPropertyChanges(filename): """Return a Subversion's 'Property changes on ...' string, which is used in the patch file. Args: filename: filename whose property might be set by [auto-props] config. Returns: A string like 'Property changes on |filename| ...' if given |filename| matches any entries in [auto-props] section. None, otherwise. """ global svn_auto_props_map if svn_auto_props_map is None: svn_auto_props_map = LoadSubversionAutoProperties() all_props = [] for file_pattern, props in svn_auto_props_map.items(): if fnmatch.fnmatch(filename, file_pattern): all_props.extend(props) if all_props: return FormatSubversionPropertyChanges(filename, all_props) return None def FormatSubversionPropertyChanges(filename, props): """Returns Subversion's 'Property changes on ...' strings using given filename and properties. Args: filename: filename props: A list whose element is a (svn_prop_key, svn_prop_value) pair. Returns: A string which can be used in the patch file for Subversion. See the following doctest for example. >>> print FormatSubversionPropertyChanges('foo.cc', [('svn:eol-style', 'LF')]) Property changes on: foo.cc ___________________________________________________________________ Added: svn:eol-style + LF <BLANKLINE> """ prop_changes_lines = [ "Property changes on: %s" % filename, "___________________________________________________________________"] for key, value in props: prop_changes_lines.append("Added: " + key) prop_changes_lines.append(" + " + value) return "\n".join(prop_changes_lines) + "\n" def RealMain(argv, data=None): """The real main function. Args: argv: Command line arguments. data: Diff contents. If None (default) the diff is generated by the VersionControlSystem implementation returned by GuessVCS(). Returns: A 2-tuple (issue id, patchset id). The patchset id is None if the base files are not uploaded by this script (applies only to SVN checkouts). """ options, args = parser.parse_args(argv[1:]) if options.help: if options.verbose < 2: # hide Perforce options parser.epilog = ( "Use '--help -v' to show additional Perforce options. " "For more help, see " "https://github.com/rietveld-codereview/rietveld/wiki" ) parser.option_groups.remove(parser.get_option_group('--p4_port')) parser.print_help() sys.exit(0) global verbosity verbosity = options.verbose if verbosity >= 3: LOGGER.setLevel(logging.DEBUG) elif verbosity >= 2: LOGGER.setLevel(logging.INFO) vcs = GuessVCS(options) base = options.base_url if isinstance(vcs, SubversionVCS): # Guessing the base field is only supported for Subversion. # Note: Fetching base files may become deprecated in future releases. guessed_base = vcs.GuessBase(options.download_base) if base: if guessed_base and base != guessed_base: print "Using base URL \"%s\" from --base_url instead of \"%s\"" % \ (base, guessed_base) else: base = guessed_base if not base and options.download_base: options.download_base = True LOGGER.info("Enabled upload of base file") if not options.assume_yes: vcs.CheckForUnknownFiles() if data is None: data = vcs.GenerateDiff(args) data = vcs.PostProcessDiff(data) if options.print_diffs: print "Rietveld diff start:*****" print data print "Rietveld diff end:*****" files = vcs.GetBaseFiles(data) if verbosity >= 1: print "Upload server:", options.server, "(change with -s/--server)" if options.use_oauth2: options.save_cookies = False rpc_server = GetRpcServer(options.server, options.email, options.host, options.save_cookies, options.account_type, options.use_oauth2, options.oauth2_port, options.open_oauth2_local_webbrowser) form_fields = [] repo_guid = vcs.GetGUID() if repo_guid: form_fields.append(("repo_guid", repo_guid)) if base: b = urlparse.urlparse(base) username, netloc = urllib.splituser(b.netloc) if username: LOGGER.info("Removed username from base URL") base = urlparse.urlunparse((b.scheme, netloc, b.path, b.params, b.query, b.fragment)) form_fields.append(("base", base)) if options.issue: form_fields.append(("issue", str(options.issue))) if options.email: form_fields.append(("user", options.email)) if options.reviewers: for reviewer in options.reviewers.split(','): CheckReviewer(reviewer) form_fields.append(("reviewers", options.reviewers)) if options.cc: for cc in options.cc.split(','): CheckReviewer(cc) form_fields.append(("cc", options.cc)) # Process --message, --title and --file. message = options.message or "" title = options.title or "" if options.file: if options.message: ErrorExit("Can't specify both message and message file options") file = open(options.file, 'r') message = file.read() file.close() if options.issue: prompt = "Title describing this patch set: " else: prompt = "New issue subject: " title = ( title or message.split('\n', 1)[0].strip() or raw_input(prompt).strip()) if not title and not options.issue: ErrorExit("A non-empty title is required for a new issue") # For existing issues, it's fine to give a patchset an empty name. Rietveld # doesn't accept that so use a whitespace. title = title or " " if len(title) > 100: title = title[:99] + '…' if title and not options.issue: message = message or title form_fields.append(("subject", title)) # If it's a new issue send message as description. Otherwise a new # message is created below on upload_complete. if message and not options.issue: form_fields.append(("description", message)) # Send a hash of all the base file so the server can determine if a copy # already exists in an earlier patchset. base_hashes = "" for file, info in files.iteritems(): if not info[0] is None: checksum = md5(info[0]).hexdigest() if base_hashes: base_hashes += "|" base_hashes += checksum + ":" + file form_fields.append(("base_hashes", base_hashes)) if options.private: if options.issue: print "Warning: Private flag ignored when updating an existing issue." else: form_fields.append(("private", "1")) if options.send_patch: options.send_mail = True if not options.download_base: form_fields.append(("content_upload", "1")) if len(data) > MAX_UPLOAD_SIZE: print "Patch is large, so uploading file patches separately." uploaded_diff_file = [] form_fields.append(("separate_patches", "1")) else: uploaded_diff_file = [("data", "data.diff", data)] ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) response_body = rpc_server.Send("/upload", body, content_type=ctype) patchset = None if not options.download_base or not uploaded_diff_file: lines = response_body.splitlines() if len(lines) >= 2: msg = lines[0] patchset = lines[1].strip() patches = [x.split(" ", 1) for x in lines[2:]] else: msg = response_body else: msg = response_body StatusUpdate(msg) if not response_body.startswith("Issue created.") and \ not response_body.startswith("Issue updated."): sys.exit(0) issue = msg[msg.rfind("/")+1:] if not uploaded_diff_file: result = UploadSeparatePatches(issue, rpc_server, patchset, data, options) if not options.download_base: patches = result if not options.download_base: vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files) payload = {} # payload for final request if options.send_mail: payload["send_mail"] = "yes" if options.send_patch: payload["attach_patch"] = "yes" if options.issue and message: payload["message"] = message payload = urllib.urlencode(payload) rpc_server.Send("/" + issue + "/upload_complete/" + (patchset or ""), payload=payload) return issue, patchset def main(): try: logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:" "%(lineno)s %(message)s ")) os.environ['LC_ALL'] = 'C' RealMain(sys.argv) except KeyboardInterrupt: print StatusUpdate("Interrupted.") sys.exit(1) if __name__ == "__main__": main()
hossamkhader/ns-3
upload.py
Python
gpl-2.0
99,818
[ "VisIt" ]
31f1118f9be76ebc6971f9d2ec269d8b3443d4168b5f3fc08bed7e0f3ae02047
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. # ---------------------------------------------------------------------------- from __future__ import absolute_import, division, print_function import six from unittest import TestCase, main import numpy as np import numpy.testing as npt from skbio.sequence._iupac_sequence import IUPACSequence from skbio.util._decorator import classproperty class ExampleIUPACSequence(IUPACSequence): @classproperty def degenerate_map(cls): return {"X": set("AB"), "Y": set("BC"), "Z": set("AC")} @classproperty def nondegenerate_chars(cls): return set("ABC") class ExampleMotifsTester(ExampleIUPACSequence): @property def _motifs(self): # These aren't really motifs, just a way to excercise the code paths return { "name1": lambda x, _, __: str(x), "name2": lambda x, _, __: len(x) } class TestIUPACSequence(TestCase): def test_instantiation_with_no_implementation(self): class IUPACSequenceSubclassNoImplementation(IUPACSequence): pass with self.assertRaises(TypeError) as cm: IUPACSequenceSubclassNoImplementation() self.assertIn("abstract class", str(cm.exception)) self.assertIn("nondegenerate_chars", str(cm.exception)) self.assertIn("degenerate_map", str(cm.exception)) def test_init_default_parameters(self): seq = ExampleIUPACSequence('.-ABCXYZ') npt.assert_equal(seq.values, np.array('.-ABCXYZ', dtype='c')) self.assertFalse(seq.has_metadata()) self.assertFalse(seq.has_positional_metadata()) def test_init_nondefault_parameters(self): seq = ExampleIUPACSequence('.-ABCXYZ', metadata={'id': 'foo'}, positional_metadata={'quality': range(8)}) npt.assert_equal(seq.values, np.array('.-ABCXYZ', dtype='c')) self.assertTrue(seq.has_metadata()) self.assertEqual(seq.metadata['id'], 'foo') self.assertTrue(seq.has_positional_metadata()) npt.assert_equal(seq.positional_metadata['quality'], np.array(range(8), dtype='int')) def test_init_valid_empty_sequence(self): # just make sure we can instantiate an empty sequence regardless of # `validate` and `lowercase` parameters. more extensive tests # are performed in Sequence base class unit tests for validate in (True, False): for lowercase in (True, False): seq = ExampleIUPACSequence('', validate=validate, lowercase=lowercase) self.assertEqual(seq, ExampleIUPACSequence('')) def test_init_valid_single_character_sequence(self): for validate in (True, False): for lowercase in (True, False): seq = ExampleIUPACSequence('C', validate=validate, lowercase=lowercase) self.assertEqual(seq, ExampleIUPACSequence('C')) def test_init_valid_multiple_character_sequence(self): for validate in (True, False): for lowercase in (True, False): seq = ExampleIUPACSequence('BAACB.XYY-AZ', validate=validate, lowercase=lowercase) self.assertEqual(seq, ExampleIUPACSequence('BAACB.XYY-AZ')) def test_init_validate_parameter_single_character(self): seq = 'w' with six.assertRaisesRegex(self, ValueError, "character.*'w'"): ExampleIUPACSequence(seq) # test that we can instantiate an invalid sequence. we don't guarantee # anything working beyond instantiation ExampleIUPACSequence(seq, validate=False) def test_init_validate_parameter_multiple_characters(self): # mix of valid and invalid characters with repeats and lowercased # alphabet characters seq = 'CBCBBbawCbbwBXYZ-.x' with six.assertRaisesRegex(self, ValueError, "\['a', 'b', 'w', 'x'\]"): ExampleIUPACSequence(seq) ExampleIUPACSequence(seq, validate=False) def test_init_lowercase_all_lowercase(self): s = 'cbcbbbazcbbzbxyz-.x' with six.assertRaisesRegex(self, ValueError, "\['a', 'b', 'c', 'x', 'y', 'z'\]"): ExampleIUPACSequence(s) seq = ExampleIUPACSequence(s, lowercase=True) self.assertEqual(seq, ExampleIUPACSequence('CBCBBBAZCBBZBXYZ-.X')) def test_init_lowercase_mixed_case(self): s = 'CBCBBbazCbbzBXYZ-.x' with six.assertRaisesRegex(self, ValueError, "\['a', 'b', 'x', 'z'\]"): ExampleIUPACSequence(s) seq = ExampleIUPACSequence(s, lowercase=True) self.assertEqual(seq, ExampleIUPACSequence('CBCBBBAZCBBZBXYZ-.X')) def test_init_lowercase_no_validation(self): s = 'car' with six.assertRaisesRegex(self, ValueError, "\['a', 'c', 'r'\]"): ExampleIUPACSequence(s) with six.assertRaisesRegex(self, ValueError, "character.*'R'"): ExampleIUPACSequence(s, lowercase=True) ExampleIUPACSequence(s, lowercase=True, validate=False) def test_init_lowercase_byte_ownership(self): bytes = np.array([97, 98, 97], dtype=np.uint8) with six.assertRaisesRegex(self, ValueError, "\['a', 'b'\]"): ExampleIUPACSequence(bytes) seq = ExampleIUPACSequence(bytes, lowercase=True) self.assertEqual(seq, ExampleIUPACSequence('ABA')) # should not share the same memory self.assertIsNot(seq._bytes, bytes) # we should have copied `bytes` before modifying in place to convert to # upper. make sure `bytes` hasn't been mutated npt.assert_equal(bytes, np.array([97, 98, 97], dtype=np.uint8)) def test_init_lowercase_invalid_keys(self): for invalid_key in ((), [], 2): invalid_type = type(invalid_key) with six.assertRaisesRegex(self, TypeError, "lowercase keyword argument expected " "a bool or string, but got %s" % invalid_type): ExampleIUPACSequence('ACGTacgt', lowercase=invalid_key) def test_degenerate_chars(self): expected = set("XYZ") self.assertIs(type(ExampleIUPACSequence.degenerate_chars), set) self.assertEqual(ExampleIUPACSequence.degenerate_chars, expected) ExampleIUPACSequence.degenerate_chars.add("W") self.assertEqual(ExampleIUPACSequence.degenerate_chars, expected) self.assertEqual(ExampleIUPACSequence('').degenerate_chars, expected) with self.assertRaises(AttributeError): ExampleIUPACSequence('').degenerate_chars = set("BAR") def test_nondegenerate_chars(self): expected = set("ABC") self.assertEqual(ExampleIUPACSequence.nondegenerate_chars, expected) ExampleIUPACSequence.degenerate_chars.add("D") self.assertEqual(ExampleIUPACSequence.nondegenerate_chars, expected) self.assertEqual(ExampleIUPACSequence('').nondegenerate_chars, expected) with self.assertRaises(AttributeError): ExampleIUPACSequence('').nondegenerate_chars = set("BAR") def test_gap_chars(self): expected = set(".-") self.assertIs(type(ExampleIUPACSequence.gap_chars), set) self.assertEqual(ExampleIUPACSequence.gap_chars, expected) ExampleIUPACSequence.gap_chars.add("_") self.assertEqual(ExampleIUPACSequence.gap_chars, expected) self.assertEqual(ExampleIUPACSequence('').gap_chars, expected) with self.assertRaises(AttributeError): ExampleIUPACSequence('').gap_chars = set("_ =") def test_alphabet(self): expected = set("ABC.-XYZ") self.assertIs(type(ExampleIUPACSequence.alphabet), set) self.assertEqual(ExampleIUPACSequence.alphabet, expected) ExampleIUPACSequence.alphabet.add("DEF") self.assertEqual(ExampleIUPACSequence.alphabet, expected) self.assertEqual(ExampleIUPACSequence('').alphabet, expected) with self.assertRaises(AttributeError): ExampleIUPACSequence('').alphabet = set("ABCDEFG.-WXYZ") def test_degenerate_map(self): expected = {"X": set("AB"), "Y": set("BC"), "Z": set("AC")} self.assertEqual(ExampleIUPACSequence.degenerate_map, expected) ExampleIUPACSequence.degenerate_map['W'] = set("ABC") ExampleIUPACSequence.degenerate_map['X'] = set("CA") self.assertEqual(ExampleIUPACSequence.degenerate_map, expected) self.assertEqual(ExampleIUPACSequence('').degenerate_map, expected) with self.assertRaises(AttributeError): ExampleIUPACSequence('').degenerate_map = {'W': "ABC"} def test_gaps(self): self.assertIs(type(ExampleIUPACSequence("").gaps()), np.ndarray) self.assertIs(ExampleIUPACSequence("").gaps().dtype, np.dtype('bool')) npt.assert_equal(ExampleIUPACSequence("ABCXBZYABC").gaps(), np.zeros(10).astype(bool)) npt.assert_equal(ExampleIUPACSequence(".-.-.").gaps(), np.ones(5).astype(bool)) npt.assert_equal(ExampleIUPACSequence("A.B-C.X-Y.").gaps(), np.array([0, 1] * 5, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("AB.AC.XY-").gaps(), np.array([0, 0, 1] * 3, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("A.BC.-").gaps(), np.array([0, 1, 0, 0, 1, 1], dtype=bool)) def test_has_gaps(self): self.assertIs(type(ExampleIUPACSequence("").has_gaps()), bool) self.assertIs(type(ExampleIUPACSequence("-").has_gaps()), bool) self.assertFalse(ExampleIUPACSequence("").has_gaps()) self.assertFalse(ExampleIUPACSequence("ABCXYZ").has_gaps()) self.assertTrue(ExampleIUPACSequence("-").has_gaps()) self.assertTrue(ExampleIUPACSequence("ABCXYZ-").has_gaps()) def test_degenerates(self): self.assertIs(type(ExampleIUPACSequence("").degenerates()), np.ndarray) self.assertIs(ExampleIUPACSequence("").degenerates().dtype, np.dtype('bool')) npt.assert_equal(ExampleIUPACSequence("ABCBC-.AB.").degenerates(), np.zeros(10).astype(bool)) npt.assert_equal(ExampleIUPACSequence("ZYZYZ").degenerates(), np.ones(5).astype(bool)) npt.assert_equal(ExampleIUPACSequence("AX.Y-ZBXCZ").degenerates(), np.array([0, 1] * 5, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("ABXACY.-Z").degenerates(), np.array([0, 0, 1] * 3, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("AZBCXY").degenerates(), np.array([0, 1, 0, 0, 1, 1], dtype=bool)) def test_has_degenerates(self): self.assertIs(type(ExampleIUPACSequence("").has_degenerates()), bool) self.assertIs(type(ExampleIUPACSequence("X").has_degenerates()), bool) self.assertFalse(ExampleIUPACSequence("").has_degenerates()) self.assertFalse(ExampleIUPACSequence("A-.BC").has_degenerates()) self.assertTrue(ExampleIUPACSequence("Z").has_degenerates()) self.assertTrue(ExampleIUPACSequence("ABC.XYZ-").has_degenerates()) def test_nondegenerates(self): self.assertIs(type(ExampleIUPACSequence("").nondegenerates()), np.ndarray) self.assertIs(ExampleIUPACSequence("").nondegenerates().dtype, np.dtype('bool')) npt.assert_equal(ExampleIUPACSequence("XYZYZ-.XY.").nondegenerates(), np.zeros(10).astype(bool)) npt.assert_equal(ExampleIUPACSequence("ABABA").nondegenerates(), np.ones(5).astype(bool)) npt.assert_equal(ExampleIUPACSequence("XA.B-AZCXA").nondegenerates(), np.array([0, 1] * 5, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("XXAZZB.-C").nondegenerates(), np.array([0, 0, 1] * 3, dtype=bool)) npt.assert_equal(ExampleIUPACSequence("YB.-AC").nondegenerates(), np.array([0, 1, 0, 0, 1, 1], dtype=bool)) def test_has_nondegenerates(self): self.assertIs(type(ExampleIUPACSequence("").has_nondegenerates()), bool) self.assertIs(type(ExampleIUPACSequence("A").has_nondegenerates()), bool) self.assertFalse(ExampleIUPACSequence("").has_nondegenerates()) self.assertFalse(ExampleIUPACSequence("X-.YZ").has_nondegenerates()) self.assertTrue(ExampleIUPACSequence("C").has_nondegenerates()) self.assertTrue(ExampleIUPACSequence(".XYZ-ABC").has_nondegenerates()) def test_degap(self): kw = { 'metadata': { 'id': 'some_id', 'description': 'some description', }, } self.assertEqual( ExampleIUPACSequence("", positional_metadata={'qual': []}, **kw).degap(), ExampleIUPACSequence("", positional_metadata={'qual': []}, **kw)) self.assertEqual( ExampleIUPACSequence( "ABCXYZ", positional_metadata={'qual': np.arange(6)}, **kw).degap(), ExampleIUPACSequence( "ABCXYZ", positional_metadata={'qual': np.arange(6)}, **kw)) self.assertEqual( ExampleIUPACSequence( "ABC-XYZ", positional_metadata={'qual': np.arange(7)}, **kw).degap(), ExampleIUPACSequence( "ABCXYZ", positional_metadata={'qual': [0, 1, 2, 4, 5, 6]}, **kw)) self.assertEqual( ExampleIUPACSequence( ".-ABC-XYZ.", positional_metadata={'qual': np.arange(10)}, **kw).degap(), ExampleIUPACSequence( "ABCXYZ", positional_metadata={'qual': [2, 3, 4, 6, 7, 8]}, **kw)) self.assertEqual( ExampleIUPACSequence( "---.-.-.-.-.", positional_metadata={'quality': np.arange(12)}, **kw).degap(), ExampleIUPACSequence( "", positional_metadata={'quality': np.array([], dtype=np.int64)}, **kw)) def test_expand_degenerates_no_degens(self): seq = ExampleIUPACSequence("ABCABCABC") self.assertEqual(list(seq.expand_degenerates()), [seq]) def test_expand_degenerates_all_degens(self): exp = [ExampleIUPACSequence('ABA'), ExampleIUPACSequence('ABC'), ExampleIUPACSequence('ACA'), ExampleIUPACSequence('ACC'), ExampleIUPACSequence('BBA'), ExampleIUPACSequence('BBC'), ExampleIUPACSequence('BCA'), ExampleIUPACSequence('BCC')] # Sort based on sequence string, as order is not guaranteed. obs = sorted(ExampleIUPACSequence('XYZ').expand_degenerates(), key=str) self.assertEqual(obs, exp) def test_expand_degenerates_with_metadata(self): kw = { "metadata": { "id": "some_id", "description": "some description" }, "positional_metadata": { "quality": np.arange(3), }, } exp = [ExampleIUPACSequence('ABA', **kw), ExampleIUPACSequence('ABC', **kw), ExampleIUPACSequence('BBA', **kw), ExampleIUPACSequence('BBC', **kw)] obs = sorted(ExampleIUPACSequence('XBZ', **kw).expand_degenerates(), key=str) self.assertEqual(obs, exp) def test_to_regex_no_degens(self): seq = ExampleIUPACSequence('ABC') regex = seq.to_regex() self.assertEqual(regex.pattern, str(seq)) def test_to_regex_with_degens(self): seq = ExampleIUPACSequence('AYZ') regex = seq.to_regex() self.assertFalse(any(regex.match(s) is None for s in 'ABA ABC ACA ACC'.split())) self.assertTrue(all(regex.match(s) is None for s in 'CBA BBA ABB AAA'.split())) def test_find_motifs_no_motif(self): seq = ExampleMotifsTester("ABCABCABC") with self.assertRaises(ValueError) as cm: seq.find_motifs("doesn't-exist") self.assertIn("doesn't-exist", str(cm.exception)) seq = ExampleIUPACSequence("ABCABCABC") with self.assertRaises(ValueError) as cm: seq.find_motifs("doesn't-exist") self.assertIn("doesn't-exist", str(cm.exception)) def test_find_motifs(self): seq = ExampleMotifsTester("ABC") self.assertEqual(seq.find_motifs("name1"), "ABC") self.assertEqual(seq.find_motifs("name2"), 3) def test_repr(self): # basic sanity checks for custom repr stats. more extensive testing is # performed on Sequence.__repr__ # minimal obs = repr(ExampleIUPACSequence('')) self.assertEqual(obs.count('\n'), 7) self.assertTrue(obs.startswith('ExampleIUPACSequence')) self.assertIn('length: 0', obs) self.assertIn('has gaps: False', obs) self.assertIn('has degenerates: False', obs) self.assertIn('has non-degenerates: False', obs) self.assertTrue(obs.endswith('-')) # no metadata, mix of gaps, degenerates, and non-degenerates obs = repr(ExampleIUPACSequence('AY-B')) self.assertEqual(obs.count('\n'), 8) self.assertTrue(obs.startswith('ExampleIUPACSequence')) self.assertIn('length: 4', obs) self.assertIn('has gaps: True', obs) self.assertIn('has degenerates: True', obs) self.assertIn('has non-degenerates: True', obs) self.assertTrue(obs.endswith('0 AY-B')) # metadata and positional metadata of mixed types obs = repr( ExampleIUPACSequence( 'ABCA', metadata={'foo': 42, u'bar': 33.33, None: True, False: {}, (1, 2): 3, 'acb' * 100: "'"}, positional_metadata={'foo': range(4), 42: ['a', 'b', [], 'c']})) self.assertEqual(obs.count('\n'), 18) self.assertTrue(obs.startswith('ExampleIUPACSequence')) self.assertIn('None: True', obs) self.assertIn('\'foo\': 42', obs) self.assertIn('42: <dtype: object>', obs) self.assertIn('\'foo\': <dtype: int64>', obs) self.assertIn('length: 4', obs) self.assertIn('has gaps: False', obs) self.assertIn('has degenerates: False', obs) self.assertIn('has non-degenerates: True', obs) self.assertTrue(obs.endswith('0 ABCA')) # sequence spanning > 5 lines obs = repr(ExampleIUPACSequence('A' * 301)) self.assertEqual(obs.count('\n'), 12) self.assertTrue(obs.startswith('ExampleIUPACSequence')) self.assertIn('length: 301', obs) self.assertIn('has gaps: False', obs) self.assertIn('has degenerates: False', obs) self.assertIn('has non-degenerates: True', obs) self.assertIn('...', obs) self.assertTrue(obs.endswith('300 A')) if __name__ == "__main__": main()
SamStudio8/scikit-bio
skbio/sequence/tests/test_iupac_sequence.py
Python
bsd-3-clause
19,961
[ "scikit-bio" ]
bbc339777bc7d48384fe33bc209c9385c3c669184b2ef972227cdfd1f0ab5e2f
#!/usr/bin/env python # -*- encoding: utf-8 -*- # CREATED:2015-02-15 10:06:03 by Brian McFee <brian.mcfee@nyu.edu> '''Helpful tools for deprecation''' import warnings from decorator import decorator import six def moved(moved_from, version, version_removed): '''This is a decorator which can be used to mark functions as moved/renamed. It will result in a warning being emitted when the function is used. ''' def __wrapper(func, *args, **kwargs): '''Warn the user, and then proceed.''' code = six.get_function_code(func) warnings.warn_explicit( "{:s}\n\tThis function was moved to '{:s}.{:s}' in " "librosa version {:s}." "\n\tThis alias will be removed in librosa version " "{:s}.".format(moved_from, func.__module__, func.__name__, version, version_removed), category=DeprecationWarning, filename=code.co_filename, lineno=code.co_firstlineno + 1 ) return func(*args, **kwargs) return decorator(__wrapper) def deprecated(version, version_removed): '''This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.''' def __wrapper(func, *args, **kwargs): '''Warn the user, and then proceed.''' code = six.get_function_code(func) warnings.warn_explicit( "{:s}.{:s}\n\tDeprecated as of librosa version {:s}." "\n\tIt will be removed in librosa version {:s}." .format(func.__module__, func.__name__, version, version_removed), category=DeprecationWarning, filename=code.co_filename, lineno=code.co_firstlineno + 1 ) return func(*args, **kwargs) return decorator(__wrapper) '''Define the optional_jit decorator If numba is importable, use numba.jit. Else create a no-op decorator. ''' try: from numba.decorators import jit as optional_jit except ImportError: def optional_jit(*_, **__): def __wrapper(func, *args, **kwargs): return func(*args, **kwargs) return decorator(__wrapper)
ruohoruotsi/librosa
librosa/util/decorators.py
Python
isc
2,239
[ "Brian" ]
dc813b9d71bf5dc6ce08d8f8c49aa6bcb351f2e6a8bdf2201d2c811f0b8aa366
#!/usr/bin/env python # coding:utf-8 from sqlalchemy import * from base_model import * class UserVisitLog(Model): __tablename__ = 'tb_user_visit_log' id = Column(Integer, primary_key=True) #for UV(user visit): anonymous:userid=sessionid uid = Column(String(255), nullable=False) login_time = Column(DateTime, nullable=False) logout_time = Column(DateTime, default=None) sid = Column(String(255), nullable=False) srcip = Column(String(255), nullable=False) location = Column(String(1024), default=None)
cshzc/X1Tool
src/server/database/models/use_visity_log.py
Python
gpl-2.0
541
[ "VisIt" ]
346ba2475289cbe299a14cba854aac12042364608887e7b24851bc202ee3c0db
# Copyright 2015-2016 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Calculate the number of blank lines between top-level entities. Calculates how many blank lines we need between classes, functions, and other entities at the same level. CalculateBlankLines(): the main function exported by this module. Annotations: newlines: The number of newlines required before the node. """ from lib2to3 import pytree from yapf.yapflib import py3compat from yapf.yapflib import pytree_utils from yapf.yapflib import pytree_visitor _NO_BLANK_LINES = 1 _ONE_BLANK_LINE = 2 _TWO_BLANK_LINES = 3 _PYTHON_STATEMENTS = frozenset({ 'small_stmt', 'expr_stmt', 'print_stmt', 'del_stmt', 'pass_stmt', 'break_stmt', 'continue_stmt', 'return_stmt', 'raise_stmt', 'yield_stmt', 'import_stmt', 'global_stmt', 'exec_stmt', 'assert_stmt', 'if_stmt', 'while_stmt', 'for_stmt', 'try_stmt', 'with_stmt', 'nonlocal_stmt', 'async_stmt', 'simple_stmt' }) def CalculateBlankLines(tree): """Run the blank line calculator visitor over the tree. This modifies the tree in place. Arguments: tree: the top-level pytree node to annotate with subtypes. """ blank_line_calculator = _BlankLineCalculator() blank_line_calculator.Visit(tree) class _BlankLineCalculator(pytree_visitor.PyTreeVisitor): """_BlankLineCalculator - see file-level docstring for a description.""" def __init__(self): self.class_level = 0 self.function_level = 0 self.last_comment_lineno = 0 self.last_was_decorator = False self.last_was_class_or_function = False def Visit_simple_stmt(self, node): # pylint: disable=invalid-name self.DefaultNodeVisit(node) if pytree_utils.NodeName(node.children[0]) == 'COMMENT': self.last_comment_lineno = node.children[0].lineno def Visit_decorator(self, node): # pylint: disable=invalid-name if (self.last_comment_lineno and self.last_comment_lineno == node.children[0].lineno - 1): self._SetNumNewlines(node.children[0], _NO_BLANK_LINES) else: self._SetNumNewlines(node.children[0], self._GetNumNewlines(node)) for child in node.children: self.Visit(child) self.last_was_decorator = True def Visit_classdef(self, node): # pylint: disable=invalid-name self.last_was_class_or_function = False index = self._SetBlankLinesBetweenCommentAndClassFunc(node) self.last_was_decorator = False self.class_level += 1 for child in node.children[index:]: self.Visit(child) self.class_level -= 1 self.last_was_class_or_function = True def Visit_funcdef(self, node): # pylint: disable=invalid-name self.last_was_class_or_function = False index = self._SetBlankLinesBetweenCommentAndClassFunc(node) if _AsyncFunction(node): # Move the number of blank lines to the async keyword. num_newlines = pytree_utils.GetNodeAnnotation( node.children[0], pytree_utils.Annotation.NEWLINES) self._SetNumNewlines(node.prev_sibling, num_newlines) self._SetNumNewlines(node.children[0], None) self.last_was_decorator = False self.function_level += 1 for child in node.children[index:]: self.Visit(child) self.function_level -= 1 self.last_was_class_or_function = True def DefaultNodeVisit(self, node): """Override the default visitor for Node. This will set the blank lines required if the last entity was a class or function. Arguments: node: (pytree.Node) The node to visit. """ if self.last_was_class_or_function: if pytree_utils.NodeName(node) in _PYTHON_STATEMENTS: leaf = _GetFirstChildLeaf(node) if pytree_utils.NodeName(leaf) != 'COMMENT': self._SetNumNewlines(leaf, self._GetNumNewlines(leaf)) self.last_was_class_or_function = False super(_BlankLineCalculator, self).DefaultNodeVisit(node) def _SetBlankLinesBetweenCommentAndClassFunc(self, node): """Set the number of blanks between a comment and class or func definition. Class and function definitions have leading comments as children of the classdef and functdef nodes. Arguments: node: (pytree.Node) The classdef or funcdef node. Returns: The index of the first child past the comment nodes. """ index = 0 while pytree_utils.IsCommentStatement(node.children[index]): # Standalone comments are wrapped in a simple_stmt node with the comment # node as its only child. self.Visit(node.children[index].children[0]) self._SetNumNewlines(node.children[index].children[0], _ONE_BLANK_LINE) index += 1 if (index and node.children[index].lineno - 1 == node.children[index - 1].children[0].lineno): self._SetNumNewlines(node.children[index], _NO_BLANK_LINES) else: if self.last_comment_lineno + 1 == node.children[index].lineno: num_newlines = _NO_BLANK_LINES else: num_newlines = self._GetNumNewlines(node) self._SetNumNewlines(node.children[index], num_newlines) return index def _GetNumNewlines(self, node): if self.last_was_decorator: return _NO_BLANK_LINES elif self._IsTopLevel(node): return _TWO_BLANK_LINES return _ONE_BLANK_LINE def _SetNumNewlines(self, node, num_newlines): pytree_utils.SetNodeAnnotation(node, pytree_utils.Annotation.NEWLINES, num_newlines) def _IsTopLevel(self, node): return (not (self.class_level or self.function_level) and _StartsInZerothColumn(node)) def _StartsInZerothColumn(node): return (_GetFirstChildLeaf(node).column == 0 or (_AsyncFunction(node) and node.prev_sibling.column == 0)) def _AsyncFunction(node): return (py3compat.PY3 and node.prev_sibling and pytree_utils.NodeName(node.prev_sibling) == 'ASYNC') def _GetFirstChildLeaf(node): if isinstance(node, pytree.Leaf): return node return _GetFirstChildLeaf(node.children[0])
wklken/yapf
yapf/yapflib/blank_line_calculator.py
Python
apache-2.0
6,497
[ "VisIt" ]
c9d1a464bb52b9fc95b7af39cc40fab4ef23a384128bb89f5e063f39370bdeae
from collections import OrderedDict from edc_constants.constants import REQUIRED, NOT_REQUIRED, ADDITIONAL, NOT_ADDITIONAL from edc_visit_schedule.classes import ( VisitScheduleConfiguration, site_visit_schedules, CrfTuple, MembershipFormTuple, ScheduleTuple, RequisitionPanelTuple) from tshilo_dikotla.constants import INFANT from ..models import InfantVisit, InfantBirth class InfantBirthVisitSchedule(VisitScheduleConfiguration): name = 'birth visit schedule' app_label = 'td_infant' membership_forms = OrderedDict({ 'infant_enrollment': MembershipFormTuple('infant_enrollment', InfantBirth, True)}) schedules = OrderedDict({ 'Infant Enrollment': ScheduleTuple('Infant Enrollment', 'infant_enrollment', None, None)}) infant_birth_requisitions = ( RequisitionPanelTuple( 10, 'td_lab', 'infantrequisition', 'Infant Insulin', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 20, 'td_lab', 'infantrequisition', 'Infant Serum (Store Only)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 30, 'td_lab', 'infantrequisition', 'Infant Glucose', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 40, 'td_lab', 'infantrequisition', 'Infant PBMC PL', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 50, 'td_lab', 'infantrequisition', 'DNA PCR', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), ) infant_1month_requisitions = ( RequisitionPanelTuple( 10, 'td_lab', 'infantrequisition', 'Infant Insulin', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 20, 'td_lab', 'infantrequisition', 'Infant Glucose', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 30, 'td_lab', 'infantrequisition', 'DNA PCR', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 40, 'td_lab', 'infantrequisition', 'PBMC Plasma (STORE ONLY)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 50, 'td_lab', 'infantrequisition', 'Infant Serum (Store Only)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 60, 'td_lab', 'infantrequisition', 'DBS (Store Only)', 'STORAGE', 'WB', NOT_REQUIRED, ADDITIONAL), ) infant_followup_requisitions = ( RequisitionPanelTuple( 10, 'td_lab', 'infantrequisition', 'DNA PCR', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), RequisitionPanelTuple( 20, 'td_lab', 'infantrequisition', 'Infant Glucose', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), RequisitionPanelTuple( 30, 'td_lab', 'infantrequisition', 'Infant Insulin', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), RequisitionPanelTuple( 40, 'td_lab', 'infantrequisition', 'ELISA', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), ) infant_36month_requisitions = ( RequisitionPanelTuple( 10, 'td_lab', 'infantrequisition', 'Infant Insulin', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 20, 'td_lab', 'infantrequisition', 'Infant Glucose', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 30, 'td_lab', 'infantrequisition', 'PBMC Plasma (STORE ONLY)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 40, 'td_lab', 'infantrequisition', 'Infant Serum (Store Only)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 50, 'td_lab', 'infantrequisition', 'DNA PCR', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), RequisitionPanelTuple( 60, 'td_lab', 'infantrequisition', 'ELISA', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), ) infant_18month_requisitions = ( RequisitionPanelTuple( 10, 'td_lab', 'infantrequisition', 'Infant Insulin', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 20, 'td_lab', 'infantrequisition', 'Infant Glucose', 'TEST', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 40, 'td_lab', 'infantrequisition', 'ELISA', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), RequisitionPanelTuple( 50, 'td_lab', 'infantrequisition', 'Infant Serum (Store Only)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 60, 'td_lab', 'infantrequisition', 'PBMC Plasma (STORE ONLY)', 'STORAGE', 'WB', REQUIRED, ADDITIONAL), RequisitionPanelTuple( 70, 'td_lab', 'infantrequisition', 'DNA PCR', 'TEST', 'WB', NOT_REQUIRED, ADDITIONAL), ) visit_definitions = OrderedDict() visit_definitions['2000'] = { 'title': 'Birth', 'time_point': 0, 'base_interval': 0, 'base_interval_unit': 'D', 'window_lower_bound': 0, 'window_lower_bound_unit': 'D', 'window_upper_bound': 0, 'window_upper_bound_unit': 'D', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_birth_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantbirthdata', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantbirthexam', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantbirthfeedingvaccine', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantbirtharv', REQUIRED, NOT_ADDITIONAL), CrfTuple(50, 'td_infant', 'infantcongenitalanomalies', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantdeathreport', NOT_REQUIRED, ADDITIONAL), CrfTuple(70, 'td_infant', 'infantnvpdispensing', NOT_REQUIRED, ADDITIONAL))} visit_definitions['2010'] = { 'title': 'Infant 1 Month Visit', 'time_point': 10, 'base_interval': 1, 'base_interval_unit': 'M', 'window_lower_bound': 15, 'window_lower_bound_unit': 'D', 'window_upper_bound': 15, 'window_upper_bound_unit': 'D', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_1month_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(50, 'td_infant', 'infantarvproph', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple( 70, 'td_infant', 'infantnvpadjustment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2020'] = { 'title': 'Infant 2 Month Visit', 'time_point': 20, 'base_interval': 2, 'base_interval_unit': 'M', 'window_lower_bound': 15, 'window_lower_bound_unit': 'D', 'window_upper_bound': 60, 'window_upper_bound_unit': 'D', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_followup_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL), CrfTuple(50, 'td_infant', 'infantarvproph', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL))} visit_definitions['2060'] = { 'title': 'Infant 6 Month Visit', 'time_point': 60, 'base_interval': 6, 'base_interval_unit': 'M', 'window_lower_bound': 89, 'window_lower_bound_unit': 'D', 'window_upper_bound': 60, 'window_upper_bound_unit': 'D', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_followup_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2120'] = { 'title': 'Infant 12 Month Visit', 'time_point': 120, 'base_interval': 12, 'base_interval_unit': 'M', 'window_lower_bound': 4, 'window_lower_bound_unit': 'M', 'window_upper_bound': 3, 'window_upper_bound_unit': 'M', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_followup_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2180'] = { 'title': 'Infant 18 Month Visit', 'time_point': 180, 'base_interval': 18, 'base_interval_unit': 'M', 'window_lower_bound': 3, 'window_lower_bound_unit': 'M', 'window_upper_bound': 3, 'window_upper_bound_unit': 'M', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_18month_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2240'] = { 'title': 'Infant 24 Month Visit', 'time_point': 240, 'base_interval': 24, 'base_interval_unit': 'M', 'window_lower_bound': 3, 'window_lower_bound_unit': 'M', 'window_upper_bound': 3, 'window_upper_bound_unit': 'M', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_followup_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2300'] = { 'title': 'Infant 30 Month Visit', 'time_point': 300, 'base_interval': 30, 'base_interval_unit': 'M', 'window_lower_bound': 3, 'window_lower_bound_unit': 'M', 'window_upper_bound': 3, 'window_upper_bound_unit': 'M', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_followup_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} visit_definitions['2360'] = { 'title': 'Infant 36 Month Visit', 'time_point': 360, 'base_interval': 36, 'base_interval_unit': 'M', 'window_lower_bound': 3, 'window_lower_bound_unit': 'M', 'window_upper_bound': 3, 'window_upper_bound_unit': 'M', 'grouping': INFANT, 'visit_tracking_model': InfantVisit, 'schedule': 'Infant Enrollment', 'instructions': 'V1', 'requisitions': infant_36month_requisitions, 'entries': ( CrfTuple(10, 'td_infant', 'infantfu', REQUIRED, NOT_ADDITIONAL), CrfTuple(20, 'td_infant', 'infantfuphysical', REQUIRED, NOT_ADDITIONAL), CrfTuple(30, 'td_infant', 'infantfudx', REQUIRED, NOT_ADDITIONAL), CrfTuple(40, 'td_infant', 'infantfunewmed', REQUIRED, NOT_ADDITIONAL), CrfTuple(60, 'td_infant', 'infantfeeding', REQUIRED, NOT_ADDITIONAL), CrfTuple(70, 'td_infant', 'solidfoodassessment', REQUIRED, NOT_ADDITIONAL), CrfTuple(80, 'td_infant', 'infantfuimmunizations', REQUIRED, NOT_ADDITIONAL),)} site_visit_schedules.register(InfantBirthVisitSchedule)
botswana-harvard/tshilo-dikotla
td_infant/visit_schedule/infant_birth_visit_schedule.py
Python
gpl-2.0
16,178
[ "VisIt" ]
4e9992bc28fe8149a44eec86ea71bf25aa29df0f28f581257fb7616235993def
""" Module to set up run time parameters for Clawpack. The values set in the function setrun are then written out to data files that will be read in by the Fortran code. """ import os import numpy as np try: CLAW = os.environ['CLAW'] except: raise Exception("*** Must first set CLAW enviornment variable") # Scratch directory for storing topo and dtopo files: scratch_dir = os.path.join(CLAW, 'geoclaw', 'scratch') #------------------------------ def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ #probdata = rundata.new_UserData(name='probdata',fname='setprob.data') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = -120.0 # west longitude clawdata.upper[0] = -60.0 # east longitude clawdata.lower[1] = -60.0 # south latitude clawdata.upper[1] = 0.0 # north latitude # Number of grid cells: Coarsest grid clawdata.num_cells[0] = 30 clawdata.num_cells[1] = 30 # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # Note: If restarting, you must also change the Makefile to set: # RESTART = True # If restarting, t0 above should be from original run, and the # restart_file 'fort.chkNNNNN' specified below should be in # the OUTDIR indicated in Makefile. clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00036' # File to use for restart data # ------------- # Output times: #-------------- # Specify at what times the results should be written to fort.q files. # Note that the time integration stops after the final output time. # The solution at initial time t0 is always written in addition. clawdata.output_style = 1 if clawdata.output_style==1: # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 5 clawdata.tfinal = 5*3600. clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = np.linspace(4,8,17) * 3600. elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 1 clawdata.total_steps = 3 clawdata.output_t0 = True clawdata.output_format = 'ascii' # 'ascii' or 'netcdf' clawdata.output_q_components = 'all' # need all clawdata.output_aux_components = 'none' # eta=h+B is in q clawdata.output_aux_onlyonce = False # output aux arrays each frame # --------------------------------------------------- # Verbosity of messages to screen during integration: # --------------------------------------------------- # The current t, dt, and cfl will be printed every time step # at AMR levels <= verbosity. Set verbosity = 0 for no printing. # (E.g. verbosity == 2 means print only on levels 1 and 2.) clawdata.verbosity = 1 # -------------- # Time stepping: # -------------- # if dt_variable==1: variable time steps used based on cfl_desired, # if dt_variable==0: fixed time steps dt = dt_initial will always be used. clawdata.dt_variable = True # Initial time step for variable dt. # If dt_variable==0 then dt=dt_initial for all steps: clawdata.dt_initial = 0.2 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.75 clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? (not yet available for AMR) clawdata.dimensional_split = 'unsplit' # For unsplit method, transverse_waves can be # 0 or 'none' ==> donor cell (only normal solver used) # 1 or 'increment' ==> corner transport of waves # 2 or 'all' ==> corner transport of 2nd order corrections too clawdata.transverse_waves = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # List of limiters to use for each wave family: # Required: len(limiter) == num_waves # Some options: # 0 or 'none' ==> no limiter (Lax-Wendroff) # 1 or 'minmod' ==> minmod # 2 or 'superbee' ==> superbee # 3 or 'mc' ==> MC limiter # 4 or 'vanleer' ==> van Leer clawdata.limiter = ['mc', 'mc', 'mc'] clawdata.use_fwaves = True # True ==> use f-wave version of algorithms # Source terms splitting: # src_split == 0 or 'none' ==> no source term (src routine never called) # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. clawdata.source_split = 'godunov' # -------------------- # Boundary conditions: # -------------------- # Number of ghost cells (usually 2) clawdata.num_ghost = 2 # Choice of BCs at xlower and xupper: # 0 => user specified (must modify bcN.f to use this option) # 1 => extrapolation (non-reflecting outflow) # 2 => periodic (must specify this at both boundaries) # 3 => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' clawdata.bc_upper[0] = 'extrap' clawdata.bc_lower[1] = 'extrap' clawdata.bc_upper[1] = 'extrap' # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 0 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif clawdata.checkpt_style == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [0.1,0.15] elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = 3 # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = [2,6] amrdata.refinement_ratios_y = [2,6] amrdata.refinement_ratios_t = [2,6] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center','capacity','yleft'] # Flag using refinement routine flag2refine rather than richardson error amrdata.flag_richardson = False # use Richardson? amrdata.flag2refine = True # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 2 # clustering alg. cutoff for (# flagged pts) / (total # of cells refined) # (closer to 1.0 => more small grids may be needed to cover flagged cells) amrdata.clustering_cutoff = 0.700000 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # ----- For developers ----- # Toggle debugging print statements: amrdata.dprint = False # print domain flags amrdata.eprint = False # print err est flags amrdata.edebug = False # even more err est flags amrdata.gprint = False # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = False # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = True # time step reporting each level amrdata.uprint = False # update/upbnd reporting # More AMR parameters can be set -- see the defaults in pyclaw/data.py # --------------- # Regions: # --------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # Allow only level 1 as default everywhere: rundata.regiondata.regions.append([1, 1, 0., 1e9, -180, 180, -90, 90]) # Force refinement around earthquake source region for first hour: rundata.regiondata.regions.append([3, 3, 0., 3600., -85,-72,-38,-25]) # Allow up to level 3 in northeastern part of domain: rundata.regiondata.regions.append([1, 3, 0., 1.e9, -90,-60,-30,0]) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([32412, -86.392, -17.975, 0., 1.e10]) return rundata # end of function setrun # ---------------------- #------------------- def setgeo(rundata): #------------------- """ Set GeoClaw specific runtime parameters. For documentation see .... """ try: geo_data = rundata.geo_data except: print "*** Error, this rundata has no geo_data attribute" raise AttributeError("Missing geo_data attribute") # == Physics == geo_data.gravity = 9.81 geo_data.coordinate_system = 2 geo_data.earth_radius = 6367.5e3 # == Forcing Options geo_data.coriolis_forcing = False # == Algorithm and Initial Conditions == geo_data.sea_level = 0.0 geo_data.dry_tolerance = 1.e-3 geo_data.friction_forcing = True geo_data.manning_coefficient =.025 geo_data.friction_depth = 1e6 # Refinement settings refinement_data = rundata.refinement_data refinement_data.variable_dt_refinement_ratios = True refinement_data.wave_tolerance = 0.02 refinement_data.deep_depth = 1e2 refinement_data.max_level_deep = 3 # == settopo.data values == topo_data = rundata.topo_data # for topography, append lines of the form # [topotype, minlevel, maxlevel, t1, t2, fname] topo_path = os.path.join(scratch_dir, 'etopo10min120W60W60S0S.asc') topo_data.topofiles.append([2, 1, 3, 0., 1.e10, topo_path]) # == setdtopo.data values == dtopo_data = rundata.dtopo_data # for moving topography, append lines of the form : (<= 1 allowed for now!) # [topotype, minlevel,maxlevel,fname] dtopo_path = os.path.join(scratch_dir, 'dtopo_usgs100227.tt3') dtopo_data.dtopofiles.append([3,3,3,dtopo_path]) dtopo_data.dt_max_dtopo = 0.2 # == setqinit.data values == rundata.qinit_data.qinit_type = 0 rundata.qinit_data.qinitfiles = [] # for qinit perturbations, append lines of the form: (<= 1 allowed for now!) # [minlev, maxlev, fname] # == setfixedgrids.data values == fixed_grids = rundata.fixed_grid_data # for fixed grids append lines of the form # [t1,t2,noutput,x1,x2,y1,y2,xpoints,ypoints,\ # ioutarrivaltimes,ioutsurfacemax] return rundata # end of function setgeo # ---------------------- if __name__ == '__main__': # Set up run-time parameters and write all data files. import sys rundata = setrun(*sys.argv[1:]) rundata.write()
clawpack/geoclaw_tutorial_csdms2016
chile2010b/setrun_original.py
Python
bsd-2-clause
13,572
[ "NetCDF" ]
f3fbd8fd8d882bd76ac23a2c10268a4ef2a1299aa0346e00eefadabc1b9614fd
# python3 # pylint: disable=g-bad-file-header # Copyright 2021 DeepMind Technologies Limited. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ """Factory methods for Bayes by Backprop agent.""" import dataclasses from typing import Sequence from enn import base as enn_base from enn import losses from enn import networks import jax.numpy as jnp from neural_testbed import base as testbed_base from neural_testbed.agents import enn_agent import optax @dataclasses.dataclass class BBBConfig: """Configuration for bbb agent.""" hidden_sizes: Sequence[int] = (50, 50) # Hidden sizes for the neural network num_batches: int = 1000 # Number of SGD steps learning_rate: float = 1e-3 # Learning rate for adam optimizer seed: int = 0 # Initialization seed sigma_1: float = 0.3 # Standard deviation of the first Gaussian prior sigma_2: float = 0.75 # Standard deviation of the second Gaussian prior mixture_scale: float = 1. # Scale for mixture of two Gauusian densities num_index_samples: int = 8 # Number of index samples to average over kl_method: str = 'analytical' # How to find KL of prior and vi posterior adaptive_scale: bool = True # Whether to scale prior KL with temp output_scale: bool = False # Whether to scale output with temperature batch_strategy: bool = False # Whether to scale num_batches with data ratio def make_agent(config: BBBConfig) -> enn_agent.VanillaEnnAgent: """Factory method to create a BBB agent.""" def make_enn(prior: testbed_base.PriorKnowledge) -> enn_base.EpistemicNetwork: """Makes ENN.""" temperature = 1. if config.output_scale: temperature = prior.temperature enn = networks.make_bbb_enn( base_output_sizes=list(config.hidden_sizes) + [prior.num_classes], dummy_input=jnp.zeros(shape=(prior.input_dim,)), temperature=temperature) return enn def make_loss(prior: testbed_base.PriorKnowledge, enn: enn_base.EpistemicNetwork) -> enn_base.LossFn: """Define the ENN architecture from the prior.""" del enn # Loss assuming a classification task. assert prior.num_classes > 1 log_likelihood_fn = losses.get_categorical_loglike_fn( num_classes=prior.num_classes) if config.kl_method == 'analytical': model_prior_kl_fn = losses.get_analytical_diagonal_linear_model_prior_kl_fn( prior.num_train, config.sigma_1) elif config.kl_method == 'sample_based': model_prior_kl_fn = losses.get_sample_based_model_prior_kl_fn( prior.num_train, config.sigma_1, config.sigma_2, config.mixture_scale) else: ValueError(f'Invalid kl_method={config.kl_method}') if config.adaptive_scale: single_loss = losses.ElboLoss(log_likelihood_fn, model_prior_kl_fn, prior.temperature, prior.input_dim) else: single_loss = losses.ElboLoss(log_likelihood_fn, model_prior_kl_fn) loss_fn = losses.average_single_index_loss( single_loss, num_index_samples=config.num_index_samples) return loss_fn def batch_strategy(prior: testbed_base.PriorKnowledge) -> int: if not config.batch_strategy: return config.num_batches data_ratio = prior.num_train / prior.input_dim if data_ratio > 500: # high data regime return config.num_batches * 5 elif data_ratio < 5: # low data regime return config.num_batches // 5 else: return config.num_batches agent_config = enn_agent.VanillaEnnConfig( enn_ctor=make_enn, loss_ctor=make_loss, num_batches=batch_strategy, optimizer=optax.adam(config.learning_rate), seed=config.seed, ) return enn_agent.VanillaEnnAgent(agent_config)
deepmind/neural_testbed
neural_testbed/agents/factories/bbb.py
Python
apache-2.0
4,315
[ "Gaussian" ]
9069f05cbf79b5af55cfe18ece0729d9b883baca8853eb0d6a0351de907682ac
""" This file provides a more advanced example of vtkTable access and manipulation methods. """ from vtk import * #------------------------------------------------------------------------------ # Script Entry Point (i.e., main() ) #------------------------------------------------------------------------------ if __name__ == "__main__": """ Main entry point of this python script """ print "vtkTable Example 4: Accessing vtkTable data elements" # Load our table from a CSV file (covered in table2.py) csv_source = vtkDelimitedTextReader() csv_source.SetFieldDelimiterCharacters(",") csv_source.SetHaveHeaders(True) csv_source.SetFileName("table_data.csv") csv_source.Update() csv_source.GetOutput().Dump(6) T = csv_source.GetOutput() # Print some information about the table print "Number of Columns =", T.GetNumberOfColumns() print "Number of Rows =", T.GetNumberOfRows() print "Get column 1, row 4 data: ", T.GetColumn(1).GetValue(4) # Add a new row to the table new_row = [8, "Luis", 68] for i in range( T.GetNumberOfColumns()): T.GetColumn(i).InsertNextValue( str(new_row[i]) ) print "Table after new row appenended:" T.Dump(6) print "vtkTable Example 4: Finished."
b3c/VTK-5.8
Examples/Infovis/Python/tables4.py
Python
bsd-3-clause
1,290
[ "VTK" ]
b9178b3f2ce5e6744bdab2fc72458888cf87f59ac480213e3448cf2d49fd6d69
import numpy as np import pylab as pl class SMP(): ### this is a soft margin perceptron also supporting kernels def __init__(self, max_it = 4400, kernel = None, degree=3, disp=1): self.max_it = max_it self.disp = disp if kernel == 'poly': self.kernel = lambda x, y: (np.inner(x, y) + 1)**degree elif kernel == 'gaussian': self.kernel = lambda x, y: np.exp(np.inner(x - y, x - y)/1) else: # kernel == 'inner' self.kernel = None def train(self, X, y, C = 0.1): self.fit(X, y, C) def fit(self, X, y, C = 0.1, lam = 1, sC = 0.1, mu = 0.1, learning_rate = 0.02): # coefficients if self.kernel: alpha = np.zeros(np.shape(X)[0]) else: alpha = np.zeros(np.shape(X)[1]) b = 0.0 xi = np.zeros(np.shape(X)[0]) # build kernel matrix if self.kernel: K = np.asarray( self.kernel(X, X) ) # index fields indices = [i for i in range(len(y))] index_count = [0] * len(y) first_recount = True threshold = min(len(y), self.max_it)/5 # loop k = 0; loop = True; while loop and k < self.max_it: k = k + 1; loop = False alpha *= (1.0 - C * learning_rate) # cycle through samples for i in indices: update = 0. if xi[i] >= 0 else mu # misclassification if self.kernel and 1 - xi[i] - y[i] * (np.inner(y*alpha,K[:, i]) + b) >= 0 : loop = True update += lam alpha[i] += learning_rate * lam b += learning_rate * lam*y[i] index_count[i] = 0 # misclassification elif not self.kernel and 1 - xi[i] - y[i] * (np.inner(alpha,X[i, :]) + b) >= 0 : loop = True update += lam alpha += learning_rate * lam * y[i] * X[i,:] b += learning_rate * lam*y[i] index_count[i] = 0 # correct classification else: index_count[i] += 1 if index_count[i] > threshold: indices.remove(i) xi[i] -= learning_rate * (sC - update) # use all arrays before reaching the end. if k == self.max_it - threshold or loop == False: if first_recount : loop = True first_recount = False indices = [i for i in range(len(y))] # save results self.alpha = alpha self.b = b self.X = X self.y = y if self.disp > 0: print 'k =', k if self.disp > 1: print 'alpha =', self.alpha # get posterior probability for a single samples mainly def classify(self, z): z = np.asarray(z) if self.kernel: K = np.asarray( map(lambda x: self.kernel(x, z), self.X) ) return np.dot(self.y*self.alpha, K) + self.b else: return np.inner(self.alpha, z) + self.b # classify for lists of samples def predict(self, grid): t = [] for z in grid: if self.classify(z) < 0: t.append(0) else: t.append(1) return np.asarray(t);
wedgeCountry/SMP
SMP.py
Python
gpl-3.0
2,738
[ "Gaussian" ]
d21e51c8d3c835f1fbac1a792290719af13068caaa415340bc2734699ec3a9d7
""" Copyright (C) 2017 Roberto Bruttomesso <roberto.bruttomesso@gmail.com> This file is distributed under the terms of the 3-clause BSD License. A copy of the license can be found in the root directory or at https://opensource.org/licenses/BSD-3-Clause. Author: Roberto Bruttomesso <roberto.bruttomesso@gmail.com> Date: 27/03/2017 This module implements the main parsing routine of Lustre files """ from antlr4 import FileStream, CommonTokenStream from intrepyd.lustre2py.LustreLexer import LustreLexer from intrepyd.lustre2py.LustreParser import LustreParser from intrepyd.lustre2py.astbuilder import ASTBuilder from intrepyd.lustre2py.ast import Ast def parse(infile): """ Parse the provided input file and translates into a python equivalent file for intrepyd """ lexer = LustreLexer(FileStream(infile)) stream = CommonTokenStream(lexer) parser = LustreParser(stream) tree = parser.program() ast_builder = ASTBuilder() ast_builder.visit(tree) return Ast(ast_builder.nodes)
formalmethods/intrepyd
intrepyd/lustre2py/parser.py
Python
bsd-3-clause
1,027
[ "VisIt" ]
68065409c0ff10646b4f2568b238e00cfa99846e53068d9f49861dcf73fc9146
# -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 ## ## Copyright (C) 2012 Async Open Source <http://www.async.com.br> ## All rights reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <stoq-devel@async.com.br> ## # pylint: enable=E1101 from decimal import Decimal import collections from kiwi.currency import currency from storm.references import Reference, ReferenceSet from storm.expr import And, Join from zope.interface import implementer from stoqlib.database.properties import (UnicodeCol, DateTimeCol, IntCol, PriceCol, QuantityCol, IdentifierCol, IdCol, EnumCol) from stoqlib.database.runtime import get_current_branch from stoqlib.domain.base import Domain from stoqlib.domain.fiscal import Invoice, FiscalBookEntry from stoqlib.domain.interfaces import IContainer, IInvoiceItem, IInvoice from stoqlib.domain.payment.method import PaymentMethod from stoqlib.domain.payment.payment import Payment from stoqlib.domain.product import StockTransactionHistory from stoqlib.domain.taxes import InvoiceItemIcms, InvoiceItemIpi from stoqlib.lib.dateutils import localnow from stoqlib.lib.parameters import sysparam from stoqlib.lib.translation import stoqlib_gettext _ = stoqlib_gettext @implementer(IInvoiceItem) class ReturnedSaleItem(Domain): """An item of a :class:`returned sale <ReturnedSale>` Note that objects of this type should never be created manually, only by calling :meth:`Sale.create_sale_return_adapter` """ __storm_table__ = 'returned_sale_item' #: the returned quantity quantity = QuantityCol(default=0) #: The price which this :obj:`.sale_item` was sold. #: When creating this object, if *price* is not passed to the #: contructor, it defaults to :obj:`.sale_item.price` or #: :obj:`.sellable.price` price = PriceCol() sale_item_id = IdCol(default=None) #: the returned |saleitem| sale_item = Reference(sale_item_id, 'SaleItem.id') sellable_id = IdCol() #: The returned |sellable| #: Note that if :obj:`.sale_item` != ``None``, this is the same as #: :obj:`.sale_item.sellable` sellable = Reference(sellable_id, 'Sellable.id') batch_id = IdCol() #: If the sellable is a storable, the |batch| that it was removed from batch = Reference(batch_id, 'StorableBatch.id') returned_sale_id = IdCol() #: the |returnedsale| which this item belongs returned_sale = Reference(returned_sale_id, 'ReturnedSale.id') icms_info_id = IdCol() #: the :class:`stoqlib.domain.taxes.InvoiceItemIcms` tax for *self* icms_info = Reference(icms_info_id, 'InvoiceItemIcms.id') ipi_info_id = IdCol() #: the :class:`stoqlib.domain.taxes.InvoiceItemIpi` tax fo *self* ipi_info = Reference(ipi_info_id, 'InvoiceItemIpi.id') item_discount = Decimal('0') def __init__(self, store=None, **kwargs): # TODO: Add batch logic here. (get if from sale_item or check if was # passed togheter with sellable) sale_item = kwargs.get('sale_item') sellable = kwargs.get('sellable') if not sale_item and not sellable: raise ValueError( "A sale_item or a sellable is mandatory to create this object") elif sale_item and sellable and sale_item.sellable != sellable: raise ValueError( "sellable must be the same as sale_item.sellable") elif sale_item and not sellable: sellable = sale_item.sellable kwargs['sellable'] = sellable if not 'price' in kwargs: # sale_item.price takes priority over sellable.price kwargs['price'] = sale_item.price if sale_item else sellable.price kwargs['ipi_info'] = InvoiceItemIpi(store=store) kwargs['icms_info'] = InvoiceItemIcms(store=store) super(ReturnedSaleItem, self).__init__(store=store, **kwargs) product = self.sellable.product if product: self.ipi_info.set_item_tax(self) self.icms_info.set_item_tax(self) @property def total(self): """The total being returned This is the same as :obj:`.price` * :obj:`.quantity` """ return self.price * self.quantity # # IInvoiceItem implementation # @property def base_price(self): return self.price @property def parent(self): return self.returned_sale @property def nfe_cfop_code(self): sale = self.returned_sale.sale client_address = sale.client.person.get_main_address() branch_address = sale.branch.person.get_main_address() same_state = True if branch_address.city_location.state != client_address.city_location.state: same_state = False if same_state: return u'1202' else: return u'2202' # # Public API # def get_total(self): return self.total def return_(self, branch): """Do the real return of this item When calling this, the real return will happen, that is, if :obj:`.sellable` is a |product|, it's stock will be increased on *branch*. """ storable = self.sellable.product_storable if storable: storable.increase_stock(self.quantity, branch, StockTransactionHistory.TYPE_RETURNED_SALE, self.id, batch=self.batch) if self.sale_item: self.sale_item.quantity_decreased -= self.quantity def undo(self): """Undo this item return. This is the oposite of the return, ie, the item will be removed back from stock and the sale item decreased quantity will be restored. """ storable = self.sellable.product_storable if storable: storable.decrease_stock(self.quantity, self.returned_sale.branch, # FIXME: Create a new type StockTransactionHistory.TYPE_RETURNED_SALE, self.id, batch=self.batch) if self.sale_item: self.sale_item.quantity_decreased += self.quantity @implementer(IContainer) @implementer(IInvoice) class ReturnedSale(Domain): """Holds information about a returned |sale|. This can be: * *trade*, a |client| is returning the |sale| and buying something new with that credit. In that case the returning sale is :obj:`.sale` and the replacement |sale| is in :obj:`.new_sale`. * *return sale* or *devolution*, a |client| is returning the |sale| without making a new |sale|. Normally the old sale which is returned is :obj:`.sale`, however it might be ``None`` in some situations for example, if the |sale| was done at a different |branch| that hasn't been synchronized or is using another system. """ __storm_table__ = 'returned_sale' #: This returned sale was received on another branch, but is not yet #: confirmed. A product goes back to stock only after confirmation STATUS_PENDING = u'pending' #: This return was confirmed, meaning the product stock was increased. STATUS_CONFIRMED = u'confirmed' #: This returned sale was canceled, ie, The product stock is decreased back #: and the original sale still have the products. STATUS_CANCELLED = 'cancelled' statuses = collections.OrderedDict([ (STATUS_PENDING, _(u'Pending')), (STATUS_CONFIRMED, _(u'Confirmed')), (STATUS_CANCELLED, _(u'Cancelled')), ]) #: A numeric identifier for this object. This value should be used instead of #: :obj:`Domain.id` when displaying a numerical representation of this object to #: the user, in dialogs, lists, reports and such. identifier = IdentifierCol() #: Status of the returned sale status = EnumCol(default=STATUS_PENDING) #: the date this return was done return_date = DateTimeCol(default_factory=localnow) #: the date that the |returned sale| with the status pending was received confirm_date = DateTimeCol(default=None) # When this returned sale was undone undo_date = DateTimeCol(default=None) #: the invoice number for this returning invoice_number = IntCol(default=None) #: the reason why this return was made reason = UnicodeCol(default=u'') #: The reason this returned sale was undone undo_reason = UnicodeCol(default=u'') sale_id = IdCol(default=None) #: the |sale| we're returning sale = Reference(sale_id, 'Sale.id') new_sale_id = IdCol(default=None) #: if not ``None``, :obj:`.sale` was traded for this |sale| new_sale = Reference(new_sale_id, 'Sale.id') responsible_id = IdCol() #: the |loginuser| responsible for doing this return responsible = Reference(responsible_id, 'LoginUser.id') confirm_responsible_id = IdCol() #: the |loginuser| responsible for receiving the pending return confirm_responsible = Reference(confirm_responsible_id, 'LoginUser.id') undo_responsible_id = IdCol() #: the |loginuser| responsible for undoing this returned sale. undo_responsible = Reference(undo_responsible_id, 'LoginUser.id') branch_id = IdCol() #: the |branch| in which this return happened branch = Reference(branch_id, 'Branch.id') #: a list of all items returned in this return returned_items = ReferenceSet('id', 'ReturnedSaleItem.returned_sale_id') #: |payments| generated by this returned sale payments = None #: |transporter| used in returned sale transporter = None invoice_id = IdCol() #: The |invoice| generated by the returned sale invoice = Reference(invoice_id, 'Invoice.id') def __init__(self, store=None, **kwargs): kwargs['invoice'] = Invoice(store=store, invoice_type=Invoice.TYPE_IN) super(ReturnedSale, self).__init__(store=store, **kwargs) @property def group(self): """|paymentgroup| for this return sale. Can return: * For a *trade*, use the |paymentgroup| from the replacement |sale|. * For a *devolution*, use the |paymentgroup| from the returned |sale|. """ if self.new_sale: return self.new_sale.group if self.sale: return self.sale.group return None @property def client(self): """The |client| of this return Note that this is the same as :obj:`.sale.client` """ return self.sale and self.sale.client @property def sale_total(self): """The current total amount of the |sale|. This is calculated by getting the :attr:`total amount <stoqlib.domain.sale.Sale.total_amount>` of the returned sale and subtracting the sum of :obj:`.returned_total` of all existing returns for the same sale. """ if not self.sale: return currency(0) # TODO: Filter by status returned = self.store.find(ReturnedSale, sale=self.sale) # This will sum the total already returned for this sale, # excluiding *self* within the same store returned_total = sum([returned_sale.returned_total for returned_sale in returned if returned_sale != self]) return currency(self.sale.total_amount - returned_total) @property def paid_total(self): """The total paid for this sale Note that this is the same as :meth:`stoqlib.domain.sale.Sale.get_total_paid` """ if not self.sale: return currency(0) return self.sale.get_total_paid() @property def returned_total(self): """The total being returned on this return This is done by summing the :attr:`ReturnedSaleItem.total` of all of this :obj:`returned items <.returned_items>` """ return currency(sum([item.total for item in self.returned_items])) @property def total_amount(self): """The total amount for this return See :meth:`.return_` for details of how this is used. """ return currency(self.sale_total - self.paid_total - self.returned_total) @property def total_amount_abs(self): """The absolute total amount for this return This is the same as abs(:attr:`.total_amount`). Useful for displaying it on a gui, just changing it's label to show if it's 'overpaid' or 'missing'. """ return currency(abs(self.total_amount)) # # IContainer implementation # def add_item(self, returned_item): assert not returned_item.returned_sale returned_item.returned_sale = self def get_items(self): return self.returned_items def remove_item(self, item): item.returned_sale = None self.store.maybe_remove(item) # # IInvoice implementation # @property def comments(self): return self.reason @property def discount_value(self): return currency(0) @property def invoice_subtotal(self): return self.returned_total @property def invoice_total(self): return self.returned_total @property def recipient(self): if self.sale.client: return self.sale.client.person return None @property def operation_nature(self): # TODO: Save the operation nature in new returned_sale table field. return _(u"Sale Return") # # Public API # @classmethod def get_pending_returned_sales(cls, store, branch): """Returns a list of pending |returned_sale| :param store: a store :param branch: the |branch| where the sale was made """ from stoqlib.domain.sale import Sale tables = [cls, Join(Sale, cls.sale_id == Sale.id)] # We want the returned_sale which sale was made on the branch # So we are comparing Sale.branch with |branch| to build the query return store.using(*tables).find(cls, And(cls.status == cls.STATUS_PENDING, Sale.branch == branch)) def is_pending(self): return self.status == ReturnedSale.STATUS_PENDING def is_undone(self): return self.status == ReturnedSale.STATUS_CANCELLED def can_undo(self): return self.status == ReturnedSale.STATUS_CONFIRMED def return_(self, method_name=u'money', login_user=None): """Do the return of this returned sale. :param unicode method_name: The name of the payment method that will be used to create this payment. If :attr:`.total_amount` is: * > 0, the client is returning more than it paid, we will create a |payment| with that value so the |client| can be reversed. * == 0, the |client| is returning the same amount that needs to be paid, so existing payments will be cancelled and the |client| doesn't owe anything to us. * < 0, than the payments need to be readjusted before calling this. .. seealso: :meth:`stoqlib.domain.sale.Sale.return_` as that will be called after that payment logic is done. """ assert self.sale and self.sale.can_return() self._clean_not_used_items() payment = None if self.total_amount == 0: # The client does not owe anything to us self.group.cancel() elif self.total_amount < 0: # The user has paid more than it's returning for payment in self.group.get_pending_payments(): if payment.is_inpayment(): # We are returning money to client, that means he doesn't owe # us anything, we do now. Cancel pending payments payment.cancel() method = PaymentMethod.get_by_name(self.store, method_name) description = _(u'%s returned for sale %s') % (method.description, self.sale.identifier) payment = method.create_payment(Payment.TYPE_OUT, payment_group=self.group, branch=self.branch, value=self.total_amount_abs, description=description) payment.set_pending() if method_name == u'credit': payment.pay() # FIXME: For now, we are not reverting the comission as there is a # lot of things to consider. See bug 5215 for information about it. self._revert_fiscal_entry() self.sale.return_(self) # Save invoice number, operation_nature and branch in Invoice table. self.invoice.invoice_number = self.invoice_number self.invoice.operation_nature = self.operation_nature self.invoice.branch = self.branch if self.sale.branch == self.branch: self.confirm(login_user) def trade(self): """Do a trade for this return Almost the same as :meth:`.return_`, but unlike it, this won't generate reversed payments to the client. Instead, it'll generate an inpayment using :obj:`.returned_total` value, so it can be used as an "already paid quantity" on :obj:`.new_sale`. """ assert self.new_sale if self.sale: assert self.sale.can_return() self._clean_not_used_items() store = self.store group = self.group method = PaymentMethod.get_by_name(store, u'trade') description = _(u'Traded items for sale %s') % ( self.new_sale.identifier, ) value = self.returned_total self._return_items() value_as_discount = sysparam.get_bool('USE_TRADE_AS_DISCOUNT') if value_as_discount: self.new_sale.discount_value = self.returned_total else: payment = method.create_payment(Payment.TYPE_IN, group, self.branch, value, description=description) payment.set_pending() payment.pay() self._revert_fiscal_entry() if self.sale: self.sale.return_(self) def remove(self): """Remove this return and it's items from the database""" # XXX: Why do we remove this object from the database for item in self.get_items(): self.remove_item(item) self.store.remove(self) def confirm(self, login_user): """Receive the returned_sale_items from a pending |returned_sale| :param user: the |login_user| that received the pending returned sale """ assert self.status == self.STATUS_PENDING self._return_items() self.status = self.STATUS_CONFIRMED self.confirm_responsible = login_user self.confirm_date = localnow() def undo(self, reason): """Undo this returned sale. This includes removing the returned items from stock again (updating the quantity decreased on the sale). :param reason: The reason for this operation. """ assert self.can_undo() for item in self.get_items(): item.undo() # We now need to create a new in payment for the total amount of this # returned sale. method_name = self._guess_payment_method() method = PaymentMethod.get_by_name(self.store, method_name) description = _(u'%s return undone for sale %s') % ( method.description, self.sale.identifier) payment = method.create_payment(Payment.TYPE_IN, payment_group=self.group, branch=self.branch, value=self.returned_total, description=description) payment.set_pending() payment.pay() self.status = self.STATUS_CANCELLED self.cancel_date = localnow() self.undo_reason = reason # if the sale status is returned, we must reset it to confirmed (only # confirmed sales can be returned) if self.sale.is_returned(): self.sale.set_not_returned() # # Private # def _guess_payment_method(self): """Guesses the payment method used in this returned sale. """ value = self.returned_total # Now look for the out payment, ie, the payment that we possibly created # for the returned value. payments = list(self.sale.payments.find(payment_type=Payment.TYPE_OUT, value=value)) if len(payments) == 1: # There is only one payment that matches our criteria, we can trust it # is the one we are looking for. method = payments[0].method.method_name elif len(payments) == 0: # This means that the returned sale didn't endup creating any return # payment for the client. Let's just create a money payment then method = u'money' else: # This means that we found more than one return payment for this # value. This probably means that the user has returned multiple # items in different returns. methods = set(payment.method.method_name for payment in payments) if len(methods) == 1: # All returns were using the same method. Lets use that one them method = methods.pop() else: # The previous returns used different methods, let's pick money method = u'money' return method def _return_items(self): # We must have at least one item to return assert self.returned_items.count() # FIXME branch = get_current_branch(self.store) for item in self.returned_items: item.return_(branch) def _get_returned_percentage(self): return Decimal(self.returned_total / self.sale.total_amount) def _clean_not_used_items(self): store = self.store for item in self.returned_items: if not item.quantity: # Removed items not marked for return item.delete(item.id, store=store) def _revert_fiscal_entry(self): entry = self.store.find(FiscalBookEntry, payment_group=self.group, is_reversal=False).one() if not entry: return # FIXME: Instead of doing a partial reversion of fiscal entries, # we should be reverting the exact tax for each returned item. returned_percentage = self._get_returned_percentage() entry.reverse_entry( self.invoice_number, icms_value=entry.icms_value * returned_percentage, iss_value=entry.iss_value * returned_percentage, ipi_value=entry.ipi_value * returned_percentage)
andrebellafronte/stoq
stoqlib/domain/returnedsale.py
Python
gpl-2.0
24,066
[ "VisIt" ]
a7c2ade5243e548487808c56a7f90d8d00d3a3f934d989278d68428f9c233db6
''' Resource handling Keep track of the names/locations of any static resources we use, file types. @author: Robert Toomey (retoomey) ''' import os def getScriptDir(): """ Get root location this script is running from. Found this example on google. Basically use the file path of THIS module, but go up one directory """ upOne = (os.path.join( os.path.dirname ( __file__), os.pardir)) return os.path.abspath(upOne) def getResourceDir(): """ Get the location of our 'resource' directory. We use this to find our resources. Found this example on google """ return os.path.join(getScriptDir(), "resource") def getArcgisDir(): """ Get the location of our arcgis data file directory """ return os.path.join(getResourceDir(), "arcgis") def getDataDir(): """ Get the location of our arcgis data file directory """ return os.path.join(getResourceDir(), "exampleNsslData") def getHTMLGenDir(): """ Get the location of a default HTML generation directory """ return os.path.join(getResourceDir(), "HTML") def getArcgisFilename(filename): """ Get the location of a file in our arcgis data file directory """ return os.path.join(getArcgisDir(), filename) def getDataFilename(filename): """ Get the location of a file in our arcgis data file directory """ return os.path.join(getDataDir(), filename) def getSymbologyLayer(): """ Get the location of our default symbology lyr file for raster generation and html output """ return getArcgisFilename("cloudcover.lyr") def getUSAMapLayer(): """ Get the location of our USA map we provide for CONUS html generation""" return getArcgisFilename("usa.lyr") def getTempFile(rootfolder, filename): """ Get a full temp file location given a rootfolder and name """ return os.path.join(rootfolder, filename) def getBaseMulti(filename): """ Turn something like 'C:/stuff/test.netcdf.gz' into 'test' """ return getAbsBaseMulti(os.path.basename(filename)) def getAbsBaseMulti(filename): """ We have files like name.netcdf.gz where there are multiple periods. So this function will get rid of all of them in an OS independent manner. The regular splitext only handles one period. So we call it until it returns the same string Turn something like 'C:/stuff/test.netcdf.gz' into 'C:/stuff/test' """ newfilename = os.path.splitext(filename)[0] while newfilename != filename: # We took at least one '.' off.. filename = newfilename # Do it until no more periods come off newfilename = os.path.splitext(filename)[0] return newfilename def removeGDBCharacters(filename): """ Remove characters that can't be in a GDB name. I know that at least '-' must be removed.""" filename = filename.replace("-", "_") return filename def getHandledFileTypes(): """ Get the file types that we can parse """ return ["netcdf", "nc", "gz"] def isHandledFileType(filename): """ Return True if given filename ends in one of our handled endings """ handled = False for l in getHandledFileTypes(): if filename.endswith("."+l): handled = True break return handled
retoomey/WDSS2Python
w2py/resource.py
Python
apache-2.0
3,409
[ "NetCDF" ]
97237416e422f27c3eb21f601b2065c3f3337da0be2d1e763140af01083456d2
"""Sample conformations from clusters {{header}} Meta ---- depends: - ../../top.pdb - ../../trajs """ import mdtraj as md import os from msmbuilder.io.sampling import sample_states from msmbuilder.io import load_trajs, save_generic, preload_top, backup, load_generic ## Load meta, ttrajs = load_trajs('ttrajs') kmeans = load_generic("kmeans.pickl") ## Sample inds = sample_states(ttrajs, kmeans.cluster_centers_, k=10) save_generic(inds, "cluster-sample-inds.pickl") ## Make trajectories top = preload_top(meta) out_folder = "cluster_samples" backup(out_folder) os.mkdir(out_folder) for state_i, state_inds in enumerate(inds): traj = md.join( md.load_frame(meta.loc[traj_i]['traj_fn'], index=frame_i, top=top) for traj_i, frame_i in state_inds ) traj.save("{}/{}.xtc".format(out_folder, state_i))
mpharrigan/mixtape
msmbuilder/project_templates/cluster/sample-clusters.py
Python
lgpl-2.1
880
[ "MDTraj" ]
09f0237d43388e8239f60f00908864fdef3532dc5b46ae639e38d415241656ff
########################################################################### # # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ########################################################################### # # This code generated (see starthinker/scripts for possible source): # - Command: "python starthinker_ui/manage.py airflow" # ########################################################################### ''' -------------------------------------------------------------- Before running this Airflow module... Install StarThinker in cloud composer ( recommended ): From Release: pip install starthinker From Open Source: pip install git+https://github.com/google/starthinker Or push local code to the cloud composer plugins directory ( if pushing local code changes ): source install/deploy.sh 4) Composer Menu l) Install All -------------------------------------------------------------- If any recipe task has "auth" set to "user" add user credentials: 1. Ensure an RECIPE['setup']['auth']['user'] = [User Credentials JSON] OR 1. Visit Airflow UI > Admin > Connections. 2. Add an Entry called "starthinker_user", fill in the following fields. Last step paste JSON from authentication. - Conn Type: Google Cloud Platform - Project: Get from https://github.com/google/starthinker/blob/master/tutorials/cloud_project.md - Keyfile JSON: Get from: https://github.com/google/starthinker/blob/master/tutorials/deploy_commandline.md#optional-setup-user-credentials -------------------------------------------------------------- If any recipe task has "auth" set to "service" add service credentials: 1. Ensure an RECIPE['setup']['auth']['service'] = [Service Credentials JSON] OR 1. Visit Airflow UI > Admin > Connections. 2. Add an Entry called "starthinker_service", fill in the following fields. Last step paste JSON from authentication. - Conn Type: Google Cloud Platform - Project: Get from https://github.com/google/starthinker/blob/master/tutorials/cloud_project.md - Keyfile JSON: Get from: https://github.com/google/starthinker/blob/master/tutorials/cloud_service.md -------------------------------------------------------------- CM360 Bulk User Editor A tool for rapidly bulk editing Campaign Manager profiles, roles, and sub accounts. - Add this card to a recipe and save it. - Then click Run Now to deploy. - Follow the 1-instructions for setup. 1-instructions: https://docs.google.com/spreadsheets/d/1Mw4kDJfaWVloyjSayJSkgE8i28Svoj1756fyQtIpmRE/ -------------------------------------------------------------- This StarThinker DAG can be extended with any additional tasks from the following sources: - https://google.github.io/starthinker/ - https://github.com/google/starthinker/tree/master/dags ''' from starthinker.airflow.factory import DAG_Factory INPUTS = { 'recipe_name':'', # Name of document to deploy to. } RECIPE = { 'setup':{ 'day':[ ], 'hour':[ ] }, 'tasks':[ { 'drive':{ 'auth':'user', 'hour':[ ], 'copy':{ 'source':'https://docs.google.com/spreadsheets/d/1Mw4kDJfaWVloyjSayJSkgE8i28Svoj1756fyQtIpmRE/', 'destination':{'field':{'name':'recipe_name','prefix':'CM User Editor For ','kind':'string','order':1,'description':'Name of document to deploy to.','default':''}} } } } ] } dag_maker = DAG_Factory('cm_user_editor', RECIPE, INPUTS) dag = dag_maker.generate() if __name__ == "__main__": dag_maker.print_commandline()
google/starthinker
dags/cm_user_editor_dag.py
Python
apache-2.0
4,129
[ "VisIt" ]
00520d38e13f91ac7d36e727268e178bc25a605cc20cc7489abb8607da4d960e
# this file contains all the string data (inputs and outputs) for tests # the SD trees were originally produced on SD 3.4.1 but they work up # to (at least) SD 3.5.2. the UD trees were produced using UD 3.5.2. # tests now require SD/UD 3.5.2 (and thus Java 1.8). downside of this # is that we can't test JPype on older versions of SD since it can only # be (safely) initialized once. class trees_sd: tree1 = '(S1 (NP (DT a) (NN cow)))' tree1_out = ''' Token(index=1, form='a', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cow', cpos='NN', pos='NN', head=0, deprel='root') '''.strip() tree2 = '(S1 (NP (NP (NP (DT A) (NN cat)) (CC and) (NP (DT a) ' \ '(NN mouse))) (. .)))' tree2_out_basic = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cat', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='a', cpos='DT', pos='DT', head=5, deprel='det') Token(index=5, form='mouse', cpos='NN', pos='NN', head=2, deprel='conj') Token(index=6, form='.', cpos='.', pos='.', head=2, deprel='punct')'''.strip() tree2_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cat', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='a', cpos='DT', pos='DT', head=5, deprel='det') Token(index=5, form='mouse', cpos='NN', pos='NN', head=2, deprel='conj_and') Token(index=6, form='.', cpos='.', pos='.', head=2, deprel='punct')'''.strip() tree2_out_CCprocessed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cat', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='a', cpos='DT', pos='DT', head=5, deprel='det') Token(index=5, form='mouse', cpos='NN', pos='NN', head=2, deprel='conj_and') Token(index=6, form='.', cpos='.', pos='.', head=2, deprel='punct')'''.strip() tree2_out_collapsedTree = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cat', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='a', cpos='DT', pos='DT', head=5, deprel='det') Token(index=5, form='mouse', cpos='NN', pos='NN', head=2, deprel='conj_and') Token(index=6, form='.', cpos='.', pos='.', head=2, deprel='punct')'''.strip() tree3 = '(S1 (NP (DT some) (JJ blue) (NN moose)))' tree3_out = ''' Token(index=1, form='some', cpos='DT', pos='DT', head=3, deprel='det') Token(index=2, form='blue', cpos='JJ', pos='JJ', head=3, deprel='amod') Token(index=3, form='moose', cpos='NN', pos='NN', head=0, deprel='root') '''.strip() tree4 = '(S1 (NP (NP (DT A) (NN burrito)) (PP (IN with) (NP (NP ' + \ '(NNS beans)) (CONJP (CC but) (RB not)) (NP (NN chicken)))) (. .)))' tree4_out_basic = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='with', cpos='IN', pos='IN', head=2, deprel='prep') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=3, deprel='pobj') Token(index=5, form='but', cpos='CC', pos='CC', head=6, deprel='cc') Token(index=6, form='not', cpos='RB', pos='RB', head=4, deprel='cc') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='prep_with') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj_negcc') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_CCprocessed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='prep_with') Token(index=7, form='chicken', cpos='NN', pos='NN', head=2, deprel='prep_with') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj_negcc') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_collapsedTree = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='prep_with') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj_negcc') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5 = ''' (S1 (S (NP (NNP Ed)) (VP (VBZ cooks) (CC and) (VBZ sells) (NP (NP (NNS burritos)) (PP (IN with) (NP (NNS beans) (CONJP (CC but) (RB not)) (NN rice))))) (. .))) '''.strip() tree5_out_basic = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=5, deprel='prep') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=6, deprel='pobj') Token(index=8, form='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsed = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_CCprocessed = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=4, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=10, form='rice', cpos='NN', pos='NN', head=5, deprel='prep_with') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsedTree = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsedTree_no_punct = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') '''.strip() tree5_out_collapsedTree_erased = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=0, deprel='erased') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=0, deprel='erased') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=8, form='but', cpos='CC', pos='CC', head=0, deprel='erased') Token(index=9, form='not', cpos='RB', pos='RB', head=0, deprel='erased') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsedTree_erased_no_punct = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=0, deprel='erased') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj_and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=0, deprel='erased') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='prep_with') Token(index=8, form='but', cpos='CC', pos='CC', head=0, deprel='erased') Token(index=9, form='not', cpos='RB', pos='RB', head=0, deprel='erased') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj_negcc') '''.strip() tree5_out_basic_lemmas = ''' Token(index=1, form='Ed', lemma='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', lemma='cook', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', lemma='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', lemma='sell', cpos='VBZ', pos='VBZ', head=2, deprel='conj') Token(index=5, form='burritos', lemma='burrito', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', lemma='with', cpos='IN', pos='IN', head=5, deprel='prep') Token(index=7, form='beans', lemma='bean', cpos='NNS', pos='NNS', head=6, deprel='pobj') Token(index=8, form='but', lemma='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', lemma='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', lemma='rice', cpos='NN', pos='NN', head=7, deprel='conj') Token(index=11, form='.', lemma='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() # tests -NONE- handling tree6 = ''' ( (S (S-TPC-1 (NP-SBJ (PRP He) ) (ADVP (RB also) ) (VP (VBZ is) (NP-PRD (DT a) (NN consensus) (NN manager) ))) (, ,) (NP-SBJ (NNS insiders) ) (VP (VBP say) (SBAR (-NONE- 0) (S (-NONE- *T*-1) ))) (. .) )) ''' tree6_out = ''' Token(index=1, form='He', cpos='PRP', pos='PRP', head=6, deprel='nsubj') Token(index=2, form='also', cpos='RB', pos='RB', head=6, deprel='advmod') Token(index=3, form='is', cpos='VBZ', pos='VBZ', head=6, deprel='cop') Token(index=4, form='a', cpos='DT', pos='DT', head=6, deprel='det') Token(index=5, form='consensus', cpos='NN', pos='NN', head=6, deprel='nn') Token(index=6, form='manager', cpos='NN', pos='NN', head=9, deprel='ccomp') Token(index=7, form=',', cpos=',', pos=',', head=9, deprel='punct') Token(index=8, form='insiders', cpos='NNS', pos='NNS', head=9, deprel='nsubj') Token(index=9, form='say', cpos='VBP', pos='VBP', head=0, deprel='root') Token(index=10, form='.', cpos='.', pos='.', head=9, deprel='punct') '''.strip() # tests weird \/ handling tree7 = '''(S1 (NP (NP (NNP PRIME) (NNP RATE) ) (: :) (NP (CD 10) (CD 1\/2) (NN %) ) (. .) ))''' tree7_out = ''' Token(index=1, form='PRIME', cpos='NNP', pos='NNP', head=2, deprel='nn') Token(index=2, form='RATE', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=3, form=':', cpos=':', pos=':', head=2, deprel='punct') Token(index=4, form='10', cpos='CD', pos='CD', head=6, deprel='num') Token(index=5, form='1/2', cpos='CD', pos='CD', head=6, deprel='num') Token(index=6, form='%', cpos='NN', pos='NN', head=2, deprel='dep') Token(index=7, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree8 = ''' (ROOT (S (NP (NNS Visitors)) (VP (MD can) (VP (VB reach) (NP (PRP it)) (ADVP (RB only)) (PP (PP (IN under) (NP (JJ strict) (JJ military) (NN escort))) (CC and) (PP (IN with) (NP (NP (JJ prior) (NN permission)) (PP (IN from) (NP (DT the) (NNP Pentagon)))))) (, ,) (PP (IN aboard) (NP (NP (JJ special) (JJ small) (NN shuttle) (NNS flights)) (SBAR (WHNP (WDT that)) (S (VP (VBP reach) (NP (DT the) (NN base)) (PP (IN by) (NP (NP (DT a) (JJ circuitous) (NN flight)) (PP (IN from) (NP (DT the) (NNP United) (NNPS States)))))))))))) (. .))) ''' tree8_out = ''' Token(index=1, form='Visitors', cpos='NNS', pos='NNS', head=3, deprel='nsubj') Token(index=2, form='can', cpos='MD', pos='MD', head=3, deprel='aux') Token(index=3, form='reach', cpos='VB', pos='VB', head=0, deprel='root') Token(index=4, form='it', cpos='PRP', pos='PRP', head=3, deprel='dobj') Token(index=5, form='only', cpos='RB', pos='RB', head=3, deprel='advmod') Token(index=6, form='under', cpos='IN', pos='IN', head=3, deprel='prep') Token(index=7, form='strict', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=8, form='military', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=9, form='escort', cpos='NN', pos='NN', head=6, deprel='pobj') Token(index=10, form='and', cpos='CC', pos='CC', head=6, deprel='cc') Token(index=11, form='with', cpos='IN', pos='IN', head=6, deprel='conj') Token(index=12, form='prior', cpos='JJ', pos='JJ', head=13, deprel='amod') Token(index=13, form='permission', cpos='NN', pos='NN', head=11, deprel='pobj') Token(index=14, form='from', cpos='IN', pos='IN', head=13, deprel='prep') Token(index=15, form='the', cpos='DT', pos='DT', head=16, deprel='det') Token(index=16, form='Pentagon', cpos='NNP', pos='NNP', head=14, deprel='pobj') Token(index=17, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=18, form='aboard', cpos='IN', pos='IN', head=3, deprel='prep') Token(index=19, form='special', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=20, form='small', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=21, form='shuttle', cpos='NN', pos='NN', head=22, deprel='nn') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=18, deprel='pobj') Token(index=23, form='that', cpos='WDT', pos='WDT', head=24, deprel='nsubj') Token(index=24, form='reach', cpos='VBP', pos='VBP', head=22, deprel='rcmod') Token(index=25, form='the', cpos='DT', pos='DT', head=26, deprel='det') Token(index=26, form='base', cpos='NN', pos='NN', head=24, deprel='dobj') Token(index=27, form='by', cpos='IN', pos='IN', head=24, deprel='prep') Token(index=28, form='a', cpos='DT', pos='DT', head=30, deprel='det') Token(index=29, form='circuitous', cpos='JJ', pos='JJ', head=30, deprel='amod') Token(index=30, form='flight', cpos='NN', pos='NN', head=27, deprel='pobj') Token(index=31, form='from', cpos='IN', pos='IN', head=30, deprel='prep') Token(index=32, form='the', cpos='DT', pos='DT', head=34, deprel='det') Token(index=33, form='United', cpos='NNP', pos='NNP', head=34, deprel='nn') Token(index=34, form='States', cpos='NNPS', pos='NNPS', head=31, deprel='pobj') Token(index=35, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree8_out_collapsed = ''' Token(index=1, form='Visitors', cpos='NNS', pos='NNS', head=3, deprel='nsubj') Token(index=2, form='can', cpos='MD', pos='MD', head=3, deprel='aux') Token(index=3, form='reach', cpos='VB', pos='VB', head=0, deprel='root') Token(index=3, form='reach', cpos='VB', pos='VB', head=3, deprel='conj_and', extra={'dep_is_copy': 1}) Token(index=4, form='it', cpos='PRP', pos='PRP', head=3, deprel='dobj') Token(index=5, form='only', cpos='RB', pos='RB', head=3, deprel='advmod') Token(index=7, form='strict', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=8, form='military', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=9, form='escort', cpos='NN', pos='NN', head=3, deprel='prep_under') Token(index=12, form='prior', cpos='JJ', pos='JJ', head=13, deprel='amod') Token(index=13, form='permission', cpos='NN', pos='NN', head=3, deprel='prep_with', extra={'gov_is_copy': 1}) Token(index=15, form='the', cpos='DT', pos='DT', head=16, deprel='det') Token(index=16, form='Pentagon', cpos='NNP', pos='NNP', head=13, deprel='prep_from') Token(index=17, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=19, form='special', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=20, form='small', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=21, form='shuttle', cpos='NN', pos='NN', head=22, deprel='nn') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=3, deprel='prep_aboard') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=24, deprel='nsubj') Token(index=24, form='reach', cpos='VBP', pos='VBP', head=22, deprel='rcmod') Token(index=25, form='the', cpos='DT', pos='DT', head=26, deprel='det') Token(index=26, form='base', cpos='NN', pos='NN', head=24, deprel='dobj') Token(index=28, form='a', cpos='DT', pos='DT', head=30, deprel='det') Token(index=29, form='circuitous', cpos='JJ', pos='JJ', head=30, deprel='amod') Token(index=30, form='flight', cpos='NN', pos='NN', head=24, deprel='prep_by') Token(index=32, form='the', cpos='DT', pos='DT', head=34, deprel='det') Token(index=33, form='United', cpos='NNP', pos='NNP', head=34, deprel='nn') Token(index=34, form='States', cpos='NNPS', pos='NNPS', head=30, deprel='prep_from') Token(index=35, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree9 = '''(ROOT (S (NP (NP (DT A) (NN total)) (PP (IN of) (NP (NP (QP (CD 17) (CD million)) (JJ metric) (NNS tons)) (PP (IN of) (NP (NNS potatoes)))))) (VP (VBD was) (VP (VBN produced) (, ,) (SBAR (WHNP (WDT which)) (S (VP (VBD was) (ADJP (NP (CD 14) (NN %)) (JJR less) (PP (PP (IN than) (NP (NP (NP (JJ last) (NN year)) (PRN (-LRB- -LRB-) (NP (NP (CD 106) (NNS quintals)) (PP (IN per) (NP (NN hectare)))) (-RRB- -RRB-))) (, ,) (CC and) (NP (NP (QP (CD 5.4) (CD million)) (JJ metric) (NNS tons)) (PP (IN of) (NP (NNS vegetables)))))) (, ,) (CC or) (ADVP (NP (CD 2.2) (NN %)) (RBR more)) (PP (IN than) (PP (IN on) (NP (DT the) (JJ same) (NN date)) (NP (JJ last) (NN year)))))) (PRN (-LRB- -LRB-) (NP (NP (JJ 116) (NNS quintals)) (PP (IN per) (NP (NN hectare)))) (-RRB- -RRB-))))))) (. .)))''' tree9_out = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='total', cpos='NN', pos='NN', head=11, deprel='nsubjpass') Token(index=3, form='of', cpos='IN', pos='IN', head=2, deprel='prep') Token(index=4, form='17', cpos='CD', pos='CD', head=5, deprel='number') Token(index=5, form='million', cpos='CD', pos='CD', head=7, deprel='num') Token(index=6, form='metric', cpos='JJ', pos='JJ', head=7, deprel='amod') Token(index=7, form='tons', cpos='NNS', pos='NNS', head=3, deprel='pobj') Token(index=8, form='of', cpos='IN', pos='IN', head=7, deprel='prep') Token(index=9, form='potatoes', cpos='NNS', pos='NNS', head=8, deprel='pobj') Token(index=10, form='was', cpos='VBD', pos='VBD', head=11, deprel='auxpass') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=0, deprel='root') Token(index=12, form=',', cpos=',', pos=',', head=11, deprel='punct') Token(index=13, form='which', cpos='WDT', pos='WDT', head=17, deprel='nsubj') Token(index=14, form='was', cpos='VBD', pos='VBD', head=17, deprel='cop') Token(index=15, form='14', cpos='CD', pos='CD', head=16, deprel='num') Token(index=16, form='%', cpos='NN', pos='NN', head=17, deprel='npadvmod') Token(index=17, form='less', cpos='JJR', pos='JJR', head=11, deprel='ccomp') Token(index=18, form='than', cpos='IN', pos='IN', head=17, deprel='prep') Token(index=19, form='last', cpos='JJ', pos='JJ', head=20, deprel='amod') Token(index=20, form='year', cpos='NN', pos='NN', head=18, deprel='pobj') Token(index=21, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=23, deprel='punct') Token(index=22, form='106', cpos='CD', pos='CD', head=23, deprel='num') Token(index=23, form='quintals', cpos='NNS', pos='NNS', head=20, deprel='dep') Token(index=24, form='per', cpos='IN', pos='IN', head=23, deprel='prep') Token(index=25, form='hectare', cpos='NN', pos='NN', head=24, deprel='pobj') Token(index=26, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=23, deprel='punct') Token(index=27, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=28, form='and', cpos='CC', pos='CC', head=20, deprel='cc') Token(index=29, form='5.4', cpos='CD', pos='CD', head=30, deprel='number') Token(index=30, form='million', cpos='CD', pos='CD', head=32, deprel='num') Token(index=31, form='metric', cpos='JJ', pos='JJ', head=32, deprel='amod') Token(index=32, form='tons', cpos='NNS', pos='NNS', head=20, deprel='conj') Token(index=33, form='of', cpos='IN', pos='IN', head=32, deprel='prep') Token(index=34, form='vegetables', cpos='NNS', pos='NNS', head=33, deprel='pobj') Token(index=35, form=',', cpos=',', pos=',', head=18, deprel='punct') Token(index=36, form='or', cpos='CC', pos='CC', head=18, deprel='cc') Token(index=37, form='2.2', cpos='CD', pos='CD', head=38, deprel='num') Token(index=38, form='%', cpos='NN', pos='NN', head=39, deprel='npadvmod') Token(index=39, form='more', cpos='RBR', pos='RBR', head=18, deprel='conj') Token(index=40, form='than', cpos='IN', pos='IN', head=18, deprel='conj') Token(index=41, form='on', cpos='IN', pos='IN', head=40, deprel='pcomp') Token(index=42, form='the', cpos='DT', pos='DT', head=44, deprel='det') Token(index=43, form='same', cpos='JJ', pos='JJ', head=44, deprel='amod') Token(index=44, form='date', cpos='NN', pos='NN', head=41, deprel='pobj') Token(index=45, form='last', cpos='JJ', pos='JJ', head=46, deprel='amod') Token(index=46, form='year', cpos='NN', pos='NN', head=41, deprel='tmod') Token(index=47, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=49, deprel='punct') Token(index=48, form='116', cpos='JJ', pos='JJ', head=49, deprel='amod') Token(index=49, form='quintals', cpos='NNS', pos='NNS', head=17, deprel='dep') Token(index=50, form='per', cpos='IN', pos='IN', head=49, deprel='prep') Token(index=51, form='hectare', cpos='NN', pos='NN', head=50, deprel='pobj') Token(index=52, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=49, deprel='punct') Token(index=53, form='.', cpos='.', pos='.', head=11, deprel='punct') '''.strip() tree9_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='total', cpos='NN', pos='NN', head=11, deprel='nsubjpass') Token(index=4, form='17', cpos='CD', pos='CD', head=5, deprel='number') Token(index=5, form='million', cpos='CD', pos='CD', head=7, deprel='num') Token(index=6, form='metric', cpos='JJ', pos='JJ', head=7, deprel='amod') Token(index=7, form='tons', cpos='NNS', pos='NNS', head=2, deprel='prep_of') Token(index=9, form='potatoes', cpos='NNS', pos='NNS', head=7, deprel='prep_of') Token(index=10, form='was', cpos='VBD', pos='VBD', head=11, deprel='auxpass') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=0, deprel='root') Token(index=12, form=',', cpos=',', pos=',', head=11, deprel='punct') Token(index=13, form='which', cpos='WDT', pos='WDT', head=17, deprel='nsubj') Token(index=14, form='was', cpos='VBD', pos='VBD', head=17, deprel='cop') Token(index=15, form='14', cpos='CD', pos='CD', head=16, deprel='num') Token(index=16, form='%', cpos='NN', pos='NN', head=17, deprel='npadvmod') Token(index=17, form='less', cpos='JJR', pos='JJR', head=11, deprel='ccomp') Token(index=19, form='last', cpos='JJ', pos='JJ', head=20, deprel='amod') Token(index=20, form='year', cpos='NN', pos='NN', head=17, deprel='prep_than') Token(index=21, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=23, deprel='punct') Token(index=22, form='106', cpos='CD', pos='CD', head=23, deprel='num') Token(index=23, form='quintals', cpos='NNS', pos='NNS', head=20, deprel='dep') Token(index=25, form='hectare', cpos='NN', pos='NN', head=23, deprel='prep_per') Token(index=26, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=23, deprel='punct') Token(index=27, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=29, form='5.4', cpos='CD', pos='CD', head=30, deprel='number') Token(index=30, form='million', cpos='CD', pos='CD', head=32, deprel='num') Token(index=31, form='metric', cpos='JJ', pos='JJ', head=32, deprel='amod') Token(index=32, form='tons', cpos='NNS', pos='NNS', head=20, deprel='conj_and') Token(index=34, form='vegetables', cpos='NNS', pos='NNS', head=32, deprel='prep_of') Token(index=35, form=',', cpos=',', pos=',', head=17, deprel='punct') Token(index=37, form='2.2', cpos='CD', pos='CD', head=38, deprel='num') Token(index=38, form='%', cpos='NN', pos='NN', head=39, deprel='npadvmod') Token(index=39, form='more', cpos='RBR', pos='RBR', head=17, deprel='conj') Token(index=41, form='on', cpos='IN', pos='IN', head=17, deprel='pcomp') Token(index=42, form='the', cpos='DT', pos='DT', head=44, deprel='det') Token(index=43, form='same', cpos='JJ', pos='JJ', head=44, deprel='amod') Token(index=44, form='date', cpos='NN', pos='NN', head=41, deprel='pobj') Token(index=45, form='last', cpos='JJ', pos='JJ', head=46, deprel='amod') Token(index=46, form='year', cpos='NN', pos='NN', head=41, deprel='tmod') Token(index=47, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=49, deprel='punct') Token(index=48, form='116', cpos='JJ', pos='JJ', head=49, deprel='amod') Token(index=49, form='quintals', cpos='NNS', pos='NNS', head=17, deprel='dep') Token(index=51, form='hectare', cpos='NN', pos='NN', head=49, deprel='prep_per') Token(index=52, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=49, deprel='punct') Token(index=53, form='.', cpos='.', pos='.', head=11, deprel='punct') '''.strip() tree10 = r''' (ROOT (NP (NP (NNP Hanoi) (, ,) (NNP May) (CD 13)) (PRN (-LRB- -LRB-) (NP (NNP VNA)) (-RRB- -RRB-)) (: --) (NP (NP (NNP Vietnam)) (SBAR (S (VP (VBZ has) (VP (VBN produced) (NP (NP (DT a) (NN variety)) (PP (IN of) (NP (NNS drugs)))) (S (VP (TO to) (VP (VB control) (NP (NNS HIV\/AIDS)) (PP (IN in) (NP (NP (NNS patients)) (VP (VBG suffering) (PP (IN with) (NP (DT the) (NN disease)))))))))))))) (. .))) '''.strip() tree10_out = ''' Token(index=1, form='Hanoi', cpos='NNP', pos='NNP', head=3, deprel='nn') Token(index=2, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=3, form='May', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=4, form='13', cpos='CD', pos='CD', head=3, deprel='num') Token(index=5, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=6, deprel='punct') Token(index=6, form='VNA', cpos='NNP', pos='NNP', head=3, deprel='appos') Token(index=7, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=6, deprel='punct') Token(index=8, form='--', cpos=':', pos=':', head=3, deprel='punct') Token(index=9, form='Vietnam', cpos='NNP', pos='NNP', head=3, deprel='dep') Token(index=10, form='has', cpos='VBZ', pos='VBZ', head=11, deprel='aux') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=9, deprel='rcmod') Token(index=12, form='a', cpos='DT', pos='DT', head=13, deprel='det') Token(index=13, form='variety', cpos='NN', pos='NN', head=11, deprel='dobj') Token(index=14, form='of', cpos='IN', pos='IN', head=13, deprel='prep') Token(index=15, form='drugs', cpos='NNS', pos='NNS', head=14, deprel='pobj') Token(index=16, form='to', cpos='TO', pos='TO', head=17, deprel='aux') Token(index=17, form='control', cpos='VB', pos='VB', head=11, deprel='vmod') Token(index=18, form='HIV/AIDS', cpos='NNS', pos='NNS', head=17, deprel='dobj') Token(index=19, form='in', cpos='IN', pos='IN', head=17, deprel='prep') Token(index=20, form='patients', cpos='NNS', pos='NNS', head=19, deprel='pobj') Token(index=21, form='suffering', cpos='VBG', pos='VBG', head=20, deprel='vmod') Token(index=22, form='with', cpos='IN', pos='IN', head=21, deprel='prep') Token(index=23, form='the', cpos='DT', pos='DT', head=24, deprel='det') Token(index=24, form='disease', cpos='NN', pos='NN', head=22, deprel='pobj') Token(index=25, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree10_out_collapsed = ''' Token(index=1, form='Hanoi', cpos='NNP', pos='NNP', head=3, deprel='nn') Token(index=2, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=3, form='May', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=4, form='13', cpos='CD', pos='CD', head=3, deprel='num') Token(index=5, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=6, deprel='punct') Token(index=6, form='VNA', cpos='NNP', pos='NNP', head=3, deprel='appos') Token(index=7, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=6, deprel='punct') Token(index=8, form='--', cpos=':', pos=':', head=3, deprel='punct') Token(index=9, form='Vietnam', cpos='NNP', pos='NNP', head=3, deprel='dep') Token(index=10, form='has', cpos='VBZ', pos='VBZ', head=11, deprel='aux') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=9, deprel='rcmod') Token(index=12, form='a', cpos='DT', pos='DT', head=13, deprel='det') Token(index=13, form='variety', cpos='NN', pos='NN', head=11, deprel='dobj') Token(index=15, form='drugs', cpos='NNS', pos='NNS', head=13, deprel='prep_of') Token(index=16, form='to', cpos='TO', pos='TO', head=17, deprel='aux') Token(index=17, form='control', cpos='VB', pos='VB', head=11, deprel='vmod') Token(index=18, form='HIV/AIDS', cpos='NNS', pos='NNS', head=17, deprel='dobj') Token(index=20, form='patients', cpos='NNS', pos='NNS', head=17, deprel='prep_in') Token(index=21, form='suffering', cpos='VBG', pos='VBG', head=20, deprel='vmod') Token(index=23, form='the', cpos='DT', pos='DT', head=24, deprel='det') Token(index=24, form='disease', cpos='NN', pos='NN', head=21, deprel='prep_with') Token(index=25, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() @classmethod def get_basic_test_trees(self): return ((self.tree1, self.tree1_out), (self.tree2, self.tree2_out_basic), (self.tree3, self.tree3_out), (self.tree4, self.tree4_out_basic), (self.tree5, self.tree5_out_basic), (self.tree6, self.tree6_out), (self.tree7, self.tree7_out), (self.tree8, self.tree8_out), (self.tree9, self.tree9_out), (self.tree10, self.tree10_out)) @classmethod def get_repr_test_trees(self): return ((self.tree2, dict(basic=self.tree2_out_basic, collapsed=self.tree2_out_collapsed, CCprocessed=self.tree2_out_CCprocessed, collapsedTree=self.tree2_out_collapsedTree)), (self.tree4, dict(basic=self.tree4_out_basic, collapsed=self.tree4_out_collapsed, CCprocessed=self.tree4_out_CCprocessed, collapsedTree=self.tree4_out_collapsedTree)), (self.tree5, dict(basic=self.tree5_out_basic, collapsed=self.tree5_out_collapsed, CCprocessed=self.tree5_out_CCprocessed, collapsedTree=self.tree5_out_collapsedTree)), (self.tree8, dict(collapsed=self.tree8_out_collapsed)), (self.tree9, dict(collapsed=self.tree9_out_collapsed)), (self.tree10, dict(collapsed=self.tree10_out_collapsed))) # UD trees are similar to SD trees, but some parts are overridden class trees_ud(trees_sd): tree2_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='cat', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='a', cpos='DT', pos='DT', head=5, deprel='det') Token(index=5, form='mouse', cpos='NN', pos='NN', head=2, deprel='conj:and') Token(index=6, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree2_out_collapsedTree = tree2_out_collapsed tree2_out_CCprocessed = tree2_out_collapsed tree4_out_basic = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='with', cpos='IN', pos='IN', head=4, deprel='case') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='nmod') Token(index=5, form='but', cpos='CC', pos='CC', head=6, deprel='cc') Token(index=6, form='not', cpos='RB', pos='RB', head=4, deprel='cc') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='with', cpos='IN', pos='IN', head=4, deprel='case') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='nmod:with') Token(index=5, form='but', cpos='CC', pos='CC', head=6, deprel='cc') Token(index=6, form='not', cpos='RB', pos='RB', head=4, deprel='cc') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj:negcc') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_CCprocessed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='burrito', cpos='NN', pos='NN', head=0, deprel='root') Token(index=3, form='with', cpos='IN', pos='IN', head=4, deprel='case') Token(index=4, form='beans', cpos='NNS', pos='NNS', head=2, deprel='nmod:with') Token(index=5, form='but', cpos='CC', pos='CC', head=6, deprel='cc') Token(index=6, form='not', cpos='RB', pos='RB', head=4, deprel='cc') Token(index=7, form='chicken', cpos='NN', pos='NN', head=2, deprel='nmod:with') Token(index=7, form='chicken', cpos='NN', pos='NN', head=4, deprel='conj:negcc') Token(index=8, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree4_out_collapsedTree = tree4_out_collapsed tree5_out_basic = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=7, deprel='case') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='nmod') Token(index=8, form='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsed = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj:and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=7, deprel='case') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='nmod:with') Token(index=8, form='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj:negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_CCprocessed = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=4, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj:and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=7, deprel='case') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='nmod:with') Token(index=8, form='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', cpos='NN', pos='NN', head=5, deprel='nmod:with') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj:negcc') Token(index=11, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree5_out_collapsedTree = tree5_out_collapsed tree5_out_collapsedTree_no_punct = ''' Token(index=1, form='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', cpos='VBZ', pos='VBZ', head=2, deprel='conj:and') Token(index=5, form='burritos', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', cpos='IN', pos='IN', head=7, deprel='case') Token(index=7, form='beans', cpos='NNS', pos='NNS', head=5, deprel='nmod:with') Token(index=8, form='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', cpos='NN', pos='NN', head=7, deprel='conj:negcc') '''.strip() # nothing gets erased in UD tree5_out_collapsedTree_erased = tree5_out_collapsedTree tree5_out_collapsedTree_erased_no_punct = tree5_out_collapsedTree_no_punct tree5_out_basic_lemmas = ''' Token(index=1, form='Ed', lemma='Ed', cpos='NNP', pos='NNP', head=2, deprel='nsubj') Token(index=2, form='cooks', lemma='cook', cpos='VBZ', pos='VBZ', head=0, deprel='root') Token(index=3, form='and', lemma='and', cpos='CC', pos='CC', head=2, deprel='cc') Token(index=4, form='sells', lemma='sell', cpos='VBZ', pos='VBZ', head=2, deprel='conj') Token(index=5, form='burritos', lemma='burrito', cpos='NNS', pos='NNS', head=2, deprel='dobj') Token(index=6, form='with', lemma='with', cpos='IN', pos='IN', head=7, deprel='case') Token(index=7, form='beans', lemma='bean', cpos='NNS', pos='NNS', head=5, deprel='nmod') Token(index=8, form='but', lemma='but', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=9, form='not', lemma='not', cpos='RB', pos='RB', head=7, deprel='cc') Token(index=10, form='rice', lemma='rice', cpos='NN', pos='NN', head=7, deprel='conj') Token(index=11, form='.', lemma='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree6_out = ''' Token(index=1, form='He', cpos='PRP', pos='PRP', head=6, deprel='nsubj') Token(index=2, form='also', cpos='RB', pos='RB', head=6, deprel='advmod') Token(index=3, form='is', cpos='VBZ', pos='VBZ', head=6, deprel='cop') Token(index=4, form='a', cpos='DT', pos='DT', head=6, deprel='det') Token(index=5, form='consensus', cpos='NN', pos='NN', head=6, deprel='compound') Token(index=6, form='manager', cpos='NN', pos='NN', head=9, deprel='ccomp') Token(index=7, form=',', cpos=',', pos=',', head=9, deprel='punct') Token(index=8, form='insiders', cpos='NNS', pos='NNS', head=9, deprel='nsubj') Token(index=9, form='say', cpos='VBP', pos='VBP', head=0, deprel='root') Token(index=10, form='.', cpos='.', pos='.', head=9, deprel='punct') '''.strip() tree7_out = ''' Token(index=1, form='PRIME', cpos='NNP', pos='NNP', head=2, deprel='compound') Token(index=2, form='RATE', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=3, form=':', cpos=':', pos=':', head=2, deprel='punct') Token(index=4, form='10', cpos='CD', pos='CD', head=6, deprel='nummod') Token(index=5, form='1/2', cpos='CD', pos='CD', head=6, deprel='nummod') Token(index=6, form='%', cpos='NN', pos='NN', head=2, deprel='dep') Token(index=7, form='.', cpos='.', pos='.', head=2, deprel='punct') '''.strip() tree8_out = ''' Token(index=1, form='Visitors', cpos='NNS', pos='NNS', head=3, deprel='nsubj') Token(index=2, form='can', cpos='MD', pos='MD', head=3, deprel='aux') Token(index=3, form='reach', cpos='VB', pos='VB', head=0, deprel='root') Token(index=4, form='it', cpos='PRP', pos='PRP', head=3, deprel='dobj') Token(index=5, form='only', cpos='RB', pos='RB', head=3, deprel='advmod') Token(index=6, form='under', cpos='IN', pos='IN', head=9, deprel='case') Token(index=7, form='strict', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=8, form='military', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=9, form='escort', cpos='NN', pos='NN', head=3, deprel='nmod') Token(index=10, form='and', cpos='CC', pos='CC', head=9, deprel='cc') Token(index=11, form='with', cpos='IN', pos='IN', head=13, deprel='case') Token(index=12, form='prior', cpos='JJ', pos='JJ', head=13, deprel='amod') Token(index=13, form='permission', cpos='NN', pos='NN', head=9, deprel='conj') Token(index=14, form='from', cpos='IN', pos='IN', head=16, deprel='case') Token(index=15, form='the', cpos='DT', pos='DT', head=16, deprel='det') Token(index=16, form='Pentagon', cpos='NNP', pos='NNP', head=13, deprel='nmod') Token(index=17, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=18, form='aboard', cpos='IN', pos='IN', head=22, deprel='case') Token(index=19, form='special', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=20, form='small', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=21, form='shuttle', cpos='NN', pos='NN', head=22, deprel='compound') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=3, deprel='nmod') Token(index=23, form='that', cpos='WDT', pos='WDT', head=24, deprel='nsubj') Token(index=24, form='reach', cpos='VBP', pos='VBP', head=22, deprel='acl:relcl') Token(index=25, form='the', cpos='DT', pos='DT', head=26, deprel='det') Token(index=26, form='base', cpos='NN', pos='NN', head=24, deprel='dobj') Token(index=27, form='by', cpos='IN', pos='IN', head=30, deprel='case') Token(index=28, form='a', cpos='DT', pos='DT', head=30, deprel='det') Token(index=29, form='circuitous', cpos='JJ', pos='JJ', head=30, deprel='amod') Token(index=30, form='flight', cpos='NN', pos='NN', head=24, deprel='nmod') Token(index=31, form='from', cpos='IN', pos='IN', head=34, deprel='case') Token(index=32, form='the', cpos='DT', pos='DT', head=34, deprel='det') Token(index=33, form='United', cpos='NNP', pos='NNP', head=34, deprel='compound') Token(index=34, form='States', cpos='NNPS', pos='NNPS', head=30, deprel='nmod') Token(index=35, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree8_out_collapsed = ''' Token(index=1, form='Visitors', cpos='NNS', pos='NNS', head=3, deprel='nsubj') Token(index=2, form='can', cpos='MD', pos='MD', head=3, deprel='aux') Token(index=3, form='reach', cpos='VB', pos='VB', head=0, deprel='root') Token(index=3, form='reach', cpos='VB', pos='VB', head=3, deprel='conj:and', extra={'dep_is_copy': 1}) Token(index=4, form='it', cpos='PRP', pos='PRP', head=3, deprel='dobj') Token(index=5, form='only', cpos='RB', pos='RB', head=3, deprel='advmod') Token(index=6, form='under', cpos='IN', pos='IN', head=9, deprel='case') Token(index=7, form='strict', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=8, form='military', cpos='JJ', pos='JJ', head=9, deprel='amod') Token(index=9, form='escort', cpos='NN', pos='NN', head=3, deprel='nmod:under') Token(index=10, form='and', cpos='CC', pos='CC', head=3, deprel='cc') Token(index=11, form='with', cpos='IN', pos='IN', head=13, deprel='case') Token(index=12, form='prior', cpos='JJ', pos='JJ', head=13, deprel='amod') Token(index=13, form='permission', cpos='NN', pos='NN', head=3, deprel='nmod:with', extra={'gov_is_copy': 1}) Token(index=14, form='from', cpos='IN', pos='IN', head=16, deprel='case') Token(index=15, form='the', cpos='DT', pos='DT', head=16, deprel='det') Token(index=16, form='Pentagon', cpos='NNP', pos='NNP', head=13, deprel='nmod:from') Token(index=17, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=18, form='aboard', cpos='IN', pos='IN', head=22, deprel='case') Token(index=19, form='special', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=20, form='small', cpos='JJ', pos='JJ', head=22, deprel='amod') Token(index=21, form='shuttle', cpos='NN', pos='NN', head=22, deprel='compound') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=3, deprel='nmod:aboard') Token(index=22, form='flights', cpos='NNS', pos='NNS', head=24, deprel='nsubj') Token(index=23, form='that', cpos='WDT', pos='WDT', head=22, deprel='ref') Token(index=24, form='reach', cpos='VBP', pos='VBP', head=22, deprel='acl:relcl') Token(index=25, form='the', cpos='DT', pos='DT', head=26, deprel='det') Token(index=26, form='base', cpos='NN', pos='NN', head=24, deprel='dobj') Token(index=27, form='by', cpos='IN', pos='IN', head=30, deprel='case') Token(index=28, form='a', cpos='DT', pos='DT', head=30, deprel='det') Token(index=29, form='circuitous', cpos='JJ', pos='JJ', head=30, deprel='amod') Token(index=30, form='flight', cpos='NN', pos='NN', head=24, deprel='nmod:by') Token(index=31, form='from', cpos='IN', pos='IN', head=34, deprel='case') Token(index=32, form='the', cpos='DT', pos='DT', head=34, deprel='det') Token(index=33, form='United', cpos='NNP', pos='NNP', head=34, deprel='compound') Token(index=34, form='States', cpos='NNPS', pos='NNPS', head=30, deprel='nmod:from') Token(index=35, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree9_out = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='total', cpos='NN', pos='NN', head=11, deprel='nsubjpass') Token(index=3, form='of', cpos='IN', pos='IN', head=7, deprel='case') Token(index=4, form='17', cpos='CD', pos='CD', head=5, deprel='compound') Token(index=5, form='million', cpos='CD', pos='CD', head=7, deprel='nummod') Token(index=6, form='metric', cpos='JJ', pos='JJ', head=7, deprel='amod') Token(index=7, form='tons', cpos='NNS', pos='NNS', head=2, deprel='nmod') Token(index=8, form='of', cpos='IN', pos='IN', head=9, deprel='case') Token(index=9, form='potatoes', cpos='NNS', pos='NNS', head=7, deprel='nmod') Token(index=10, form='was', cpos='VBD', pos='VBD', head=11, deprel='auxpass') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=0, deprel='root') Token(index=12, form=',', cpos=',', pos=',', head=11, deprel='punct') Token(index=13, form='which', cpos='WDT', pos='WDT', head=17, deprel='nsubj') Token(index=14, form='was', cpos='VBD', pos='VBD', head=17, deprel='cop') Token(index=15, form='14', cpos='CD', pos='CD', head=16, deprel='nummod') Token(index=16, form='%', cpos='NN', pos='NN', head=17, deprel='nmod:npmod') Token(index=17, form='less', cpos='JJR', pos='JJR', head=11, deprel='ccomp') Token(index=18, form='than', cpos='IN', pos='IN', head=20, deprel='case') Token(index=19, form='last', cpos='JJ', pos='JJ', head=20, deprel='amod') Token(index=20, form='year', cpos='NN', pos='NN', head=17, deprel='nmod') Token(index=21, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=23, deprel='punct') Token(index=22, form='106', cpos='CD', pos='CD', head=23, deprel='nummod') Token(index=23, form='quintals', cpos='NNS', pos='NNS', head=20, deprel='dep') Token(index=24, form='per', cpos='IN', pos='IN', head=25, deprel='case') Token(index=25, form='hectare', cpos='NN', pos='NN', head=23, deprel='nmod') Token(index=26, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=23, deprel='punct') Token(index=27, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=28, form='and', cpos='CC', pos='CC', head=20, deprel='cc') Token(index=29, form='5.4', cpos='CD', pos='CD', head=30, deprel='compound') Token(index=30, form='million', cpos='CD', pos='CD', head=32, deprel='nummod') Token(index=31, form='metric', cpos='JJ', pos='JJ', head=32, deprel='amod') Token(index=32, form='tons', cpos='NNS', pos='NNS', head=20, deprel='conj') Token(index=33, form='of', cpos='IN', pos='IN', head=34, deprel='case') Token(index=34, form='vegetables', cpos='NNS', pos='NNS', head=32, deprel='nmod') Token(index=35, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=36, form='or', cpos='CC', pos='CC', head=20, deprel='cc') Token(index=37, form='2.2', cpos='CD', pos='CD', head=38, deprel='nummod') Token(index=38, form='%', cpos='NN', pos='NN', head=39, deprel='nmod:npmod') Token(index=39, form='more', cpos='RBR', pos='RBR', head=20, deprel='conj') Token(index=40, form='than', cpos='IN', pos='IN', head=44, deprel='case') Token(index=41, form='on', cpos='IN', pos='IN', head=44, deprel='case') Token(index=42, form='the', cpos='DT', pos='DT', head=44, deprel='det') Token(index=43, form='same', cpos='JJ', pos='JJ', head=44, deprel='amod') Token(index=44, form='date', cpos='NN', pos='NN', head=20, deprel='conj') Token(index=45, form='last', cpos='JJ', pos='JJ', head=46, deprel='amod') Token(index=46, form='year', cpos='NN', pos='NN', head=44, deprel='nmod:tmod') Token(index=47, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=49, deprel='punct') Token(index=48, form='116', cpos='JJ', pos='JJ', head=49, deprel='amod') Token(index=49, form='quintals', cpos='NNS', pos='NNS', head=17, deprel='dep') Token(index=50, form='per', cpos='IN', pos='IN', head=51, deprel='case') Token(index=51, form='hectare', cpos='NN', pos='NN', head=49, deprel='nmod') Token(index=52, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=49, deprel='punct') Token(index=53, form='.', cpos='.', pos='.', head=11, deprel='punct') '''.strip() tree9_out_collapsed = ''' Token(index=1, form='A', cpos='DT', pos='DT', head=2, deprel='det') Token(index=2, form='total', cpos='NN', pos='NN', head=11, deprel='nsubjpass') Token(index=3, form='of', cpos='IN', pos='IN', head=7, deprel='case') Token(index=4, form='17', cpos='CD', pos='CD', head=5, deprel='compound') Token(index=5, form='million', cpos='CD', pos='CD', head=7, deprel='nummod') Token(index=6, form='metric', cpos='JJ', pos='JJ', head=7, deprel='amod') Token(index=7, form='tons', cpos='NNS', pos='NNS', head=2, deprel='nmod:of') Token(index=8, form='of', cpos='IN', pos='IN', head=9, deprel='case') Token(index=9, form='potatoes', cpos='NNS', pos='NNS', head=7, deprel='nmod:of') Token(index=10, form='was', cpos='VBD', pos='VBD', head=11, deprel='auxpass') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=0, deprel='root') Token(index=12, form=',', cpos=',', pos=',', head=11, deprel='punct') Token(index=13, form='which', cpos='WDT', pos='WDT', head=17, deprel='nsubj') Token(index=14, form='was', cpos='VBD', pos='VBD', head=17, deprel='cop') Token(index=15, form='14', cpos='CD', pos='CD', head=16, deprel='nummod') Token(index=16, form='%', cpos='NN', pos='NN', head=17, deprel='nmod:npmod') Token(index=17, form='less', cpos='JJR', pos='JJR', head=11, deprel='ccomp') Token(index=17, form='less', cpos='JJR', pos='JJR', head=17, deprel='conj:and', extra={'dep_is_copy': 3}) Token(index=17, form='less', cpos='JJR', pos='JJR', head=17, deprel='conj:and', extra={'dep_is_copy': 4}) Token(index=17, form='less', cpos='JJR', pos='JJR', head=17, deprel='conj:or', extra={'dep_is_copy': 1}) Token(index=17, form='less', cpos='JJR', pos='JJR', head=17, deprel='conj:or', extra={'dep_is_copy': 2}) Token(index=18, form='than', cpos='IN', pos='IN', head=20, deprel='case') Token(index=19, form='last', cpos='JJ', pos='JJ', head=20, deprel='amod') Token(index=20, form='year', cpos='NN', pos='NN', head=17, deprel='nmod:than') Token(index=21, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=23, deprel='punct') Token(index=22, form='106', cpos='CD', pos='CD', head=23, deprel='nummod') Token(index=23, form='quintals', cpos='NNS', pos='NNS', head=20, deprel='dep') Token(index=24, form='per', cpos='IN', pos='IN', head=25, deprel='case') Token(index=25, form='hectare', cpos='NN', pos='NN', head=23, deprel='nmod:per') Token(index=26, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=23, deprel='punct') Token(index=27, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=28, form='and', cpos='CC', pos='CC', head=17, deprel='cc') Token(index=29, form='5.4', cpos='CD', pos='CD', head=30, deprel='compound') Token(index=30, form='million', cpos='CD', pos='CD', head=32, deprel='nummod') Token(index=31, form='metric', cpos='JJ', pos='JJ', head=32, deprel='amod') Token(index=32, form='tons', cpos='NNS', pos='NNS', head=20, deprel='conj') Token(index=33, form='of', cpos='IN', pos='IN', head=34, deprel='case') Token(index=34, form='vegetables', cpos='NNS', pos='NNS', head=32, deprel='nmod:of') Token(index=35, form=',', cpos=',', pos=',', head=20, deprel='punct') Token(index=36, form='or', cpos='CC', pos='CC', head=17, deprel='cc') Token(index=37, form='2.2', cpos='CD', pos='CD', head=38, deprel='nummod') Token(index=38, form='%', cpos='NN', pos='NN', head=39, deprel='nmod:npmod') Token(index=39, form='more', cpos='RBR', pos='RBR', head=20, deprel='conj') Token(index=40, form='than', cpos='IN', pos='IN', head=44, deprel='case') Token(index=41, form='on', cpos='IN', pos='IN', head=44, deprel='case') Token(index=42, form='the', cpos='DT', pos='DT', head=44, deprel='det') Token(index=43, form='same', cpos='JJ', pos='JJ', head=44, deprel='amod') Token(index=44, form='date', cpos='NN', pos='NN', head=17, deprel='nmod:on', extra={'gov_is_copy': 1}) Token(index=45, form='last', cpos='JJ', pos='JJ', head=46, deprel='amod') Token(index=46, form='year', cpos='NN', pos='NN', head=44, deprel='nmod:tmod') Token(index=47, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=49, deprel='punct') Token(index=48, form='116', cpos='JJ', pos='JJ', head=49, deprel='amod') Token(index=49, form='quintals', cpos='NNS', pos='NNS', head=17, deprel='dep') Token(index=50, form='per', cpos='IN', pos='IN', head=51, deprel='case') Token(index=51, form='hectare', cpos='NN', pos='NN', head=49, deprel='nmod:per') Token(index=52, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=49, deprel='punct') Token(index=53, form='.', cpos='.', pos='.', head=11, deprel='punct') '''.strip() tree10_out = ''' Token(index=1, form='Hanoi', cpos='NNP', pos='NNP', head=3, deprel='compound') Token(index=2, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=3, form='May', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=4, form='13', cpos='CD', pos='CD', head=3, deprel='nummod') Token(index=5, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=6, deprel='punct') Token(index=6, form='VNA', cpos='NNP', pos='NNP', head=3, deprel='appos') Token(index=7, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=6, deprel='punct') Token(index=8, form='--', cpos=':', pos=':', head=3, deprel='punct') Token(index=9, form='Vietnam', cpos='NNP', pos='NNP', head=3, deprel='dep') Token(index=10, form='has', cpos='VBZ', pos='VBZ', head=11, deprel='aux') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=9, deprel='acl:relcl') Token(index=12, form='a', cpos='DT', pos='DT', head=13, deprel='det') Token(index=13, form='variety', cpos='NN', pos='NN', head=11, deprel='dobj') Token(index=14, form='of', cpos='IN', pos='IN', head=15, deprel='case') Token(index=15, form='drugs', cpos='NNS', pos='NNS', head=13, deprel='nmod') Token(index=16, form='to', cpos='TO', pos='TO', head=17, deprel='mark') Token(index=17, form='control', cpos='VB', pos='VB', head=11, deprel='advcl') Token(index=18, form='HIV/AIDS', cpos='NNS', pos='NNS', head=17, deprel='dobj') Token(index=19, form='in', cpos='IN', pos='IN', head=20, deprel='case') Token(index=20, form='patients', cpos='NNS', pos='NNS', head=17, deprel='nmod') Token(index=21, form='suffering', cpos='VBG', pos='VBG', head=20, deprel='acl') Token(index=22, form='with', cpos='IN', pos='IN', head=24, deprel='case') Token(index=23, form='the', cpos='DT', pos='DT', head=24, deprel='det') Token(index=24, form='disease', cpos='NN', pos='NN', head=21, deprel='nmod') Token(index=25, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip() tree10_out_collapsed = ''' Token(index=1, form='Hanoi', cpos='NNP', pos='NNP', head=3, deprel='compound') Token(index=2, form=',', cpos=',', pos=',', head=3, deprel='punct') Token(index=3, form='May', cpos='NNP', pos='NNP', head=0, deprel='root') Token(index=4, form='13', cpos='CD', pos='CD', head=3, deprel='nummod') Token(index=5, form='-LRB-', cpos='-LRB-', pos='-LRB-', head=6, deprel='punct') Token(index=6, form='VNA', cpos='NNP', pos='NNP', head=3, deprel='appos') Token(index=7, form='-RRB-', cpos='-RRB-', pos='-RRB-', head=6, deprel='punct') Token(index=8, form='--', cpos=':', pos=':', head=3, deprel='punct') Token(index=9, form='Vietnam', cpos='NNP', pos='NNP', head=3, deprel='dep') Token(index=10, form='has', cpos='VBZ', pos='VBZ', head=11, deprel='aux') Token(index=11, form='produced', cpos='VBN', pos='VBN', head=9, deprel='acl:relcl') Token(index=12, form='a', cpos='DT', pos='DT', head=13, deprel='det') Token(index=13, form='variety', cpos='NN', pos='NN', head=11, deprel='dobj') Token(index=14, form='of', cpos='IN', pos='IN', head=15, deprel='case') Token(index=15, form='drugs', cpos='NNS', pos='NNS', head=13, deprel='nmod:of') Token(index=16, form='to', cpos='TO', pos='TO', head=17, deprel='mark') Token(index=17, form='control', cpos='VB', pos='VB', head=11, deprel='advcl') Token(index=18, form='HIV/AIDS', cpos='NNS', pos='NNS', head=17, deprel='dobj') Token(index=19, form='in', cpos='IN', pos='IN', head=20, deprel='case') Token(index=20, form='patients', cpos='NNS', pos='NNS', head=17, deprel='nmod:in') Token(index=21, form='suffering', cpos='VBG', pos='VBG', head=20, deprel='acl') Token(index=22, form='with', cpos='IN', pos='IN', head=24, deprel='case') Token(index=23, form='the', cpos='DT', pos='DT', head=24, deprel='det') Token(index=24, form='disease', cpos='NN', pos='NN', head=21, deprel='nmod:with') Token(index=25, form='.', cpos='.', pos='.', head=3, deprel='punct') '''.strip()
dmcc/PyStanfordDependencies
test/data.py
Python
apache-2.0
58,776
[ "MOOSE" ]
2191705e54c40ccb883382beeb11549d617c8d4ca75b0b8cc43bf5d358acdf61
import abc import numpy as np import operator import six import sys import uuid import logging import warnings import weakref from ast import parse if six.PY2: from funcsigs import signature, Parameter as SigParameter else: from inspect import signature, Parameter as SigParameter __all__ = ['Nexus', 'NexusError', 'Alias', 'Array', 'Fallback', 'Function', 'Parameter', 'Tuple'] # -- helpers _OPERATORS = { # arithmetic 'add': operator.add, 'sub': operator.sub, 'mul': operator.mul, 'truediv': operator.truediv, 'floordiv': operator.floordiv, 'mod': operator.mod, } # 'div' operator only available in Python 2 if six.PY2: _OPERATORS['div'] = operator.div _OPERATORS = { # arithmetic 'add': (operator.add, True), 'sub': (operator.sub, True), 'mul': (operator.mul, True), 'truediv': (operator.truediv, True), 'floordiv': (operator.floordiv, True), 'mod': (operator.mod, True), # binary arithmetic 'lshift': (operator.lshift, True), 'rshift': (operator.rshift, True), # logical 'and': (operator.and_, True), 'or': (operator.or_, True), 'xor': (operator.xor, True), # comparison #'eq': (operator.eq, False), #'ne': (operator.ne, False), #'lt': (operator.lt, False), #'le': (operator.le, False), #'gt': (operator.gt, False), #'ge': (operator.ge, False), # other #'getitem': (operator.getitem, False), #'contains': (operator.contains, False), } _UNARY_OPERATORS = { 'invert': operator.invert, 'neg': operator.neg, 'pos': operator.pos, 'len': len, } # 'div' operator only available in Python 2 if six.PY2: _OPERATORS['div'] = (operator.div, True) # '_abs' operator only available in Python 3 if six.PY3: _UNARY_OPERATORS['abs'] = operator._abs def _add_common_operators(cls): """class decorator for implementing common operator methods for nodes""" for name, (op, add_reversed) in list(_OPERATORS.items()): setattr(cls, '__{}__'.format(name), cls._make_binop_method(op)) if add_reversed: setattr(cls, '__r{}__'.format(name), cls._make_rbinop_method(op)) for name, op in _UNARY_OPERATORS.items(): setattr(cls, '__{}__'.format(name), cls._make_unaryop_method(op)) return cls # -- Nodes ------------------------------------- class NodeException(Exception): pass class FallbackError(NodeException): pass @six.add_metaclass(abc.ABCMeta) class NodeBase(object): """ Abstract class for a computation graph node. Defines the minimal interface required by all specializations. Dependencies between nodes are expressed via parent nodes and child nodes. The status of a parent node depends on the status of its children; When the status of a child node changes the status of any of its parents will need to be changed as well. """ RESERVED_PARAMETER_NAMES = ('__all__', '__real__', '__root__', '__error__') def __init__(self, name=None): """ :param name: the name of the node :type name: str """ self.name = name or 'Node_' + uuid.uuid4().hex[:10] self._stale = True self._frozen = False self._children = [] self._parents = set() def __iter__(self): raise TypeError("'{}' is not iterable".format(self.__class__.__name__)) def __str__(self): return "{}('{}') [{}]".format( self.__class__.__name__, self.name, hex(id(self)) ) def __repr__(self): return self.__str__() def _pprint(self): """return pretty-printed version of node""" return "{}('{}')".format( self.__class__.__name__, self.name ) def __eq__(self, other): return self is other def __ne__(self, other): return self is not other def __hash__(self): return id(self) @staticmethod def _check_name_raise(name): """ Check if node name is valid. :param name: the node name :type name: str """ if name in Parameter.RESERVED_PARAMETER_NAMES: raise NodeException("Invalid node name: '%s' is a reserved keyword!" % (name,)) try: parse('dict(%s=0.123)' % (name,)) except SyntaxError: raise NodeException("Invalid node name '%s'. Must be Python identifier!" % (name,)) # -- properties @property def stale(self): """ :return: if the node needs to be updated before use. :rtype: bool """ return self._stale @property def frozen(self): """ If a node is frozen it will be unaffected by updates to its children. It will also not notify its parents of any updates. :return: if the node is frozen. :rtype: bool """ return self._frozen @property def name(self): """ :return: the name of the node. :rtype: str """ return self._name @name.setter def name(self, name): NodeBase._check_name_raise(name) self._name = name # -- public API def add_child(self, node): """ Add a child node to this node. This node will automatically add itself as a parent of the child node. :param node: the child node to be added. :type node: NodeBase """ if not isinstance(node, NodeBase): # wrap non-node values inside `Parameter` node = Parameter(node) self._children.append(node) node.add_parent(self) self.mark_for_update() def add_parent(self, node): """ Add a parent node to this node. Not to be called manually but as an automatic response to NodeBase.add_child! :param node: the parent node to be added. :type node: NodeBase """ if not isinstance(node, NodeBase): raise TypeError( "Cannot add parent: expected " "node type, got {}".format(type(node)) ) if self not in node.get_children(): raise NodeException("Child must be added to parent, not the other way around!") self._parents.add(weakref.ref(node)) def get_children(self): """ :return: a list containing the children of this node. :rtype: list of NodeBase """ return self._children def get_parents(self): """ :return: a list containing the parents of this node. :rtype: list of NodeBase """ return list(self.iter_parents()) def remove_child(self, node): """ Remove a child node from this node. Automatically removes this node from parents of child node. :param node: the child node to be removed. :type node: NodeBase """ if not isinstance(node, NodeBase): raise TypeError( "Cannot remove child: expected " "node type, got {}".format(type(node)) ) # remove all instances of the child node from root children self._children = [ _child for _child in self._children if _child is not node ] # remove self node from node parents node.remove_parent(self) self.mark_for_update() def remove_parent(self, node): """ Remove a parent node from this node. Not to be called manually but as an automatic response to NodeBase.remove_child! :param node: the parent node to be removed. :type node: NodeBase """ if not isinstance(node, NodeBase): raise TypeError( "Cannot remove parent: expected " "node type, got {}".format(type(node)) ) if self in node.get_children(): raise NodeException("Must remove child from parent, not the other way around!") # remove node from node parents self._parents.remove(weakref.ref(node)) # do *not* remove self node from node children def iter_parents(self): """ Generator for parent nodes. """ _out_of_scope_refs = [] for _p_ref in self._parents: _p = _p_ref() # dereference weakref # parent went out of scope if _p is None: _out_of_scope_refs.append(_p_ref) continue yield _p # cleanup if _out_of_scope_refs: logging.debug( "{} parent refs went out of scope since last " "call to 'iter_parents' and will be removed.".format( len(_out_of_scope_refs) ) ) for _ref in _out_of_scope_refs: self._parents.remove(_ref) def set_children(self, children): """ Setter method for children. New children that are not of type NodeBase will be wrapped in a Parameter node. :param children: the new children of this node. :type children: iterable """ _new_children = [] for _child in children: # wrap literal values inside 'Parameter' if not isinstance(_child, NodeBase): _child = Parameter(_child) _new_children.append(_child) self._children = _new_children for _child in self._children: _child.add_parent(self) self.mark_for_update() def notify_parents(self): """ Notify parents that they will need to be updated because this node has changed. """ for _p in self.iter_parents(): _p.mark_for_update() def freeze(self): """ Sets this node's frozen property to True. """ self._frozen = True def unfreeze(self): """ Sets this node's frozen property to False. """ self._frozen = False self._stale = True def mark_for_update(self): """ Sets this node's stale property to True. """ if not self.stale and not self.frozen: self._stale = True self.notify_parents() def update(self): """ Sets this node's stale property to False and performs any necessary updates to this node. """ self._stale = False def replace(self, other, other_children=True): """ Replace all instances of this node with `other`. The order of children will be preserved. :arg other: the node that this node should be replaced with. :type other: any :arg other_children: if True, `other` will keep its own children after the replacement. If False, only `other` will be replaced: after the replacement other will have the same children as this node. :type other_children: bool """ # Do nothing if a node is supposed to be replaced with itself if self is other: return if not isinstance(other, NodeBase): other = Parameter(other) if not other_children: other.set_children(self.get_children()) for _parent in self.get_parents(): _parent.replace_child(current_child=self, new_child=other) def replace_child(self, current_child, new_child): """ Replace a child node of this node with another node. If new_child is not of type NodeBase it will be wrapped inside a Parameter node. The order of children will be preserved. :param current_child: the child node to be replaced. :type current_child: NodeBase :param new_child: the new child to replace current_child with. :type new_child: any """ if not isinstance(new_child, NodeBase): # wrap non-node values inside `Parameter` new_child = Parameter(new_child) if current_child not in self._children: raise NodeException("Cannot replace child %s because it is not a child of %s." % (current_child.name, self.name)) self._children = [_c if _c is not current_child else new_child for _c in self._children] new_child.add_parent(self) current_child.remove_parent(self) self.mark_for_update() def print_descendants(self): """ Recursively print this node and its children. """ NodeChildrenPrinter(self).run() class RootNode(NodeBase): """ A Node that acts as the root node of a graph. Cannot have any parent nodes. All other nodes are direct or indirect children of this node. This node therefore depends on all other nodes. """ def __init__(self): self._name = '__root__' self._stale = True self._children = [] self._parents = set() # root node has no parents def add_child(self, node): NodeBase.add_child(self, node) # keep root node children sorted by name self._children = sorted(self._children, key=lambda x: x.name) def replace(self, other): raise TypeError("Root node cannot be replaced!") def add_parent(self, parent): raise TypeError("Cannot add parent to root node!") def iter_parents(self): # empty generator return iter(()) def notify_parents(self): pass @_add_common_operators class ValueNode(NodeBase): """ Partly abstract class for a graph node that can have a value. """ def __init__(self, value=None, name=None): """ :param value: the value of this node. :type value: any :param name: the name of this node. :type name: str """ NodeBase.__init__(self, name=name) self._value = value self._stale = False def __str__(self): try: _val = str(self.value) except Exception as e: _val = repr(e) return "{}('{}') = {} [{}]".format( self.__class__.__name__, self.name, _val, hex(id(self)) ) def _pprint(self): try: _val = str(self.value) except Exception as e: _val = repr(e) if '\n' in _val: _val = '\n' + _val else: _val = ' ' + _val return NodeBase._pprint(self) + ' =' + _val @classmethod def _make_binop_method(cls, op): """ Define binary operators for this class. """ def _op_method(self, other): if not isinstance(other, NodeBase): other = Parameter(other) _auto_name = "{}__{}__{}".format(self.name, op.__name__, other.name) return Function( func=op, name=_auto_name, parameters=(self, other), ) return _op_method @classmethod def _make_rbinop_method(cls, op): """ Define reverse binary operators for this class. """ def _op_method(self, other): if not isinstance(other, NodeBase): other = Parameter(other) _auto_name = "{}__r{}__{}".format(self.name, op.__name__, other.name) return Function( func=op, name=_auto_name, parameters=(other, self), ) return _op_method @classmethod def _make_unaryop_method(cls, op): """ Define unary operators for this class. """ def _op_method(self): _auto_name = "{}__{}".format(op.__name__, self.name) return Function( func=op, name=_auto_name, parameters=(self,), ) return _op_method @property def value(self): """ :return: the value of this node. :rtype: any """ if self.stale and not self.frozen: self.update() return self._value @value.setter def value(self, value): self._value = value # notify parents that a child value has changed self.notify_parents() class Empty(ValueNode): """ A graph node that acts as a placeholder for a ValueNode. Should be replaced by a ValueNode in the finished graph. Raises an Exception if an attempt is made to set or retrieve the value. """ def __init__(self, name=None): NodeBase.__init__(self, name=name) def __str__(self): return "{}('{}') [{}]".format( self.__class__.__name__, self.name, hex(id(self)) ) def _pprint(self): return NodeBase._pprint(self) @property def value(self): raise NodeException( "Empty node '{}' does not have a value.".format( self.name ) ) @value.setter def value(self, value): raise NodeException( "Cannot set value of empty node '{}'.".format( self.name ) ) class Parameter(ValueNode): """ Simple subclass of ValueNode that represents a constant value. """ def __init__(self, value, name=None): ValueNode.__init__(self, value=value, name=name) self._stale = False def mark_for_update(self): pass # Simple parameters are always up-to-date. class Alias(ValueNode): """ A Node that only passes on the value of another node when evaluated. Used to add multiple functionally equivalent nodes with differing names to a graph. """ def __init__(self, ref, name=None): ValueNode.__init__(self, value=None, name=name) self.ref = ref self._stale = True def _pprint(self): return '{} -> {}'.format( NodeBase._pprint(self), NodeBase._pprint(self.ref) ) @ValueNode.value.setter def value(self, value): raise NodeException( "Cannot set value of alias node '{}'.".format( self.name ) ) @property def ref(self): """ :return: The node for which this is an alias. """ return self._children[0] @ref.setter def ref(self, ref): self.set_children([ref]) ref.add_parent(self) def update(self): self._value = self.ref.value self._stale = False class Function(ValueNode): """ Subclass of ValueNode that computes its value from the values of its children. """ def __init__(self, func, name=None, parameters=None): """ Creates a new function node. If any of the parameters are not of type NodeBase they will be wrapped in Parameter nodes. :param func: the function used to compute this node's value. :type func: Callable :param name: the name of this node. :type name: str :param parameters: the parameters of the function. :type parameters: iterable """ if name is None and func.__name__ != "<lambda>": name = func.__name__ super(Function, self).__init__(value=None, name=name) self.func = func parameters = parameters or [] self.parameters = parameters self.set_children(parameters) self._par_cache = [] def __call__(self): return self._func(*self._par_cache) @property def parameters(self): """ A subset of this node's children. Passed to the function handle when this node is updated. :return: The nodes representing the function parameters. """ return self._parameters @parameters.setter def parameters(self, parameters): self._parameters = list(parameters) @property def func(self): """ :return: The function handle to be called when updating this node. """ return self._func @func.setter def func(self, function_handle): self._func = function_handle self._stale = True @ValueNode.value.setter def value(self, value): raise NodeException("Function node value cannot be set!") def add_parameter(self, parameter): """ Add a parameter for this function. Automatically adds the parameter to this node's children as well. :param parameter: the parameter to be added. :type parameter: any """ self._parameters.append(parameter) self.add_child(parameter) def update(self): for _child in self.get_children(): if _child.stale and not _child.frozen: _child.update() self._par_cache = [ _par.value for _par in self._parameters ] self._value = self() self._stale = False def replace(self, other, other_children=True): NodeBase.replace(self, other, other_children) if not other_children and isinstance(other, Function): other.parameters = self.parameters def replace_child(self, current_child, new_child): NodeBase.replace_child(self, current_child, new_child) self._parameters = [_p if _p is not current_child else new_child for _p in self._parameters] class Fallback(ValueNode): """ Node that tries to retrieve the value of several other nodes until it finds a node that doesn't raise an exception. """ def __init__(self, try_nodes, exception_type=Exception, name=None): """ Create a new Fallback node. Any objects in try_nodes that are not of type NodeBase will be wrapped inside a Parameter node. :param try_nodes: the value literals / nodes to try to retrieve the value from. :type try_nodes: iterable :param exception_type: the type of Exception upon which to continue to the next node. :type exception_type: type :param name: the name of the node. :type name: str """ super(Fallback, self).__init__(value=None, name=name) self.try_nodes = try_nodes self._exception_type = exception_type self._value = None if name is None: self.name = '__onfail__'.join([_n.name for _n in self.try_nodes]) def __call__(self): for _node in self.try_nodes: try: return _node.value except self._exception_type: pass # function failed; try next raise FallbackError( "Error evaluating fallback node '{}': " "no alternative succeeded".format(self.name) ) @property def try_nodes(self): """ :return: The nodes to try in order to retrieve the value from. Equivalent to get_children. :rtype: list of NodeBase """ return self._children @try_nodes.setter def try_nodes(self, try_nodes): self.set_children(try_nodes) def update(self): self._value = self() self._stale = False class Tuple(ValueNode): """ Node that combines several other nodes into a tuple for its own value. """ def __init__(self, nodes, name=None): """ Create a new Tuple node. Objects in nodes that are not of type NodeBase will be wrapped inside a Parameter node. :param nodes: the literals / nodes to combine into a tuple. :type nodes: iterable :param name: the name of the node. :type name: str """ super(Tuple, self).__init__(value=None, name=name) self.nodes = nodes self._value = None if name is None and self.nodes: self.name = '__'.join([_n.name for _n in self.nodes]) def __iter__(self): for _n in self.nodes: yield _n def __len__(self): return len(self._children) def __getitem__(self, index): return self._children[index] def __setitem__(self, index, item): if not isinstance(item, NodeBase): item = Parameter(item) self._children[index] = item @property def nodes(self): """ :return: The nodes representing the tuple content. :rtype: list of NodeBase """ return self._children @nodes.setter def nodes(self, nodes): self.set_children(nodes) def update(self): self._value = tuple([ _node.value for _node in self.nodes ]) self._stale = False def iter_values(self): """ Generator for Tuple.value. """ for _val in self.value: yield _val class Array(Tuple): """ Node that combines several other nodes into a numpy array for its own value. """ def __init__(self, nodes, name=None, dtype=None): """ Create a new Array node. Objects in nodes that are not of type NodeBase will be wrapped inside a Parameter node. :param nodes: the literals / nodes to combine into a numpy array. :type nodes: iterable :param name: the name of the node. :type name: str :param dtype: the data type of teh numpy array. :type dtype: type """ super(Tuple, self).__init__(value=None, name=name) self._dtype = dtype self.nodes = nodes if name is None and self.nodes: self.name = 'array_' + '__'.join([_n.name for _n in self.nodes]) @Tuple.nodes.setter def nodes(self, nodes): self.set_children(nodes) self._value = np.empty(len(nodes), dtype=self._dtype) def update(self): for _i, _node in enumerate(self.nodes): self._value[_i] = _node.value self._stale = False def iter_values(self): return self.value.__iter__() # -- Node visitors class NodeChildrenPrinter(object): """ Visitor class that recursively prints a node and its children. """ def __init__(self, root_node): self._root = root_node def visit(self, node, indent=''): _s = node._pprint() if '\n' in _s: _s = _s.replace('\n', '\n'+indent+' ') print(indent + '+ ' + _s) def run(self, node=None, indent=''): node = node if node is not None else self._root # visit current node self.visit(node, indent=indent) # recursively visit children for _c in node.get_children(): self.run(_c, indent=indent + ' ') class NodeSubgraphGraphvizSourceProducer(object): """ Visitor class for debugging that creates a graphviz representation of a node graph (i.e. a Nexus). This class has **not** been unit tested. """ _NODE_STYLE = { Function: dict( shape='"box"'), Alias: dict( shape='"cds"'), Fallback: dict( shape='"diamond"'), Empty: dict( shape='"Mcircle"'), } def __init__(self, root_node, exclude=None): self._root = root_node self._exclude = exclude or set() self._nodes = set() self._leaf_nodes = set() self._connected_nodes = set() self._full_edges = set() self._dashed_edges = set() def visit(self, node): self._nodes.add(node) for _c in node.get_children(): self._nodes.add(node) if node in self._exclude or _c in self._exclude: continue self._full_edges.add( (node, _c) ) self._nodes.add(_c) for _p in node.iter_parents(): self._nodes.add(node) if node in self._exclude or _p in self._exclude: continue self._dashed_edges.add( (_p, node) ) self._nodes.add(_p) def run(self, node=None, node_chain=None, out_stream=None): node = node if node is not None else self._root _first_call = node_chain is None node_chain = node_chain or set() # don't revisit previous nodes if node in node_chain: return # visit current node self.visit(node) node_chain.add(node) # recursively visit children for _c in node.get_children(): NodeSubgraphGraphvizSourceProducer.run(self, _c, node_chain=node_chain) # recursively visit parents for _p in node.iter_parents(): NodeSubgraphGraphvizSourceProducer.run(self, _p, node_chain=node_chain) if _first_call: out_stream = out_stream if out_stream is not None else sys.stdout import functools _all_edges = self._full_edges.union(self._dashed_edges) _connected_nodes = set(functools.reduce( lambda x, y: x+y, _all_edges, )) _isolated_nodes = self._nodes - _connected_nodes self._exclude |= _isolated_nodes _leaf_nodes = ( set([n for _, n in _all_edges]) - set([n for n, _ in _all_edges]) ) out_stream.write("digraph {} {{\n\n".format(node.name)) for _n in _connected_nodes: if _n in self._exclude: continue out_stream.write( ' {0.name} [label=<<i>{0.__class__.__name__}</i>' '<br />{0.name}>, {1}]\n'.format( _n, ', '.join([ "{}={}".format(_k, _v) for _k, _v in self._NODE_STYLE.get(_n.__class__, {}).items() ] + (['style=filled', 'fillcolor=yellow'] if _n in _leaf_nodes else [])), ) ) out_stream.write('\n') for _e in self._full_edges: if _e[0] in self._exclude or _e[1] in self._exclude: continue out_stream.write(" {0.name} -> {1.name}\n".format(*_e)) out_stream.write('\n') for _e in self._dashed_edges - self._full_edges: if _e[0] in self._exclude or _e[1] in self._exclude: continue out_stream.write(" {0.name} -> {1.name} [style=dashed]\n".format(*_e)) out_stream.write("\n}\n") out_stream.flush() self._full_edges = set() self._dashed_edges = set() class NodeSubgraphGraphvizViewer(NodeSubgraphGraphvizSourceProducer): def run(self, node=None, node_chain=None): from graphviz import Source import tempfile out = six.StringIO() NodeSubgraphGraphvizSourceProducer.run( self, node, node_chain, out_stream=out) out.seek(0) Source(out.read()).render(tempfile.mktemp('.gv'), view=True) class NodeCycleChecker(object): """ Visitor class that ensures that a node graph is acyclic, i.e. that there are no cyclic dependencies. """ def __init__(self, root_node): self._root = root_node def visit(self, node, seen): if node in seen: _cycle = seen[seen.index(node):] + (node,) raise ValueError("Dependent node cycle detected ({})".format( ' -> '.join([_n.name for _n in _cycle]) )) def run(self, node=None, seen=None): node = node if node is not None else self._root seen = seen if seen is not None else tuple() # visit current node self.visit(node, seen) # keep track of nodes encountered seen += (node,) # recursively visit parents for _c in node.iter_parents(): self.run(node=_c, seen=seen) # -- Nexus class NexusError(Exception): pass class Nexus(object): """ Object representing an entire computation graph. Used in the kafe2 NexusFitter object to manage the caching of intermediate results for the calculation of the cost function value. """ _VALID_GET_DICT_ERROR_BEHAVIORS = ( 'fail', 'none', 'exception_as_value', 'ignore', 'list') _VALID_ADD_EXISTING_BEHAVIORS = ( 'fail', 'ignore', 'replace', 'replace_if_alias', 'replace_if_empty') def __init__(self): self._nodes = { '__root__': RootNode() } self._root_ref = weakref.ref(self._nodes['__root__']) # convenience def add(self, node, add_children=True, existing_behavior='fail'): """Add a node to the nexus. The `node` type should be derived from :py:class:`~kafe.core.fitters.nexus_v2.NodeBase`. If not, it will be wrapped inside a :py:class:`~kafe.core.fitters.nexus_v2.Parameter` node. Nexus node names must be unique. If a node with the same name has already been added, the behavior of this function can be configured via `existing_behavior`, which takes one of three values: - ``fail``: raise a `NexusError` - ``replace``: replace the existing node with the one being added - ``replace_if_alias``: replace the existing node with the one only if the existing node is an alias - ``replace_if_empty``: replace the existing node with the one only if the existing node is empty - ``ignore``: do not add the node :param node: node to add :type node: :py:class:`~kafe.core.fitters.nexus_v2.NodeBase` or other :param add_children: if True, recursively add node children to self if self does not have them. :type add_children: bool :param existing_behavior: how to behave if a node with the same name has already been added to the nexus. One of: ``fail`` (default), ``replace``, ``replace_if_alias``, ``replace_if_empty``, ``ignore``. :type existing_behavior: str :returns: the added node """ # validate `existing_behavior` if existing_behavior not in self._VALID_ADD_EXISTING_BEHAVIORS: raise ValueError( "Unknown value {!r} for `existing_behavior`: " "expected one of {!r}".format( existing_behavior, self._VALID_ADD_EXISTING_BEHAVIORS ) ) # check if node has already been added if node.name in self._nodes: # resolve behavior if node is empty if existing_behavior == 'replace_if_empty': existing_behavior = ( 'replace' if isinstance(self._nodes[node.name], Empty) else 'fail' ) elif existing_behavior == 'replace_if_alias': existing_behavior = ( 'replace' if isinstance(self._nodes[node.name], Alias) else 'fail' ) # execute behavior if existing_behavior == 'fail': raise NexusError( "Node '{}' already exists.".format( node.name ) ) if existing_behavior == 'replace': if add_children: # add all dependent children to the nexus first for _child in node.get_children(): self.add(_child, add_children=True, existing_behavior='ignore') # replace node self._nodes[node.name].replace(node) elif existing_behavior == 'ignore': return # else: assert False # should not get here # node has not been added before else: if add_children: # add all dependent children to the nexus first for _child in node.get_children(): self.add(_child, add_children=True, existing_behavior='ignore') # add new node as child of root node self._root_ref().add_child(node) # remove nexus root from all children's parents (if present) for _child in node.get_children(): try: self._root_ref().remove_child(_child) except KeyError: pass # (re)map name to point to node self._nodes[node.name] = node # check for cycles NodeCycleChecker(node).run() return node def add_function(self, func, func_name=None, par_names=None, add_children=True, existing_behavior='fail'): """Construct a `Function` node from a Python function and add it to the nexus. The object passed as `func` should be a native Python function. If other callables (e.g. `lambda` expressions) are passed, they must either have a `__name__` parameter or `func_name` must be provided. The function node name is set to `func_name` (if provided) or `func.__name__`. For every parameter of the function, there should already be a nexus node with the same name as the parameter name. If they exist, they will be registered automatically as dependencies of the function node, meaning that the function value will be recalculated every time a parameter changes value. In case the function parameter names do not correspond exactly to the names of the parameter nodes in the nexus, a list of node names to use as parameters can be specified via the `par_names` keyword, If any of the specified parameter nodes does not exist, it will be created. In case a default value for the parameter is specified in the function signature, a :py:class:`~kafe.core.fitters.nexus.Parameter` node will be created and initialized to that value. If no default is specified, an :py:class:`~kafe.core.fitters.nexus.Empty` node will be created. It should be replaced by a non-empty node before the function is evaluated. Any variable-length arguments (``*args``) and keyword arguments (``**kwargs``) in the function signature are ignored when creating parameters. If a node with the same name as the function node has already been added, the behavior of this function can be configured via `existing_behavior`. For details, see :py:meth:`~kafe.core.fitters.nexus.Nexus.add`. :param func: function to add as node :type func: function :param func_name: node name to use instead of function name :type func_name: str :param par_names: node name to use as function parameters :type par_names: list of str :param add_children: if True, recursively add node children to self if self does not have them. :type add_children: bool :param existing_behavior: how to behave if a node with the same name has already been added to the nexus. One of: ``fail`` (default), ``replace``, ``replace_if_empty``, ``ignore``. :type existing_behavior: str :returns: the added function node """ # resolve function name func_name = func_name or func.__name__ if par_names is not None: _par_nodes = [ self._nodes[_par_name] if _par_name in self._nodes else Empty(_par_name) for _par_name in par_names ] return self.add( Function(func, name=func_name, parameters=_par_nodes), add_children=add_children, existing_behavior=existing_behavior ) # resolve parameter names _sig = signature(func) # take child node names from signature par_names = [_p.name for _p in _sig.parameters.values()] # assert compatibility between function signature # and supplied node names try: _ba = _sig.bind(*par_names) assert len(par_names) >= len(_sig.parameters) # Assert function isn't under-supplied. except (AssertionError, TypeError): raise ValueError( "Error adding function: supplied " "parameter nodes ({}) are not compatible with " "function signature {!r}!".format( ', '.join(map(repr, par_names)), _sig ) ) _args = _ba.arguments.items() _args_defaults = [_a.default for _a in _sig.parameters.values()] assert len(_args_defaults) >= len(_args) # barring any unbound *args, **kwargs # resolve parameter nodes _pars = [] for (_arg_name, _node_spec), _arg_default in zip(_args, _args_defaults): # fail on **kwargs if isinstance(_node_spec, dict): raise ValueError( "Error adding function: signature " "cannot contain variable keyword arguments " "(**{})!".format( _arg_name ) ) # wrap str in a tuple (normal non-* case) if isinstance(_node_spec, str): _node_spec = (_node_spec,) assert(isinstance(_node_spec, tuple)) # add node or nodes under *args for _node_name in _node_spec: # check if parameter node exists if _node_name not in self._nodes: if _arg_default == SigParameter.empty: # create empty node and add _pars.append(self.add(Empty(name=_node_name))) else: # create parameter node and add _pars.append(self.add(Parameter(_arg_default, name=_node_name))) else: _existing_node = self._nodes[_node_name] # if default value provided if _arg_default != SigParameter.empty: # node is empty if isinstance(_existing_node, Empty): # value encountered for previously empty node -> replace _pars.append(self.add( Parameter(_arg_default, name=_existing_node.name), existing_behavior='replace' )) continue # if node non-empty else: # new default may conflict -> warn if necessary try: assert(_existing_node.value == _arg_default) except AssertionError: # values definitely conflict warnings.warn( "Ignoring default value {!r} for function parameter '{}': " "non-empty nexus node already exists and has conflicting " "value {!r}.".format( _arg_default, _node_name, _existing_node.value ), UserWarning ) # register existing node as parameter _pars.append(_existing_node) # add function node to nexus and return it return self.add( Function(func, name=func_name, parameters=_pars), add_children=add_children, existing_behavior=existing_behavior ) def add_alias(self, name, alias_for, existing_behavior='fail'): """Add an Alias node pointing to an existing node `alias_for`. If a node with the same name as the alias node has already been added, the behavior of this function can be configured via `existing_behavior`. For details, see :py:meth:`~kafe.core.fitters.nexus.Nexus.add`. :param name: name of the alias node to add :type name: str :param alias_for: name of the node being pointed to by the alias. :type alias_for: str :param existing_behavior: how to behave if a node with the same name has already been added to the nexus. One of: ``fail`` (default), ``replace``, ``replace_if_empty``, ``replace_if_alias``, ``ignore``. :type existing_behavior: str :return: the added alias node """ _alias_for_node = self.get(alias_for) if _alias_for_node is None: raise ValueError( "Cannot add alias for node '{}': " "node does not exist in nexus!".format(alias_for) ) return self.add( Alias( _alias_for_node, name=name ), existing_behavior=existing_behavior ) def add_dependency(self, name, depends_on): """Register a dependency between nodes explicitly. This indicates that the value of node `name` may depend on the value of another node `depends_on`. When the value of `depends_on` changes, `name` will be notified. The specification `depends_on` may be a list or a tuple, in which case a dependency is added for each specified node. Note that this method should only be used for establishing *explicit* dependencies. Other methods such as `add`, `add_function` or `add_alias` will create *implicit* dependencies between nodes, such as between a `Function` node and its parameters or between an `Alias` node and the node it points to). In those cases it is not necessary to call `add_dependency` explicitly. This method is useful when node values may depend on an external state that operates on the nexus but is not itself part of it. :param name: name of the node whose value depends on (an)other node(s) :type name: str :param depends_on: name(s) of the node(s) whose value node `name` depends on :type depends_on: str or tuple/list of str :return: self (the Nexus instance) :rtype: Nexus """ _node = self.get(name) if _node is None: raise ValueError( "Cannot add dependency: dependent node '{}' does " "not exist!".format(name) ) if not isinstance(depends_on, (tuple, list)): depends_on = (depends_on,) _not_found = [_dep for _dep in depends_on if self.get(_dep) is None] if _not_found: raise ValueError( "Cannot add dependency: the following nodes passed to " "`depends_on` do not exist: {}".format( ', '.join(map(repr, _not_found)) ) ) # add dependent node `name` as a parent of each node in `depends_on` for _dep in depends_on: _node.add_child(self.get(_dep)) # check for cycles NodeCycleChecker(_node).run() def get(self, node_name): """Retrieve a node by its name or ``None`` if no such node exists. :param node_name: name of the node to get :type node_name: str :return: the node or ``None`` if it does not exist """ return self._nodes.get(node_name, None) def get_value_dict(self, node_names=None, error_behavior='fail'): """Return a mapping of node names to their current values. The behavior when encountering an evaluation error can be specified as a string: * ``'fail'``: raise an exception * ``'none'``: use ``None`` as a value * ``'exception_as_value'``: use the raised exception as a node value * ``'ignore'``: do not include erroring nodes in result dict * ``'list'``: return list of erroring nodes in result dict under special key ``__error__`` :param node_names: name of the nodes for which to get values. If ``None``, all nodes are evaluated. :type node_names: list of str or ``None`` :param error_behavior: how to behave if a node with the same name has already been added to the nexus. One of: ``fail`` (default), ``none``, ``ignore``, ``list``, ``exception_as_value``. :type error_behavior: str :return: dict mapping node names to values """ # validate `error_behavior` if error_behavior not in self._VALID_GET_DICT_ERROR_BEHAVIORS: raise ValueError( "Unknown value {!r} for `error_behavior`: " "expected one of {!r}".format( error_behavior, self._VALID_GET_DICT_ERROR_BEHAVIORS ) ) # construct result dict _result_dict = {} for _name, _node in self._nodes.items(): # skip root node (has no value anyway) if _name == '__root__': continue if node_names is not None and _name not in node_names: continue # attempt evaluation and behave accordingly on error try: _val = _node.value except Exception as e: if error_behavior == 'fail': raise e if error_behavior == 'none': _val = None elif error_behavior == 'exception_as_value': _val = e elif error_behavior == 'ignore': continue elif error_behavior == 'list': _result_dict.setdefault('__error__', []).append(_name) continue else: assert False, "Something went terribly wrong. " \ "Unknown error behaviour {}".format(error_behavior) else: _result_dict[_name] = _val return _result_dict def print_state(self): """Print a representation of the nexus state.""" NodeChildrenPrinter(self._root_ref()).run()
dsavoiu/kafe2
kafe2/core/fitters/nexus.py
Python
gpl-3.0
50,584
[ "VisIt" ]
6b2717e8b58e822f9f90a5c5789b115560158b1d71daa5684442cb4f60c14f8f
"""Define a graph of nodes-links-patches. Nodes and links are required. If no patches are provided, no patches will be created. Examples -------- >>> from landlab.graph import NetworkGraph, Graph >>> node_x, node_y = [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 1, 2, 0, 1, 2, 0, 1, 2] >>> graph = NetworkGraph((node_y, node_x), sort=True) >>> graph.x_of_node array([ 0., 1., 2., 0., 1., 2., 0., 1., 2.]) >>> graph.y_of_node array([ 0., 0., 0., 1., 1., 1., 2., 2., 2.]) >>> graph.ndim 2 >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links, sort=True) >>> graph.nodes_at_link # doctest: +NORMALIZE_WHITESPACE array([[0, 1], [1, 2], [0, 3], [1, 4], [2, 5], [3, 4], [4, 5], [3, 6], [4, 7], [5, 8], [6, 7], [7, 8]]) >>> graph.node_at_link_head array([1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 7, 8]) >>> graph.node_at_link_tail array([0, 1, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7]) >>> graph.links_at_node # doctest: +NORMALIZE_WHITESPACE array([[ 0, 2, -1, -1], [ 1, 3, 0, -1], [ 4, 1, -1, -1], [ 5, 7, 2, -1], [ 6, 8, 5, 3], [ 9, 6, 4, -1], [10, 7, -1, -1], [11, 10, 8, -1], [11, 9, -1, -1]]) >>> graph.link_dirs_at_node # doctest: +NORMALIZE_WHITESPACE array([[-1, -1, 0, 0], [-1, -1, 1, 0], [-1, 1, 0, 0], [-1, -1, 1, 0], [-1, -1, 1, 1], [-1, 1, 1, 0], [-1, 1, 0, 0], [-1, 1, 1, 0], [ 1, 1, 0, 0]], dtype=int8) >>> patches = ((5, 3, 0, 2), (6, 4, 1, 3), (10, 8, 5, 7), (11, 9, 6, 8)) >>> graph = Graph((node_y, node_x), links=links, patches=patches, sort=True) >>> graph.links_at_patch array([[ 3, 5, 2, 0], [ 4, 6, 3, 1], [ 8, 10, 7, 5], [ 9, 11, 8, 6]]) >>> graph.nodes_at_patch array([[4, 3, 0, 1], [5, 4, 1, 2], [7, 6, 3, 4], [8, 7, 4, 5]]) """ import json from functools import lru_cache import numpy as np import xarray as xr from ..core.utils import as_id_array from ..utils.decorators import read_only_array from .object.at_node import get_links_at_node from .object.at_patch import get_nodes_at_patch from .quantity.of_link import ( get_angle_of_link, get_length_of_link, get_midpoint_of_link, ) from .quantity.of_patch import get_area_of_patch, get_centroid_of_patch from .sort import reindex_by_xy from .sort.sort import reorient_link_dirs, reverse_one_to_many, sort_spokes_at_hub from .ugrid import ugrid_from_unstructured def find_perimeter_nodes(graph): """Find nodes on the perimeter of a graph. Uses a convex hull to locate the perimeter nodes of a graph. Parameters ---------- graph : graph_like A Graph of nodes (just requires *xy_of_node*). Returns ------- ndarray of int Identifiers of the perimeter nodes. """ from scipy.spatial import ConvexHull hull = ConvexHull(graph.xy_of_node, qhull_options="Qt") return as_id_array(hull.vertices) class thawed(object): def __init__(self, graph): self._graph = graph self._initially_frozen = graph.frozen def __enter__(self): self._graph.thaw() def __exit__(self, ex_type, ex_value, traceback): if self._initially_frozen: self._graph.freeze() def _update_node_at_cell(ugrid, node_at_cell): node_at_cell = xr.DataArray( data=as_id_array(node_at_cell), dims=("cell",), attrs={ "cf_role": "cell_node_connectivity", "long_name": "nodes centered at cells", "start_index": 0, }, ) ugrid.update({"node_at_cell": node_at_cell}) def _update_nodes_at_face(ugrid, nodes_at_face): nodes_at_face = xr.DataArray( data=as_id_array(nodes_at_face), dims=("face", "Two"), attrs={ "cf_role": "face_node_connectivity", "long_name": "nodes on either side of a face", "start_index": 0, }, ) ugrid.update({"nodes_at_face": nodes_at_face}) class NetworkGraph: """Define the connectivity of a graph of nodes and links. Unlike Graph, NetworkGraph does not have patches. """ def __init__(self, node_y_and_x, links=None, sort=False): """Define a graph of connected nodes. Parameters ---------- mesh : Dataset xarray Dataset that defines the topology in ugrid format. """ self._ds = ugrid_from_unstructured(node_y_and_x, links=links) self._frozen = False self.freeze() if sort: NetworkGraph.sort(self) self._origin = (0.0, 0.0) @property def frozen(self): return self._frozen def thawed(self): return thawed(self) def sort(self): """Sort graph elements.""" with self.thawed(): reorient_link_dirs(self) sorted_nodes, sorted_links, sorted_patches = reindex_by_xy(self) if "links_at_patch" in self.ds: sort_spokes_at_hub( self.links_at_patch, np.round(self.xy_of_patch, decimals=4), np.round(self.xy_of_link, decimals=4), inplace=True, ) return sorted_nodes, sorted_links, sorted_patches def freeze(self): """Freeze the graph by making arrays read-only.""" for var in self.ds.variables: array = self.ds[var].values while array is not None: array.flags.writeable = False array = array.base self._frozen = True def thaw(self): """Thaw the graph by making arrays writable.""" for var in self.ds.variables: arrays = [] array = self.ds[var].values while array is not None: arrays.append(array) array = array.base for array in arrays[::-1]: array.flags.writeable = True self._frozen = False def _add_variable(self, name, var, dims=None, attrs=None): kwds = dict(data=var, dims=dims, attrs=attrs) self.ds.update({name: xr.DataArray(**kwds)}) if self._frozen: self.freeze() @property def ds(self): return self._ds def to_dict(self): return self.ds.to_dict() def to_json(self): return json.dumps(self.ds.to_dict()) def to_netcdf(self, *args, **kwds): """Write graph contents to a netCDF file. See xarray.Dataset.to_netcdf for a complete list of parameters. Below are only the most common. Parameters ---------- path : str, optional Path to which to save this graph. mode : {'w', 'a'}, optional Write ('w') or append ('a') mode. If mode='w', any existing file at this location will be overwritten. format : {'NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT', 'NETCDF3_CLASSIC'}, optional File format for the resulting netCDF file: * NETCDF4: Data is stored in an HDF5 file, using netCDF4 API features. * NETCDF4_CLASSIC: Data is stored in an HDF5 file, using only netCDF 3 compatible API features. * NETCDF3_64BIT: 64-bit offset version of the netCDF 3 file format, which fully supports 2+ GB files, but is only compatible with clients linked against netCDF version 3.6.0 or later. * NETCDF3_CLASSIC: The classic netCDF 3 file format. It does not handle 2+ GB files very well. All formats are supported by the netCDF4-python library. scipy.io.netcdf only supports the last two formats. The default format is NETCDF4 if you are saving a file to disk and have the netCDF4-python library available. Otherwise, xarray falls back to using scipy to write netCDF files and defaults to the NETCDF3_64BIT format (scipy does not support netCDF4). """ self.ds.to_netcdf(*args, **kwds) @classmethod def from_netcdf(cls, fname): return cls.from_dataset(xr.open_dataset(fname)) @classmethod def from_dict(cls, meta): return cls( (meta["y_of_node"], meta["x_of_node"]), links=meta.get("nodes_at_link", None), patches=meta.get("links_at_patch", None), ) @classmethod def load(cls, source): if isinstance(source, str): return cls.from_netcdf(source) elif isinstance(source, (dict, xr.Dataset)): return cls.from_dict(source) else: raise ValueError( "source must be dict-like or NetCDF ({type})".format(type=type(source)) ) def __str__(self): return str(self.ds) def __repr__(self): return repr(self.ds) @property def ndim(self): return 2 @property @lru_cache() @read_only_array def xy_of_node(self): """Get x and y-coordinates of node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> graph.xy_of_node[:, 0] array([ 0., 1., 2., 0., 1., 2.]) >>> graph.xy_of_node[:, 1] array([ 0., 0., 0., 1., 1., 1.]) LLCATS: NINF """ return np.stack((self.x_of_node, self.y_of_node)).T.copy() @property def x_of_node(self): """Get x-coordinate of node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> graph.x_of_node array([ 0., 1., 2., 0., 1., 2.]) LLCATS: NINF """ return self.ds["x_of_node"].values @property def y_of_node(self): """Get y-coordinate of node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> graph.y_of_node array([ 0., 0., 0., 1., 1., 1.]) LLCATS: NINF """ return self.ds["y_of_node"].values @property @lru_cache() def node_x(self): return self.x_of_node @property @lru_cache() def node_y(self): return self.y_of_node @property def nodes(self): """Get identifier for each node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> graph.nodes array([0, 1, 2, 3, 4, 5]) LLCATS: NINF """ return self.ds["node"].values @property @lru_cache() @read_only_array def perimeter_nodes(self): """Get nodes on the convex hull of a Graph. Examples -------- >>> import numpy as np >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> np.sort(graph.perimeter_nodes) array([0, 2, 3, 5]) LLCATS: NINF BC SUBSET """ return find_perimeter_nodes(self) @property def number_of_nodes(self): """Get total number of nodes. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1] >>> graph = Graph((node_y, node_x)) >>> graph.number_of_nodes == 6 True LLCATS: NINF """ return self.ds.dims["node"] @property def nodes_at_link(self): """Get nodes at either end of links. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.nodes_at_link # doctest: +NORMALIZE_WHITESPACE array([[0, 1], [1, 2], [0, 3], [1, 4], [2, 5], [3, 4], [4, 5], [3, 6], [4, 7], [5, 8], [6, 7], [7, 8]]) LLCATS: NINF """ return self.ds["nodes_at_link"].values @property def node_at_link_tail(self): """Get nodes at link tail. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.node_at_link_tail array([0, 1, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7]) LLCATS: NINF """ return self.nodes_at_link[:, 0] @property def node_at_link_head(self): """Get nodes at link head. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.node_at_link_head array([1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 7, 8]) LLCATS: NINF """ return self.nodes_at_link[:, 1] @property def number_of_links(self): """Get nodes at link head. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.number_of_links == 12 True """ try: return self.ds.dims["link"] except KeyError: return 0 @property @lru_cache() @read_only_array def links_at_node(self): """Get links touching a node. Examples -------- >>> from landlab.graph import Graph >>> node_x = [0, 1, 2, 0, 1, 2, 0, 1, 2] >>> node_y = [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.links_at_node # doctest: +NORMALIZE_WHITESPACE array([[ 0, 2, -1, -1], [ 1, 3, 0, -1], [ 4, 1, -1, -1], [ 5, 7, 2, -1], [ 6, 8, 5, 3], [ 9, 6, 4, -1], [10, 7, -1, -1], [11, 10, 8, -1], [11, 9, -1, -1]]) LLCATS: LINF """ try: return self._links_at_node except AttributeError: ( self._links_at_node, self._link_dirs_at_node, ) = self._create_links_and_dirs_at_node() return self._links_at_node def _create_links_and_dirs_at_node(self): return get_links_at_node(self, sort=True) @property @lru_cache() @read_only_array def link_dirs_at_node(self): """Get directions of links touching a node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.link_dirs_at_node # doctest: +NORMALIZE_WHITESPACE array([[-1, -1, 0, 0], [-1, -1, 1, 0], [-1, 1, 0, 0], [-1, -1, 1, 0], [-1, -1, 1, 1], [-1, 1, 1, 0], [-1, 1, 0, 0], [-1, 1, 1, 0], [ 1, 1, 0, 0]], dtype=int8) """ try: return self._link_dirs_at_node except AttributeError: ( self._links_at_node, self._link_dirs_at_node, ) = self._create_links_and_dirs_at_node() return self._link_dirs_at_node @property @lru_cache() @read_only_array def angle_of_link(self): """Get the angle of each link. Examples -------- >>> import numpy as np >>> from landlab.graph import Graph >>> node_x, node_y = ([0, 1, 2, 0, 1, 2], ... [0, 0, 0, 1, 1, 1]) >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5)) >>> graph = Graph((node_y, node_x), links=links) >>> graph.angle_of_link * 180. / np.pi array([ 0., 0., 90., 90., 90., 0., 0.]) LLCATS: LINF """ return get_angle_of_link(self) @property @lru_cache() @read_only_array def length_of_link(self): """Get the length of links. Examples -------- >>> import numpy as np >>> from landlab.graph import UniformRectilinearGraph >>> graph = UniformRectilinearGraph((2, 3), spacing=(1, 2)) >>> graph.length_of_link array([ 2., 2., 1., 1., 1., 2., 2.]) LLCATS: LINF """ return get_length_of_link(self) @property @lru_cache() @read_only_array def midpoint_of_link(self): """Get the middle of links. Examples -------- >>> import numpy as np >>> from landlab.graph import UniformRectilinearGraph >>> graph = UniformRectilinearGraph((2, 3), spacing=(1, 2)) >>> graph.midpoint_of_link # doctest: +NORMALIZE_WHITESPACE array([[ 1. , 0. ], [ 3. , 0. ], [ 0. , 0.5], [ 2. , 0.5], [ 4. , 0.5], [ 1. , 1. ], [ 3. , 1. ]]) LLCATS: LINF """ return get_midpoint_of_link(self) @property @lru_cache() @read_only_array def xy_of_link(self): return get_midpoint_of_link(self) @property @lru_cache() @read_only_array def adjacent_nodes_at_node(self): """Get adjacent nodes. Examples -------- >>> from landlab.graph import Graph First, a simple example with no diagonals. >>> node_x, node_y = [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 1, 2, 0, 1, 2, 0, 1, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> graph = Graph((node_y, node_x), links=links, sort=True) >>> graph.adjacent_nodes_at_node array([[ 1, 3, -1, -1], [ 2, 4, 0, -1], [ 5, 1, -1, -1], [ 4, 6, 0, -1], [ 5, 7, 3, 1], [ 8, 4, 2, -1], [ 7, 3, -1, -1], [ 8, 6, 4, -1], [ 7, 5, -1, -1]]) Next, we add the diagonal from node 0 to node 4. >>> node_x, node_y = [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 1, 2, 0, 1, 2, 0, 1, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8), ... (0, 4)) >>> graph = Graph((node_y, node_x), links=links, sort=True) >>> graph.adjacent_nodes_at_node array([[ 1, 4, 3, -1, -1], [ 2, 4, 0, -1, -1], [ 5, 1, -1, -1, -1], [ 4, 6, 0, -1, -1], [ 5, 7, 3, 0, 1], [ 8, 4, 2, -1, -1], [ 7, 3, -1, -1, -1], [ 8, 6, 4, -1, -1], [ 7, 5, -1, -1, -1]]) LLCATS: NINF """ node_is_at_tail = np.choose( self.link_dirs_at_node + 1, np.array((1, -1, 0), dtype=np.int8) ) out = self.nodes_at_link[self.links_at_node, node_is_at_tail] out[node_is_at_tail == -1] = -1 return out @property @lru_cache() @read_only_array def adjacent_links_at_link(self): from .object.ext.at_link import find_adjacent_links_at_link adjacent_links_at_link = np.empty((self.number_of_links, 2), dtype=int) find_adjacent_links_at_link( self.nodes_at_link, self.links_at_node, adjacent_links_at_link ) return adjacent_links_at_link @property @lru_cache() @read_only_array def unit_vector_at_link(self): """Make arrays to store the unit vectors associated with each link. For each link, the x and y components of the link's unit vector (that is, the link's x and y dimensions if it were shrunk to unit length but retained its orientation). Examples -------- The example below is a seven-node hexagonal grid, with six nodes around the perimeter and one node (#3) in the interior. There are four horizontal links with unit vector (1,0), and 8 diagonal links with unit vector (+/-0.5, +/-sqrt(3)/2) (note: sqrt(3)/2 ~ 0.866). >>> from landlab.graph import TriGraph >>> graph = TriGraph((3, 2), spacing=2.0, node_layout="hex", sort=True) >>> np.round(graph.unit_vector_at_link[:, 0], decimals=5) array([ 1. , -0.5, 0.5, -0.5, 0.5, 1. , 1. , 0.5, -0.5, 0.5, -0.5, 1. ]) >>> np.round(graph.unit_vector_at_link[:, 1], decimals=5) array([ 0. , 0.86603, 0.86603, 0.86603, 0.86603, 0. , 0. , 0.86603, 0.86603, 0.86603, 0.86603, 0. ]) """ u = np.diff(self.xy_of_node[self.nodes_at_link], axis=1).reshape((-1, 2)) return u / np.linalg.norm(u, axis=1).reshape((-1, 1)) @property @lru_cache() @read_only_array def unit_vector_at_node(self): """Get a unit vector for each node. Examples -------- >>> from landlab.graph import UniformRectilinearGraph >>> graph = UniformRectilinearGraph((3, 3)) >>> graph.unit_vector_at_node array([[ 1., 1.], [ 2., 1.], [ 1., 1.], [ 1., 2.], [ 2., 2.], [ 1., 2.], [ 1., 1.], [ 2., 1.], [ 1., 1.]]) >>> from landlab.graph import TriGraph >>> graph = TriGraph((3, 2), spacing=2.0, node_layout="hex", sort=True) >>> unit_vector_at_node = np.round(graph.unit_vector_at_node, decimals=5) >>> unit_vector_at_node[:, 0] array([ 2., 2., 2., 4., 2., 2., 2.]) >>> unit_vector_at_node[:, 1] array([ 1.73205, 1.73205, 1.73205, 3.4641 , 1.73205, 1.73205, 1.73205]) """ unit_vector_at_link = np.vstack((self.unit_vector_at_link, [0.0, 0.0])) return np.abs(unit_vector_at_link[self.links_at_node]).sum(axis=1) class Graph(NetworkGraph): """Define the connectivity of a graph of nodes, links, and patches.""" def __init__(self, node_y_and_x, links=None, patches=None, sort=False): if patches is not None and len(patches) == 0: patches = None self._ds = ugrid_from_unstructured(node_y_and_x, links=links, patches=patches) self._frozen = False self.freeze() if sort: Graph.sort(self) self._origin = (0.0, 0.0) def merge(self, dual, node_at_cell=None, nodes_at_face=None): self._dual = dual if node_at_cell is not None: _update_node_at_cell(self.ds, node_at_cell) if nodes_at_face is not None: _update_nodes_at_face(self.ds, nodes_at_face) def sort(self): with self.thawed(): reorient_link_dirs(self) sorted_nodes, sorted_links, sorted_patches = reindex_by_xy(self) # reorder_links_at_patch(self) if "links_at_patch" in self.ds: sort_spokes_at_hub( self.links_at_patch, np.round(self.xy_of_patch, decimals=4), np.round(self.xy_of_link, decimals=4), inplace=True, ) return sorted_nodes, sorted_links, sorted_patches @property @lru_cache() @read_only_array def xy_of_patch(self): """Get the centroid of each patch. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches) >>> graph.xy_of_patch array([[ 0.5, 0.5], [ 1.5, 0.5]]) LLCATS: PINF """ return get_centroid_of_patch(self) @property @lru_cache() @read_only_array def area_of_patch(self): """Get the area of each patch. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches) >>> graph.area_of_patch array([ 1., 1.]) LLCATS: PINF """ return get_area_of_patch(self) @property def number_of_patches(self): """Get the number of patches. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches) >>> graph.number_of_patches == 2 True LLCATS: PINF """ try: return self.ds.dims["patch"] except KeyError: return 0 @property def links_at_patch(self): """Get the links that define a patch. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2] >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches, sort=True) >>> graph.links_at_patch array([[3, 5, 2, 0], [4, 6, 3, 1]]) LLCATS: LINF """ return self.ds["links_at_patch"].values @property @lru_cache() @read_only_array def nodes_at_patch(self): """Get the nodes that define a patch. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = ([0, 1, 2, 0, 1, 2, 0, 1, 2], ... [0, 0, 0, 1, 1, 1, 2, 2, 2]) >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5), ... (3, 6), (4, 7), (5, 8), ... (6, 7), (7, 8)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches, sort=True) >>> graph.nodes_at_patch array([[4, 3, 0, 1], [5, 4, 1, 2]]) LLCATS: NINF """ nodes_at_patch = get_nodes_at_patch(self) sort_spokes_at_hub( nodes_at_patch, self.xy_of_patch, self.xy_of_node, inplace=True ) return nodes_at_patch @property @lru_cache() @read_only_array def patches_at_node(self): """Get the patches that touch each node. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = ([0, 1, 2, 0, 1, 2], ... [0, 0, 0, 1, 1, 1]) >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches, sort=True) >>> graph.patches_at_node # doctest: +NORMALIZE_WHITESPACE array([[ 0, -1], [ 1, 0], [ 1, -1], [ 0, -1], [ 0, 1], [ 1, -1]]) LLCATS: PINF """ patches_at_node = reverse_one_to_many(self.nodes_at_patch) sort_spokes_at_hub( patches_at_node, self.xy_of_node, self.xy_of_patch, inplace=True ) return patches_at_node @property @lru_cache() @read_only_array def patches_at_link(self): """Get the patches on either side of each link. Examples -------- >>> from landlab.graph import Graph >>> node_x, node_y = ([0, 1, 2, 0, 1, 2], ... [0, 0, 0, 1, 1, 1]) >>> links = ((0, 1), (1, 2), ... (0, 3), (1, 4), (2, 5), ... (3, 4), (4, 5)) >>> patches = ((0, 3, 5, 2), (1, 4, 6, 3)) >>> graph = Graph((node_y, node_x), links=links, patches=patches) >>> graph.patches_at_link # doctest: +NORMALIZE_WHITESPACE array([[ 0, -1], [ 1, -1], [ 0, -1], [ 0, 1], [ 1, -1], [ 0, -1], [ 1, -1]]) LLCATS: PINF """ return reverse_one_to_many(self.links_at_patch, min_counts=2)
amandersillinois/landlab
landlab/graph/graph.py
Python
mit
31,162
[ "NetCDF" ]
3a9cdbb0e5711644e0c1a3c8a36c2e6328b85b43d0cf5f138718808bc618c553
# Copyright 2009 Brian Quinlan. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. import collections import logging import threading import itertools import time __author__ = 'Brian Quinlan (brian@sweetapp.com)' FIRST_COMPLETED = 'FIRST_COMPLETED' FIRST_EXCEPTION = 'FIRST_EXCEPTION' ALL_COMPLETED = 'ALL_COMPLETED' _AS_COMPLETED = '_AS_COMPLETED' # Possible future states (for internal use by the futures package). PENDING = 'PENDING' RUNNING = 'RUNNING' # The future was cancelled by the user... CANCELLED = 'CANCELLED' # ...and _Waiter.add_cancelled() was called by a worker. CANCELLED_AND_NOTIFIED = 'CANCELLED_AND_NOTIFIED' FINISHED = 'FINISHED' _FUTURE_STATES = [ PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED ] _STATE_TO_DESCRIPTION_MAP = { PENDING: "pending", RUNNING: "running", CANCELLED: "cancelled", CANCELLED_AND_NOTIFIED: "cancelled", FINISHED: "finished" } # Logger for internal use by the futures package. LOGGER = logging.getLogger("concurrent.futures") class Error(Exception): """Base class for all future-related exceptions.""" pass class CancelledError(Error): """The Future was cancelled.""" pass class TimeoutError(Error): """The operation exceeded the given deadline.""" pass class _Waiter(object): """Provides the event that wait() and as_completed() block on.""" def __init__(self): self.event = threading.Event() self.finished_futures = [] def add_result(self, future): self.finished_futures.append(future) def add_exception(self, future): self.finished_futures.append(future) def add_cancelled(self, future): self.finished_futures.append(future) class _AsCompletedWaiter(_Waiter): """Used by as_completed().""" def __init__(self): super(_AsCompletedWaiter, self).__init__() self.lock = threading.Lock() def add_result(self, future): with self.lock: super(_AsCompletedWaiter, self).add_result(future) self.event.set() def add_exception(self, future): with self.lock: super(_AsCompletedWaiter, self).add_exception(future) self.event.set() def add_cancelled(self, future): with self.lock: super(_AsCompletedWaiter, self).add_cancelled(future) self.event.set() class _FirstCompletedWaiter(_Waiter): """Used by wait(return_when=FIRST_COMPLETED).""" def add_result(self, future): super(_FirstCompletedWaiter, self).add_result(future) self.event.set() def add_exception(self, future): super(_FirstCompletedWaiter, self).add_exception(future) self.event.set() def add_cancelled(self, future): super(_FirstCompletedWaiter, self).add_cancelled(future) self.event.set() class _AllCompletedWaiter(_Waiter): """Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).""" def __init__(self, num_pending_calls, stop_on_exception): self.num_pending_calls = num_pending_calls self.stop_on_exception = stop_on_exception self.lock = threading.Lock() super(_AllCompletedWaiter, self).__init__() def _decrement_pending_calls(self): with self.lock: self.num_pending_calls -= 1 if not self.num_pending_calls: self.event.set() def add_result(self, future): super(_AllCompletedWaiter, self).add_result(future) self._decrement_pending_calls() def add_exception(self, future): super(_AllCompletedWaiter, self).add_exception(future) if self.stop_on_exception: self.event.set() else: self._decrement_pending_calls() def add_cancelled(self, future): super(_AllCompletedWaiter, self).add_cancelled(future) self._decrement_pending_calls() class _AcquireFutures(object): """A context manager that does an ordered acquire of Future conditions.""" def __init__(self, futures): self.futures = sorted(futures, key=id) def __enter__(self): for future in self.futures: future._condition.acquire() def __exit__(self, *args): for future in self.futures: future._condition.release() def _create_and_install_waiters(fs, return_when): if return_when == _AS_COMPLETED: waiter = _AsCompletedWaiter() elif return_when == FIRST_COMPLETED: waiter = _FirstCompletedWaiter() else: pending_count = sum( f._state not in [CANCELLED_AND_NOTIFIED, FINISHED] for f in fs) if return_when == FIRST_EXCEPTION: waiter = _AllCompletedWaiter(pending_count, stop_on_exception=True) elif return_when == ALL_COMPLETED: waiter = _AllCompletedWaiter(pending_count, stop_on_exception=False) else: raise ValueError("Invalid return condition: %r" % return_when) for f in fs: f._waiters.append(waiter) return waiter def as_completed(fs, timeout=None): """An iterator over the given futures that yields each as it completes. Args: fs: The sequence of Futures (possibly created by different Executors) to iterate over. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. Returns: An iterator that yields the given Futures as they complete (finished or cancelled). If any given Futures are duplicated, they will be returned once. Raises: TimeoutError: If the entire result iterator could not be generated before the given timeout. """ if timeout is not None: end_time = timeout + time.time() fs = set(fs) with _AcquireFutures(fs): finished = set( f for f in fs if f._state in [CANCELLED_AND_NOTIFIED, FINISHED]) pending = fs - finished waiter = _create_and_install_waiters(fs, _AS_COMPLETED) try: for future in finished: yield future while pending: if timeout is None: wait_timeout = None else: wait_timeout = end_time - time.time() if wait_timeout < 0: raise TimeoutError( '%d (of %d) futures unfinished' % ( len(pending), len(fs))) waiter.event.wait(wait_timeout) with waiter.lock: finished = waiter.finished_futures waiter.finished_futures = [] waiter.event.clear() for future in finished: yield future pending.remove(future) finally: for f in fs: with f._condition: f._waiters.remove(waiter) DoneAndNotDoneFutures = collections.namedtuple( 'DoneAndNotDoneFutures', 'done not_done') def wait(fs, timeout=None, return_when=ALL_COMPLETED): """Wait for the futures in the given sequence to complete. Args: fs: The sequence of Futures (possibly created by different Executors) to wait upon. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. return_when: Indicates when this function should return. The options are: FIRST_COMPLETED - Return when any future finishes or is cancelled. FIRST_EXCEPTION - Return when any future finishes by raising an exception. If no future raises an exception then it is equivalent to ALL_COMPLETED. ALL_COMPLETED - Return when all futures finish or are cancelled. Returns: A named 2-tuple of sets. The first set, named 'done', contains the futures that completed (is finished or cancelled) before the wait completed. The second set, named 'not_done', contains uncompleted futures. """ with _AcquireFutures(fs): done = set(f for f in fs if f._state in [CANCELLED_AND_NOTIFIED, FINISHED]) not_done = set(fs) - done if (return_when == FIRST_COMPLETED) and done: return DoneAndNotDoneFutures(done, not_done) elif (return_when == FIRST_EXCEPTION) and done: if any(f for f in done if not f.cancelled() and f.exception() is not None): return DoneAndNotDoneFutures(done, not_done) if len(done) == len(fs): return DoneAndNotDoneFutures(done, not_done) waiter = _create_and_install_waiters(fs, return_when) waiter.event.wait(timeout) for f in fs: with f._condition: f._waiters.remove(waiter) done.update(waiter.finished_futures) return DoneAndNotDoneFutures(done, set(fs) - done) class Future(object): """Represents the result of an asynchronous computation.""" def __init__(self): """Initializes the future. Should not be called by clients.""" self._condition = threading.Condition() self._state = PENDING self._result = None self._exception = None self._traceback = None self._waiters = [] self._done_callbacks = [] def _invoke_callbacks(self): for callback in self._done_callbacks: try: callback(self) except Exception: LOGGER.exception('exception calling callback for %r', self) def __repr__(self): with self._condition: if self._state == FINISHED: if self._exception: return '<Future at %s state=%s raised %s>' % ( hex(id(self)), _STATE_TO_DESCRIPTION_MAP[self._state], self._exception.__class__.__name__) else: return '<Future at %s state=%s returned %s>' % ( hex(id(self)), _STATE_TO_DESCRIPTION_MAP[self._state], self._result.__class__.__name__) return '<Future at %s state=%s>' % ( hex(id(self)), _STATE_TO_DESCRIPTION_MAP[self._state]) def cancel(self): """Cancel the future if possible. Returns True if the future was cancelled, False otherwise. A future cannot be cancelled if it is running or has already completed. """ with self._condition: if self._state in [RUNNING, FINISHED]: return False if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: return True self._state = CANCELLED self._condition.notify_all() self._invoke_callbacks() return True def cancelled(self): """Return True if the future has cancelled.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED] def running(self): """Return True if the future is currently executing.""" with self._condition: return self._state == RUNNING def done(self): """Return True of the future was cancelled or finished executing.""" with self._condition: return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED] def __get_result(self): if self._exception: raise type(self._exception), self._exception, self._traceback else: return self._result def add_done_callback(self, fn): """Attaches a callable that will be called when the future finishes. Args: fn: A callable that will be called with this future as its only argument when the future completes or is cancelled. The callable will always be called by a thread in the same process in which it was added. If the future has already completed or been cancelled then the callable will be called immediately. These callables are called in the order that they were added. """ with self._condition: if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]: self._done_callbacks.append(fn) return fn(self) def result(self, timeout=None): """Return the result of the call that the future represents. Args: timeout: The number of seconds to wait for the result if the future isn't done. If None, then there is no limit on the wait time. Returns: The result of the call that the future represents. Raises: CancelledError: If the future was cancelled. TimeoutError: If the future didn't finish executing before the given timeout. Exception: If the call raised then that exception will be raised. """ with self._condition: if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: raise CancelledError() elif self._state == FINISHED: return self.__get_result() self._condition.wait(timeout) if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: raise CancelledError() elif self._state == FINISHED: return self.__get_result() else: raise TimeoutError() def exception_info(self, timeout=None): """Return a tuple of (exception, traceback) raised by the call that the future represents. Args: timeout: The number of seconds to wait for the exception if the future isn't done. If None, then there is no limit on the wait time. Returns: The exception raised by the call that the future represents or None if the call completed without raising. Raises: CancelledError: If the future was cancelled. TimeoutError: If the future didn't finish executing before the given timeout. """ with self._condition: if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: raise CancelledError() elif self._state == FINISHED: return self._exception, self._traceback self._condition.wait(timeout) if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: raise CancelledError() elif self._state == FINISHED: return self._exception, self._traceback else: raise TimeoutError() def exception(self, timeout=None): """Return the exception raised by the call that the future represents. Args: timeout: The number of seconds to wait for the exception if the future isn't done. If None, then there is no limit on the wait time. Returns: The exception raised by the call that the future represents or None if the call completed without raising. Raises: CancelledError: If the future was cancelled. TimeoutError: If the future didn't finish executing before the given timeout. """ return self.exception_info(timeout)[0] # The following methods should only be used by Executors and in tests. def set_running_or_notify_cancel(self): """Mark the future as running or process any cancel notifications. Should only be used by Executor implementations and unit tests. If the future has been cancelled (cancel() was called and returned True) then any threads waiting on the future completing (though calls to as_completed() or wait()) are notified and False is returned. If the future was not cancelled then it is put in the running state (future calls to running() will return True) and True is returned. This method should be called by Executor implementations before executing the work associated with this future. If this method returns False then the work should not be executed. Returns: False if the Future was cancelled, True otherwise. Raises: RuntimeError: if this method was already called or if set_result() or set_exception() was called. """ with self._condition: if self._state == CANCELLED: self._state = CANCELLED_AND_NOTIFIED for waiter in self._waiters: waiter.add_cancelled(self) # self._condition.notify_all() is not necessary because # self.cancel() triggers a notification. return False elif self._state == PENDING: self._state = RUNNING return True else: LOGGER.critical('Future %s in unexpected state: %s', id(self), self._state) raise RuntimeError('Future in unexpected state') def set_result(self, result): """Sets the return value of work associated with the future. Should only be used by Executor implementations and unit tests. """ with self._condition: self._result = result self._state = FINISHED for waiter in self._waiters: waiter.add_result(self) self._condition.notify_all() self._invoke_callbacks() def set_exception_info(self, exception, traceback): """Sets the result of the future as being the given exception and traceback. Should only be used by Executor implementations and unit tests. """ with self._condition: self._exception = exception self._traceback = traceback self._state = FINISHED for waiter in self._waiters: waiter.add_exception(self) self._condition.notify_all() self._invoke_callbacks() def set_exception(self, exception): """Sets the result of the future as being the given exception. Should only be used by Executor implementations and unit tests. """ self.set_exception_info(exception, None) class Executor(object): """This is an abstract base class for concrete asynchronous executors.""" def submit(self, fn, *args, **kwargs): """Submits a callable to be executed with the given arguments. Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable. Returns: A Future representing the given call. """ raise NotImplementedError() def map(self, fn, *iterables, **kwargs): """Returns a iterator equivalent to map(fn, iter). Args: fn: A callable that will take as many arguments as there are passed iterables. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. Returns: An iterator equivalent to: map(func, *iterables) but the calls may be evaluated out-of-order. Raises: TimeoutError: If the entire result iterator could not be generated before the given timeout. Exception: If fn(*args) raises for any values. """ timeout = kwargs.get('timeout') if timeout is not None: end_time = timeout + time.time() fs = [self.submit(fn, *args) for args in itertools.izip(*iterables)] # Yield must be hidden in closure so that the futures are submitted # before the first iterator value is required. def result_iterator(): try: for future in fs: if timeout is None: yield future.result() else: yield future.result(end_time - time.time()) finally: for future in fs: future.cancel() return result_iterator() def shutdown(self, wait=True): """Clean-up the resources associated with the Executor. It is safe to call this method several times. Otherwise, no other methods can be called after this one. Args: wait: If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed. """ pass def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.shutdown(wait=True) return False
maxrothman/aws-alfred-workflow
venv/lib/python2.7/site-packages/concurrent/futures/_base.py
Python
mit
21,072
[ "Brian" ]
6a5bed9fe1f805879b4b507d4625f6d2a8bfa5fa74235679c231aaf9807eaf19
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <codecell> import iris # <codecell> # calculate the current speed using a EPIC NetCDF file url = 'http://geoport.whoi.edu/thredds/dodsC/usgs/data2/emontgomery/stellwagen/CF-1.6/RCNWR/9541aqd-cal.nc' # <codecell> u = iris.load_cube(url,'eastward_sea_water_velocity') v = iris.load_cube(url,'northward_sea_water_velocity') # <codecell> print u # <codecell> u.name() # <codecell> def calc_speed(u, v): """Calculate the speed""" speed = (u**2 + v**2)**0.5 return speed # <codecell> spData = calc_speed(u,v) # <codecell> print spData # <codecell> import matplotlib.pyplot as plt %matplotlib inline # <codecell> u.shape # <codecell> u[3000,0].data # <codecell> v[3000,0].data # <codecell> spData[3000,0].data # <codecell> spData.rename('sea_water_speed') # <codecell> spData # <codecell> spData.attributes = u.attributes # <codecell> spData # <codecell> print spData # <codecell>
rsignell-usgs/notebook
calc_speed.py
Python
mit
980
[ "NetCDF" ]
7daa7eb1e4145ecd892ea37f8f763ad69d487f497055fc60ef6a287db214936b
import variants_pb2 import sys import os import pysam from pysam import VariantFile from pymongo import MongoClient import json import google.protobuf.json_format as json_format import time import progressbar import uuid import google.protobuf.struct_pb2 as struct_pb2 import argparse parser = argparse.ArgumentParser() #parser.add_argument("-d","--directory", help="Directory to use") parser.add_argument("-i", "--input", help="Input file") parser.add_argument("-db", "--database", help="Database output") parser.add_argument("-ch", "--chromosome", help="Chromosome choice") parser.add_argument("-pb", "--protobuf", help="Protobuf out") p = parser.parse_args() assert p.input widgets = [progressbar.Timer()] pBar = progressbar.ProgressBar(widgets=widgets, max_value=100) vcfFile = pysam.VariantFile(p.input) hdr = vcfFile.header sampleNames = list(hdr.samples) vsID = str(uuid.uuid4()) #checking if chromosome was specified if p.chromosome is not None: chrom = p.chromosome else: chrom = None def main(): if p.database is not None: global db db = get_db(p.database) global variantset variantset = db.VariantSet global variantd variantd = db.Variants global calls calls = db.Calls global callset callset = db.CallSets #if the directory does not already exist then create it if not os.path.exists("output2/variantSet/variants/calls/callsets"): os.makedirs("output2/variantSet/variants/calls/callsets") variantSet(hdr) #count used to update the progressbar count = 0 pBar.start() for variant in vcfFile.fetch(chrom): count += 1 vMes(variant) if count % 100 == 0: pBar.update() pBar.finish() def get_db(pdatabase): client = MongoClient() db = client[pdatabase] return db """def test_connection(client): if client.alive() //alive func no longer exists == False: return "no mongodb connection" else: return""" #this function taken from ga4gh/datamodel/variants.py. def _encodeValue(value): if isinstance(value, (list, tuple)): return [struct_pb2.Value(string_value=str(v)) for v in value] else: return [struct_pb2.Value(string_value=str(value))] def vsMetadata(key, type1, number, description): gaVariant_metaData = variants_pb2.VariantSetMetadata() gaVariant_metaData.key = key #gaVariant_metaData.value = value //same as key gaVariant_metaData.type = type1 gaVariant_metaData.number = str(number) gaVariant_metaData.description = description return gaVariant_metaData #Contains VCF Header information and calls the vsMetadata function. def vHeader(hdr): formats = hdr.formats.items() infos = hdr.info.items() meta = [] for prefix, content in [("Format", formats), ("Info", infos)]: for key, value in content: meta.append(vsMetadata(key,value.type,value.number,value.description)) return meta #Creates GA4GH Variant Set message. #Also contains the files metadata by calling vHeader function. def variantSet(hdr): ranId = uuid.uuid4() gaVariantVS = variants_pb2.VariantSet() #gaVariantVS.reference_set_id = pysam has .rid but all files show as 0 for value gaVariantVS.id = str(vsID) gaVariantVS.name = str(hdr.contigs) gaVariantVS.dataset_id = str(ranId) gaVariantVS.metadata.extend(vHeader(hdr)) if p.protobuf is None: vSet_FileName = vsID + '.txt' else: vSet_FileName = vsID + '.pb' fout1 = open(os.path.join("output2/variantSet", vSet_FileName), 'w') if p.protobuf is None: fout1.write (json.dumps(json_format._MessageToJsonObject(gaVariantVS, True))) else: fout1.write (gaVariantVS.SerializeToString()) fout1.close() if "db" in globals(): variantset.insert_one(json_format._MessageToJsonObject(gaVariantVS, True)) #Creates a GA4GH Call Set Message def callSet(sampleNames, callSetId): gaVariantCS = variants_pb2.CallSet() gaVariantCS.name = str(sampleNames) #gaVariantCS.bio_sample_id = //Leave blank gaVariantCS.variant_set_ids.append(str(vsID)) gaVariantCS.created = int(time.time()) gaVariantCS.updated = int(time.time()) #gaVariantCS.info = //Not currently utilized cs_FileName = callSetId if p.protobuf is None: cs_txt_FileName = cs_FileName + '.txt' else: cs_txt_FileName = cs_FileName + '.pb' if not os.path.isfile(cs_txt_FileName): fout4 = open(os.path.join("output2/variantSet/variants/calls/callsets", cs_txt_FileName), 'w') if p.protobuf is None: fout4.write (json.dumps(json_format._MessageToJsonObject(gaVariantCS, True))) else: fout4.write (gaVariantCS.SerializeToString()) fout4.close() if "db" in globals(): callset.insert_one(json_format._MessageToJsonObject(gaVariantCS, True)) return #Creates a GA4GH Call message. #Calls the CallSet function, sends it sampleNames and the call set ID. def callMes(call_record, sample_name, variant_id): gaVariantC = variants_pb2.Call() call_set_id = uuid.uuid4() gaVariantC.call_set_name = sample_name gaVariantC.call_set_id = str(call_set_id) try: if call_record.allele_indices is not None: gaVariantC.genotype.extend(list(call_record.allele_indices)) except: pass if call_record.phased: phaseset = str(call_record.phased) gaVariantC.phaseset = str(phaseset) for key, value in call_record.iteritems(): if key == 'GL' and value is not None: gtlikelihood = value gaVariantC.genotype_likelihood.extend(list(gtlikelihood)) #GTLikelihood is not always in a VCF File gaVariantC.info["variant_id"].append(str(variant_id)) c_FileName = gaVariantC.call_set_id if p.protobuf is None: c_txt_FileName = c_FileName + '.txt' else: c_txt_FileName = c_FileName + '.pb' if not os.path.isfile(c_txt_FileName): fout3 = open(os.path.join("output2/variantSet/variants/calls", c_txt_FileName), 'w') if p.protobuf is None: fout3.write (json.dumps(json_format._MessageToJsonObject(gaVariantC, True))) else: fout3.write (gaVariantC.SerializeToString()) fout3.close() if "db" in globals(): calls.insert_one(json_format._MessageToJsonObject(gaVariantC, True)) callSet(sampleNames, gaVariantC.call_set_id) return gaVariantC #Creates a GA4GH variant message. #Calls the Call Message function also. def vMes(variant): ranId = uuid.uuid4() gaVariant = variants_pb2.Variant() gaVariant.variant_set_id = str(vsID) variant_id = ranId gaVariant.id = str(variant_id) gaVariant.reference_name = variant.contig gaVariant.created = int(time.time()) gaVariant.updated = int(time.time()) gaVariant.start = variant.start gaVariant.end = variant.stop gaVariant.reference_bases = variant.ref if variant.alts is not None: gaVariant.alternate_bases.extend(list(variant.alts)) for key, value in variant.info.iteritems(): if value is not None: gaVariant.info[key].values.extend(_encodeValue(value)) if variant.id is not None: gaVariant.names.append(variant.id) else: variant.id = None for sample_name in sampleNames: call_record = variant.samples[sample_name] gaVariant.calls.extend([callMes(call_record,sample_name,variant_id)]) if p.protobuf is None: v_FileName = gaVariant.id + '.txt' else: v_FileName = gaVariant.id + '.pb' if not os.path.isfile(v_FileName): fout2 = open(os.path.join("output2/variantSet/variants", v_FileName), 'w') if "db" in globals(): variantd.insert_one(json_format._MessageToJsonObject(gaVariant, True)) if p.protobuf is None: fout2.write (json.dumps(json_format._MessageToJsonObject(gaVariant, True))) fout2.close() else: fout2.write (gaVariant.SerializeToString()) fout2.close() return main()
Arc39/vcf_to_ga
scr.py
Python
apache-2.0
8,074
[ "pysam" ]
12557a233700fc4c0746cf4ff364f3c7b69d115d666369917edeb8707800afbd
from __future__ import absolute_import input_name = '../examples/diffusion/laplace_coupling_lcbcs.py' output_name = 'test_laplace_coupling_lcbcs.vtk' from tests_basic import TestInput class Test(TestInput): pass
vlukes/sfepy
tests/test_input_laplace_coupling_lcbcs.py
Python
bsd-3-clause
217
[ "VTK" ]
29a63a47a27f895a3fa37e711c4a1f5864e2d104b1bb315e838c8da7b85af29b
# -*- coding: utf-8 -*- """ Created on Fri Dec 16 19:04:22 2016 @author: tih """ import pandas as pd import glob import gdal import osr import os import numpy as np import subprocess from pyproj import Proj, transform import scipy.interpolate def Run_command_window(argument): """ This function runs the argument in the command window without showing cmd window Keyword Arguments: argument -- string, name of the adf file """ if os.name == 'posix': argument = argument.replace(".exe","") os.system(argument) else: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW process = subprocess.Popen(argument, startupinfo=startupinfo, stderr=subprocess.PIPE, stdout=subprocess.PIPE) process.wait() return() def Open_array_info(filename=''): """ Opening a tiff info, for example size of array, projection and transform matrix. Keyword Arguments: filename -- 'C:/file/to/path/file.tif' or a gdal file (gdal.Open(filename)) string that defines the input tiff file or gdal file """ f = gdal.Open(r"%s" %filename) if f is None: print '%s does not exists' %filename else: geo_out = f.GetGeoTransform() proj = f.GetProjection() size_X = f.RasterXSize size_Y = f.RasterYSize f = None return(geo_out, proj, size_X, size_Y) def Open_tiff_array(filename='', band=''): """ Opening a tiff array. Keyword Arguments: filename -- 'C:/file/to/path/file.tif' or a gdal file (gdal.Open(filename)) string that defines the input tiff file or gdal file band -- integer Defines the band of the tiff that must be opened. """ f = gdal.Open(filename) if f is None: print '%s does not exists' %filename else: if band is '': band = 1 Data = f.GetRasterBand(band).ReadAsArray() return(Data) def Open_nc_info(NC_filename, Var = None): """ Opening a nc info, for example size of array, time (ordinal), projection and transform matrix. Keyword Arguments: filename -- 'C:/file/to/path/file.nc' string that defines the input nc file """ from netCDF4 import Dataset fh = Dataset(NC_filename, mode='r') if Var is None: Var = fh.variables.keys()[-1] data = fh.variables[Var][:] size_Y, size_X = np.int_(data.shape[-2:]) if len(data.shape) == 3: size_Z = np.int_(data.shape[0]) Time = fh.variables['time'][:] else: size_Z = 1 Time = -9999 lats = fh.variables['latitude'][:] lons = fh.variables['longitude'][:] Geo6 = fh.variables['latitude'].pixel_size Geo2 = fh.variables['longitude'].pixel_size Geo4 = np.max(lats) + Geo6/2 Geo1 = np.min(lons) - Geo2/2 crso = fh.variables['crs'] proj = crso.projection epsg = Get_epsg(proj, extension = 'GEOGCS') geo_out = tuple([Geo1, Geo2, 0, Geo4, 0, Geo6]) fh.close() return(geo_out, epsg, size_X, size_Y, size_Z, Time) def Open_nc_array(NC_filename, Var = None, Startdate = '', Enddate = ''): """ Opening a nc array. Keyword Arguments: filename -- 'C:/file/to/path/file.nc' string that defines the input nc file Var -- string Defines the band name that must be opened. Startdate -- "yyyy-mm-dd" Defines the startdate (default is from beginning of array) Enddate -- "yyyy-mm-dd" Defines the enddate (default is from end of array) """ from netCDF4 import Dataset fh = Dataset(NC_filename, mode='r') if Var == None: Var = fh.variables.keys()[-1] if Startdate is not '': Time = fh.variables['time'][:] Array_check_start = np.ones(np.shape(Time)) Date = pd.Timestamp(Startdate) Startdate_ord = Date.toordinal() Array_check_start[Time >= Startdate_ord] = 0 Start = np.sum(Array_check_start) else: Start = 0 if Enddate is not '': Time = fh.variables['time'][:] Array_check_end = np.zeros(np.shape(Time)) Date = pd.Timestamp(Enddate) Enddate_ord = Date.toordinal() Array_check_end[Enddate_ord >= Time] = 1 End = np.sum(Array_check_end) else: try: Time = fh.variables['time'][:] End = len(Time) except: End = '' if (Enddate is not '' or Startdate is not ''): Data = fh.variables[Var][int(Start):int(End), :, :] else: Data = fh.variables[Var][:] fh.close() Data = np.array(Data) try: Data[Data==-9999] = np.nan except: pass return(Data) def Open_ncs_array(NC_Directory, Var, Startdate, Enddate): """ Opening a nc array. Keyword Arguments: NC_Directory -- 'C:/file/to/path' string that defines the path to all the simulation nc files Var -- string Defines the band name that must be opened. Startdate -- "yyyy-mm-dd" Defines the startdate Enddate -- "yyyy-mm-dd" Defines the enddate """ panda_start = pd.Timestamp(Startdate) panda_end = pd.Timestamp(Enddate) years = range(int(panda_start.year), int(panda_end.year)+1) Data_end = [] for year in years: NC_filename = os.path.join(NC_Directory, "%d.nc" %year) if year == years[0]: Startdate_now = Startdate else: Startdate_now = "%d-01-01" %int(year) if year == years[-1]: Enddate_now = Enddate else: Enddate_now = "%d-12-31" %int(year) Data_now = Open_nc_array(NC_filename, Var, Startdate_now, Enddate_now) if year == years[0]: Data_end = Data_now else: Data_end = np.vstack([Data_end,Data_now]) Data_end = np.array(Data_end) return(Data_end) def Open_nc_dict(input_netcdf, group_name, startdate = '', enddate = ''): """ Opening a nc dictionary. Keyword Arguments: filename -- 'C:/file/to/path/file.nc' string that defines the input nc file group_name -- string Defines the group name that must be opened. Startdate -- "yyyy-mm-dd" Defines the startdate (default is from beginning of array) Enddate -- "yyyy-mm-dd" Defines the enddate (default is from end of array) """ from netCDF4 import Dataset import re # sort out if the dataset is static or dynamic (written in group_name) kind_of_data = group_name.split('_')[-1] # if it is dynamic also collect the time parameter if kind_of_data == 'dynamic': time_dates = Open_nc_array(input_netcdf, Var = 'time') Amount_months = len(time_dates) # Open the input netcdf and the wanted group name in_nc = Dataset(input_netcdf) data = in_nc.groups[group_name] # Convert the string into a string that can be retransformed into a dictionary string_dict = str(data) split_dict = str(string_dict.split('\n')[2:-4]) split_dict = split_dict.replace("'","") split_dict = split_dict[1:-1] dictionary = dict() split_dict_split = re.split(':|, ',split_dict) # Loop over every attribute and add the array for i in range(0,len(split_dict_split)): number_val = split_dict_split[i] if i % 2 == 0: Array_text = split_dict_split[i + 1].replace(",","") Array_text = Array_text.replace("[","") Array_text = Array_text.replace("]","") # If the array is dynamic add a 2D array if kind_of_data == 'dynamic': tot_length = len(np.fromstring(Array_text,sep = ' ')) dictionary[int(number_val)] = np.fromstring(Array_text,sep = ' ').reshape((Amount_months, tot_length/Amount_months)) # If the array is static add a 1D array else: dictionary[int(number_val)] = np.fromstring(Array_text,sep = ' ') # Clip the dynamic dataset if a start and enddate is defined if kind_of_data == 'dynamic': if startdate is not '': Array_check_start = np.ones(np.shape(time_dates)) Date = pd.Timestamp(startdate) Startdate_ord = Date.toordinal() Array_check_start[time_dates >= Startdate_ord] = 0 Start = np.sum(Array_check_start) else: Start = 0 if enddate is not '': Array_check_end = np.zeros(np.shape(time_dates)) Date = pd.Timestamp(enddate) Enddate_ord = Date.toordinal() Array_check_end[Enddate_ord >= time_dates] = 1 End = np.sum(Array_check_end) else: try: time_dates = in_nc.variables['time'][:] End = len(time_dates) except: End = '' if Start != 0 or (End != len(time_dates) or ''): if End == '': End = len(time_dates) for key in dictionary.iterkeys(): Array = dictionary[key][:,:] Array_new = Array[int(Start):int(End),:] dictionary[key] = Array_new in_nc.close() return(dictionary) def Clip_Dataset_GDAL(input_name, output_name, latlim, lonlim): """ Clip the data to the defined extend of the user (latlim, lonlim) by using the gdal_translate executable of gdal. Keyword Arguments: input_name -- input data, input directory and filename of the tiff file output_name -- output data, output filename of the clipped file latlim -- [ymin, ymax] lonlim -- [xmin, xmax] """ # Get environmental variable WA_env_paths = os.environ["WA_PATHS"].split(';') GDAL_env_path = WA_env_paths[0] GDALTRANSLATE_PATH = os.path.join(GDAL_env_path, 'gdal_translate.exe') # find path to the executable fullCmd = ' '.join(["%s" %(GDALTRANSLATE_PATH), '-projwin %s %s %s %s -of GTiff %s %s' %(lonlim[0], latlim[1], lonlim[1], latlim[0], input_name, output_name)]) Run_command_window(fullCmd) return() def clip_data(input_file, latlim, lonlim): """ Clip the data to the defined extend of the user (latlim, lonlim) or to the extend of the DEM tile Keyword Arguments: input_file -- output data, output of the clipped dataset latlim -- [ymin, ymax] lonlim -- [xmin, xmax] """ try: if input_file.split('.')[-1] == 'tif': dest_in = gdal.Open(input_file) else: dest_in = input_file except: dest_in = input_file # Open Array data_in = dest_in.GetRasterBand(1).ReadAsArray() # Define the array that must remain Geo_in = dest_in.GetGeoTransform() Geo_in = list(Geo_in) Start_x = np.max([int(np.ceil(((lonlim[0]) - Geo_in[0])/ Geo_in[1])),0]) End_x = np.min([int(np.floor(((lonlim[1]) - Geo_in[0])/ Geo_in[1])),int(dest_in.RasterXSize)]) Start_y = np.max([int(np.floor((Geo_in[3] - latlim[1])/ -Geo_in[5])),0]) End_y = np.min([int(np.ceil(((latlim[0]) - Geo_in[3])/Geo_in[5])), int(dest_in.RasterYSize)]) #Create new GeoTransform Geo_in[0] = Geo_in[0] + Start_x * Geo_in[1] Geo_in[3] = Geo_in[3] + Start_y * Geo_in[5] Geo_out = tuple(Geo_in) data = np.zeros([End_y - Start_y, End_x - Start_x]) data = data_in[Start_y:End_y,Start_x:End_x] dest_in = None return(data, Geo_out) def reproject_dataset_epsg(dataset, pixel_spacing, epsg_to, method = 2): """ A sample function to reproject and resample a GDAL dataset from within Python. The idea here is to reproject from one system to another, as well as to change the pixel size. The procedure is slightly long-winded, but goes like this: 1. Set up the two Spatial Reference systems. 2. Open the original dataset, and get the geotransform 3. Calculate bounds of new geotransform by projecting the UL corners 4. Calculate the number of pixels with the new projection & spacing 5. Create an in-memory raster dataset 6. Perform the projection Keywords arguments: dataset -- 'C:/file/to/path/file.tif' string that defines the input tiff file pixel_spacing -- float Defines the pixel size of the output file epsg_to -- integer The EPSG code of the output dataset method -- 1,2,3,4 default = 2 1 = Nearest Neighbour, 2 = Bilinear, 3 = lanzcos, 4 = average """ # 1) Open the dataset g = gdal.Open(dataset) if g is None: print 'input folder does not exist' # Get EPSG code epsg_from = Get_epsg(g) # Get the Geotransform vector: geo_t = g.GetGeoTransform() # Vector components: # 0- The Upper Left easting coordinate (i.e., horizontal) # 1- The E-W pixel spacing # 2- The rotation (0 degrees if image is "North Up") # 3- The Upper left northing coordinate (i.e., vertical) # 4- The rotation (0 degrees) # 5- The N-S pixel spacing, negative as it is counted from the UL corner x_size = g.RasterXSize # Raster xsize y_size = g.RasterYSize # Raster ysize epsg_to = int(epsg_to) # 2) Define the UK OSNG, see <http://spatialreference.org/ref/epsg/27700/> osng = osr.SpatialReference() osng.ImportFromEPSG(epsg_to) wgs84 = osr.SpatialReference() wgs84.ImportFromEPSG(epsg_from) inProj = Proj(init='epsg:%d' %epsg_from) outProj = Proj(init='epsg:%d' %epsg_to) # Up to here, all the projection have been defined, as well as a # transformation from the from to the to ulx, uly = transform(inProj,outProj,geo_t[0], geo_t[3]) lrx, lry = transform(inProj,outProj,geo_t[0] + geo_t[1] * x_size, geo_t[3] + geo_t[5] * y_size) # See how using 27700 and WGS84 introduces a z-value! # Now, we create an in-memory raster mem_drv = gdal.GetDriverByName('MEM') # The size of the raster is given the new projection and pixel spacing # Using the values we calculated above. Also, setting it to store one band # and to use Float32 data type. col = int((lrx - ulx)/pixel_spacing) rows = int((uly - lry)/pixel_spacing) # Re-define lr coordinates based on whole number or rows and columns (lrx, lry) = (ulx + col * pixel_spacing, uly - rows * pixel_spacing) dest = mem_drv.Create('', col, rows, 1, gdal.GDT_Float32) if dest is None: print 'input folder to large for memory, clip input map' # Calculate the new geotransform new_geo = (ulx, pixel_spacing, geo_t[2], uly, geo_t[4], - pixel_spacing) # Set the geotransform dest.SetGeoTransform(new_geo) dest.SetProjection(osng.ExportToWkt()) # Perform the projection/resampling if method is 1: gdal.ReprojectImage(g, dest, wgs84.ExportToWkt(), osng.ExportToWkt(),gdal.GRA_NearestNeighbour) if method is 2: gdal.ReprojectImage(g, dest, wgs84.ExportToWkt(), osng.ExportToWkt(),gdal.GRA_Bilinear) if method is 3: gdal.ReprojectImage(g, dest, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_Lanczos) if method is 4: gdal.ReprojectImage(g, dest, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_Average) return dest, ulx, lry, lrx, uly, epsg_to def reproject_MODIS(input_name, epsg_to): ''' Reproject the merged data file by using gdalwarp. The input projection must be the MODIS projection. The output projection can be defined by the user. Keywords arguments: input_name -- 'C:/file/to/path/file.tif' string that defines the input tiff file epsg_to -- integer The EPSG code of the output dataset ''' # Define the output name name_out = ''.join(input_name.split(".")[:-1]) + '_reprojected.tif' # Get environmental variable WA_env_paths = os.environ["WA_PATHS"].split(';') GDAL_env_path = WA_env_paths[0] GDALWARP_PATH = os.path.join(GDAL_env_path, 'gdalwarp.exe') # find path to the executable fullCmd = ' '.join(["%s" %(GDALWARP_PATH), '-overwrite -s_srs "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"', '-t_srs EPSG:%s -of GTiff' %(epsg_to), input_name, name_out]) Run_command_window(fullCmd) return(name_out) def reproject_dataset_example(dataset, dataset_example, method=1): """ A sample function to reproject and resample a GDAL dataset from within Python. The user can define the wanted projection and shape by defining an example dataset. Keywords arguments: dataset -- 'C:/file/to/path/file.tif' or a gdal file (gdal.Open(filename)) string that defines the input tiff file or gdal file dataset_example -- 'C:/file/to/path/file.tif' or a gdal file (gdal.Open(filename)) string that defines the input tiff file or gdal file method -- 1,2,3,4 default = 1 1 = Nearest Neighbour, 2 = Bilinear, 3 = lanzcos, 4 = average """ # open dataset that must be transformed try: if os.path.splitext(dataset)[-1] == '.tif': g = gdal.Open(dataset) else: g = dataset except: g = dataset epsg_from = Get_epsg(g) #exceptions if epsg_from == 9001: epsg_from = 5070 # open dataset that is used for transforming the dataset try: if os.path.splitext(dataset_example)[-1] == '.tif': gland = gdal.Open(dataset_example) epsg_to = Get_epsg(gland) elif os.path.splitext(dataset_example)[-1] == '.nc': import wa.General.data_conversions as DC geo_out, epsg_to, size_X, size_Y, size_Z, Time = Open_nc_info(dataset_example) data = np.zeros([size_Y, size_X]) gland = DC.Save_as_MEM(data, geo_out, str(epsg_to)) else: gland = dataset_example epsg_to = Get_epsg(gland) except: gland = dataset_example epsg_to = Get_epsg(gland) # Set the EPSG codes osng = osr.SpatialReference() osng.ImportFromEPSG(epsg_to) wgs84 = osr.SpatialReference() wgs84.ImportFromEPSG(epsg_from) # Get shape and geo transform from example geo_land = gland.GetGeoTransform() col=gland.RasterXSize rows=gland.RasterYSize # Create new raster mem_drv = gdal.GetDriverByName('MEM') dest1 = mem_drv.Create('', col, rows, 1, gdal.GDT_Float32) dest1.SetGeoTransform(geo_land) dest1.SetProjection(osng.ExportToWkt()) # Perform the projection/resampling if method is 1: gdal.ReprojectImage(g, dest1, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_NearestNeighbour) if method is 2: gdal.ReprojectImage(g, dest1, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_Bilinear) if method is 3: gdal.ReprojectImage(g, dest1, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_Lanczos) if method is 4: gdal.ReprojectImage(g, dest1, wgs84.ExportToWkt(), osng.ExportToWkt(), gdal.GRA_Average) return(dest1) def resize_array_example(Array_in, Array_example, method=1): """ This function resizes an array so it has the same size as an example array The extend of the array must be the same Keyword arguments: Array_in -- [] Array: 2D or 3D array Array_example -- [] Array: 2D or 3D array method: -- 1 ... 5 int: Resampling method """ # Create old raster Array_out_shape = np.int_(Array_in.shape) Array_out_shape[-1] = Array_example.shape[-1] Array_out_shape[-2] = Array_example.shape[-2] if method == 1: interpolation_method='nearest' if method == 2: interpolation_method='bicubic' if method == 3: interpolation_method='bilinear' if method == 4: interpolation_method='cubic' if method == 5: interpolation_method='lanczos' if len(Array_out_shape) == 3: Array_out = np.zeros(Array_out_shape) for i in range(0, Array_out_shape[0]): Array_in_slice = Array_in[i,:,:] size=tuple(Array_out_shape[1:]) Array_out_slice=scipy.misc.imresize(np.float_(Array_in_slice), size, interp=interpolation_method, mode='F') Array_out[i,:,:] = Array_out_slice elif len(Array_out_shape) == 2: size=tuple(Array_out_shape) Array_out=scipy.misc.imresize(np.float_(Array_in), size, interp=interpolation_method, mode='F') else: print('only 2D or 3D dimensions are supported') return(Array_out) def Get_epsg(g, extension = 'tiff'): """ This function reads the projection of a GEOGCS file or tiff file Keyword arguments: g -- string Filename to the file that must be read extension -- tiff or GEOGCS Define the extension of the dataset (default is tiff) """ try: if extension == 'tiff': # Get info of the dataset that is used for transforming g_proj = g.GetProjection() Projection=g_proj.split('EPSG","') if extension == 'GEOGCS': Projection = g epsg_to=int((str(Projection[-1]).split(']')[0])[0:-1]) except: epsg_to=4326 #print 'Was not able to get the projection, so WGS84 is assumed' return(epsg_to) def gap_filling(dataset,NoDataValue, method = 1): """ This function fills the no data gaps in a numpy array Keyword arguments: dataset -- 'C:/' path to the source data (dataset that must be filled) NoDataValue -- Value that must be filled """ import wa.General.data_conversions as DC try: if dataset.split('.')[-1] == 'tif': # Open the numpy array data = Open_tiff_array(dataset) Save_as_tiff = 1 else: data = dataset Save_as_tiff = 0 except: data = dataset Save_as_tiff = 0 # fill the no data values if NoDataValue is np.nan: mask = ~(np.isnan(data)) else: mask = ~(data==NoDataValue) xx, yy = np.meshgrid(np.arange(data.shape[1]), np.arange(data.shape[0])) xym = np.vstack( (np.ravel(xx[mask]), np.ravel(yy[mask])) ).T data0 = np.ravel( data[:,:][mask] ) if method == 1: interp0 = scipy.interpolate.NearestNDInterpolator( xym, data0 ) data_end = interp0(np.ravel(xx), np.ravel(yy)).reshape( xx.shape ) if method == 2: interp0 = scipy.interpolate.LinearNDInterpolator( xym, data0 ) data_end = interp0(np.ravel(xx), np.ravel(yy)).reshape( xx.shape ) if Save_as_tiff == 1: EndProduct=dataset[:-4] + '_GF.tif' # collect the geoinformation geo_out, proj, size_X, size_Y = Open_array_info(dataset) # Save the filled array as geotiff DC.Save_as_tiff(name=EndProduct, data=data_end, geo=geo_out, projection=proj) else: EndProduct = data_end return (EndProduct) def Get3Darray_time_series_monthly(Data_Path, Startdate, Enddate, Example_data = None): """ This function creates a datacube Keyword arguments: Data_Path -- 'product/monthly' str: Path to the dataset Startdate -- 'YYYY-mm-dd' str: startdate of the 3D array Enddate -- 'YYYY-mm-dd' str: enddate of the 3D array Example_data: -- 'C:/....../.tif' str: Path to an example tiff file (all arrays will be reprojected to this example) """ # Get a list of dates that needs to be reprojected Dates = pd.date_range(Startdate, Enddate, freq = 'MS') # Change Working directory os.chdir(Data_Path) i = 0 # Loop over the months for Date in Dates: # Create the end monthly file name End_tiff_file_name = 'monthly_%d.%02d.01.tif' %(Date.year, Date.month) # Search for this file in directory file_name = glob.glob('*%s' %End_tiff_file_name) # Select the first file that is found file_name_path = os.path.join(Data_Path, file_name[0]) # Check if an example file is selected if Example_data is not None: # If it is the first day set the example gland file if Date == Dates[0]: # Check the format to read general info # if Tiff if os.path.splitext(Example_data)[-1] == '.tif': geo_out, proj, size_X, size_Y = Open_array_info(Example_data) dataTot=np.zeros([len(Dates),size_Y,size_X]) # if netCDF if os.path.splitext(Example_data)[-1] == '.nc': geo_out, projection, size_X, size_Y, size_Z, Time = Open_nc_info(Example_data) dataTot=np.zeros([len(Dates),size_Y,size_X]) # Create memory file for reprojection data = Open_nc_array(Example_data, "Landuse") driver = gdal.GetDriverByName("MEM") gland = driver.Create('', size_X, size_Y, 1, gdal.GDT_Float32, ['COMPRESS=LZW']) srse = osr.SpatialReference() if projection == '' or projection == 4326: srse.SetWellKnownGeogCS("WGS84") else: srse.SetWellKnownGeogCS(projection) gland.SetProjection(srse.ExportToWkt()) gland.GetRasterBand(1).SetNoDataValue(-9999) gland.SetGeoTransform(geo_out) gland.GetRasterBand(1).WriteArray(data) # use the input parameter as it is already an example file else: gland = Example_data # reproject dataset dest = reproject_dataset_example(file_name_path, gland, method = 4) Array_one_date = dest.GetRasterBand(1).ReadAsArray() # if there is no example dataset defined else: # Get the properties from the first file if Date is Dates[0]: geo_out, proj, size_X, size_Y = Open_array_info(file_name_path) dataTot=np.zeros([len(Dates),size_Y,size_X]) Array_one_date = Open_tiff_array(file_name_path) # Create the 3D array dataTot[i,:,:] = Array_one_date i += 1 return(dataTot) def Vector_to_Raster(Dir, shapefile_name, reference_raster_data_name): """ This function creates a raster of a shp file Keyword arguments: Dir -- str: path to the basin folder shapefile_name -- 'C:/....../.shp' str: Path from the shape file reference_raster_data_name -- 'C:/....../.tif' str: Path to an example tiff file (all arrays will be reprojected to this example) """ from osgeo import gdal, ogr geo, proj, size_X, size_Y=Open_array_info(reference_raster_data_name) x_min = geo[0] x_max = geo[0] + size_X * geo[1] y_min = geo[3] + size_Y * geo[5] y_max = geo[3] pixel_size = geo[1] # Filename of the raster Tiff that will be created Dir_Basin_Shape = os.path.join(Dir,'Basin') if not os.path.exists(Dir_Basin_Shape): os.mkdir(Dir_Basin_Shape) Basename = os.path.basename(shapefile_name) Dir_Raster_end = os.path.join(Dir_Basin_Shape, os.path.splitext(Basename)[0]+'.tif') # Open the data source and read in the extent source_ds = ogr.Open(shapefile_name) source_layer = source_ds.GetLayer() # Create the destination data source x_res = int(round((x_max - x_min) / pixel_size)) y_res = int(round((y_max - y_min) / pixel_size)) # Create tiff file target_ds = gdal.GetDriverByName('GTiff').Create(Dir_Raster_end, x_res, y_res, 1, gdal.GDT_Float32, ['COMPRESS=LZW']) target_ds.SetGeoTransform(geo) srse = osr.SpatialReference() srse.SetWellKnownGeogCS(proj) target_ds.SetProjection(srse.ExportToWkt()) band = target_ds.GetRasterBand(1) target_ds.GetRasterBand(1).SetNoDataValue(-9999) band.Fill(-9999) # Rasterize the shape and save it as band in tiff file gdal.RasterizeLayer(target_ds, [1], source_layer, None, None, [1], ['ALL_TOUCHED=TRUE']) target_ds = None # Open array Raster_Basin = Open_tiff_array(Dir_Raster_end) return(Raster_Basin) def Moving_average(dataset, Moving_front, Moving_back): """ This function applies the moving averages over a 3D matrix called dataset. Keyword Arguments: dataset -- 3D matrix [time, ysize, xsize] Moving_front -- Amount of time steps that must be considered in the front of the current month Moving_back -- Amount of time steps that must be considered in the back of the current month """ dataset_out = np.zeros((int(np.shape(dataset)[0]) - Moving_back - Moving_front, int(np.shape(dataset)[1]), int(np.shape(dataset)[2]))) for i in range(Moving_back, (int(np.shape(dataset)[0]) - Moving_front)): dataset_out[i - Moving_back,:,:] = np.nanmean(dataset[i - Moving_back : i + 1 + Moving_front, :,:], 0) return(dataset_out) def Get_ordinal(Startdate, Enddate, freq = 'MS'): """ This function creates an array with ordinal time. Keyword Arguments: Startdate -- Startdate of the ordinal time Enddate -- Enddate of the ordinal time freq -- Time frequencies between start and enddate """ import datetime Dates = pd.date_range(Startdate, Enddate, freq = freq) i = 0 ordinal = np.zeros([len(Dates)]) for date in Dates: p = datetime.date(date.year, date.month, date.day).toordinal() ordinal[i]=p i += 1 return(ordinal) def Create_Buffer(Data_In, Buffer_area): ''' This function creates a 3D array which is used to apply the moving window ''' # Buffer_area = 2 # A block of 2 times Buffer_area + 1 will be 1 if there is the pixel in the middle is 1 Data_Out=np.empty((len(Data_In),len(Data_In[1]))) Data_Out[:,:] = Data_In for ypixel in range(0,Buffer_area + 1): for xpixel in range(1,Buffer_area + 1): if ypixel==0: for xpixel in range(1,Buffer_area + 1): Data_Out[:,0:-xpixel] += Data_In[:,xpixel:] Data_Out[:,xpixel:] += Data_In[:,:-xpixel] for ypixel in range(1,Buffer_area + 1): Data_Out[ypixel:,:] += Data_In[:-ypixel,:] Data_Out[0:-ypixel,:] += Data_In[ypixel:,:] else: Data_Out[0:-xpixel,ypixel:] += Data_In[xpixel:,:-ypixel] Data_Out[xpixel:,ypixel:] += Data_In[:-xpixel,:-ypixel] Data_Out[0:-xpixel,0:-ypixel] += Data_In[xpixel:,ypixel:] Data_Out[xpixel:,0:-ypixel] += Data_In[:-xpixel,ypixel:] Data_Out[Data_Out>0.1] = 1 Data_Out[Data_Out<=0.1] = 0 return(Data_Out)
wateraccounting/wa
General/raster_conversions.py
Python
apache-2.0
30,795
[ "ADF", "NetCDF" ]
d7f15783f7a0b4fa0ab999cd2ba1786b75baa8ae3e286d5117e1aabcca5ec1ee
from nose.tools import * from pysam import FastaFile import pysam import asmvar.variantutil as vutil from asmvar.variantutil import VariantCandidateReader as vcreader from asmvar.haplotype import Haplotype as Hap import asmvar.datum as dm import asmvar.common as com from asmvar.read import Read def setup(): print "SETUP!" """ def teardown(): print "TEAR DOWN!" def test_basic(): print "I RAN!" """ def test_VariantCandidateReader(): vcf_readers = vcreader(['tests/data/tb.vcf.gz']) varlist = vcf_readers.variants('20', 14369, 17330, False) test_case = [14370, 17330] series = [i.POS for i in varlist] assert_equal(series, test_case) varlist = vcf_readers.variants('20') def test_VariantCandidateReader_variants(): vcf_readers = vcreader(['tests/data/ex1.vcf.gz']) varlist = [] varlist = vcf_readers.variants(chrom = 'chr1', nosnp = False) pos_case_chr1 = [288, 548, 1294] ref_case_chr1 = ['A', 'C', 'A'] alt_case_chr1 = ['ACATAG', 'A', 'G'] assert_equal(pos_case_chr1, [i.POS for i in varlist]) assert_equal(ref_case_chr1, [i.REF for i in varlist]) assert_equal(alt_case_chr1, [i.ALT[0].sequence for i in varlist]) varlist = vcf_readers.variants(chrom = 'chr2', nosnp = False) pos_case_chr2 = [156, 505, 784, 1344] ref_case_chr2 = ['A', 'A', 'C', 'A'] alt_case_chr2 = ['AAG', 'G', 'CAATT', 'C'] assert_equal(pos_case_chr2, [i.POS for i in varlist]) assert_equal(ref_case_chr2, [i.REF for i in varlist]) assert_equal(alt_case_chr2, [str(i.ALT[0]) for i in varlist]) assert_equal(alt_case_chr2, [i.ALT[0].sequence for i in varlist]) print '\n',str(i.ALT[0]) + 'A', '\t', i.ALT[0].sequence, '\n' def test_vutil_get_sequence_context(): fa = FastaFile('tests/data/ex1.fa') vcf_readers = vcreader(['tests/data/ex1.vcf.gz'], 'options') varlist = vcf_readers.variants('chr2') vutil.get_sequence_context(fa.fetch('chr2'), varlist[0]) def test_vutil_homoRunForOneVariant(): assert_equal(vutil._calHrunSize('tcggg'), 0) assert_equal(vutil._calHrunSize('ttcggg'), 2) assert_equal(vutil._calHrunSize('AATTGAGACTACAGAGCAAC'), 2) assert_equal(vutil._calHrunSize('ACTCACAGGTTTTATAAAAC'[::-1]), 0) fa = FastaFile('tests/data/ex1.fa') vcf_readers = vcreader(['tests/data/ex1.vcf.gz']) varlist = vcf_readers.variants(chrom = 'chr1', nosnp = False) vutil.homoRunForOneVariant(fa, varlist[0]) varlist = vcf_readers.variants(chrom = 'chr2', nosnp = False) assert_equal(784, varlist[2].POS) assert_equal('ACTCACAGGTTTTATAAAAC', fa.fetch('chr2', varlist[2].POS - 20, varlist[2].POS)) assert_equal('AATTGAGACTACAGAGCAAC', fa.fetch('chr2', varlist[2].POS, varlist[2].POS + 20)) assert_equal('ACTCACAGGTTTTATAAAACAATTGAGACTACAGAGCAAC', fa.fetch('chr2', varlist[2].POS - 20, varlist[2].POS + 20)) hr = vutil.homoRunForOneVariant(fa, varlist[2]) assert_equal(2, hr) varlist[2].POS = fa.get_reference_length('chr2') hr = vutil.homoRunForOneVariant(fa, varlist[2]) assert_equal(0, hr) def test_datum(): comdata = dm.CommonDatum() print 'indel_error_qual: ', comdata.homopol_penalty print 'hashmer: ', comdata.hashmer print 'hashsize: ', comdata.hashsize print 'max_align_size: ', comdata.max_align_size print 'indel_error_qual: ', comdata.homopol_penalty, '\n', dm.CommonDatum().homopol_penalty def test_read(): bam = pysam.AlignmentFile('tests/data/ex1.bam') read = Read() reads = [] print '\n' for r in bam.fetch('chr1', 99, 100): reads.append(Read(r)) print reads[-1].name, reads[-1].seqs, reads[-1].qual, reads[-1].seq_hash, len(reads[-1]) def test_common_SeqHashTable(): ht = com.SeqHashTable('') # Empty seq = 'ATCGCCGcccNatcgccgcccc' # seq = 'nnnnnNnnNnnNNNNNNNNNnn' # Build the hash table for 'seq' ht = com.SeqHashTable(seq, dm.CommonDatum().hashmer) print '\n', ht.hash_table, '\n' for id in ht.hash_pointer: print id, '=>', ht.hash_table[id] print '\n' idx = {} for id in ht.hash_pointer: idx[id] = idx.get(id, -1) + 1 print idx[id], id, ht.hash_table[id][idx[id]] def test_set_gap_open_cost(): penalty = com.set_gap_open_penalty('ATCGCCGcccNatcgccgcccc', dm.CommonDatum().homopol_penalty) print '\npenalty:', penalty, [ord(i) for i in penalty] penalty = com.set_gap_open_penalty('atcg', dm.CommonDatum().homopol_penalty) print 'penalty:', penalty, [ord(i) for i in penalty] penalty = com.set_gap_open_penalty('AaAaaA', dm.CommonDatum().homopol_penalty) print 'penalty:', penalty, [ord(i) for i in penalty] def test_Haplotype(): fa = FastaFile('tests/data/ex1.fa') hap = Hap(fa, 'chr1', 1, 20, 100) def test_align_fastAlignmentRoutine(): import ctypes ######## class AlignTagPointer(ctypes.Structure): _fields_ = [("score", ctypes.c_int), ("pos", ctypes.c_int)] ######## align = ctypes.CDLL('asmvar/align.so') print '\n\n** Now testing the align module **\n\n' #seq1 = 'AAAGGGCAGGGGGGAGCACTAATGCGACCTCCACGCCCTTGTGTGTGA' #seq2 = 'ACCGGGCAGGGGGGAGCACTAATGCGACCTCCAC' #qual = '<<86<<;<78<<<)<;4<67<;<;<74-7;,;8,' #seq1 = 'AAAGGGCAGGGGGGAGCACTAATGCGACCTCCACGCCCTTGTGTGTCCATGTACACACGCTGTCCTATGTACTTAT' #seq2 = 'CAGGGGGGAGCACTAATGCGACCTCCACGCCCTTGT' #qual = '<<86<<;<78<<<)<;4<67<;<;<74-7;,;8,;9' seq1 = ('CACTAGTGGCTCATTGTAAATGTGTGGTTTAACTCGTCCATGGCCCAGCATTAGGGAGCT' 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCAC' 'GGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG' 'TCCCATTTGGAGCCCCTCTAAGCCGTTCTATTTGTAATGAAAACTATATTTATGCTATTC' 'AGTTCTAAATATAGAAATTGAAACAGCTGTGTTTAGTGCCTTTGTTCAACCCCCTTGCAA' 'CAACCTTGAGAACCCCAGGGAATTTGTCAATGTCAGGGAAGGAGCATTTTGTCAGTTACC' 'AAATGTGTTTATTACCAGAGGGATGGAGGGAAGAGGGACGCTGAAGAACTTTGATGCCCT' 'CTTCTTCCAAAGATGAAACGCGTAACTGCGCTCTCATTCACTCCAGCTCCCTGTCACCCA' 'ATGGACCTGTGATATCTGGATTCTGGGAAATTCTTCATCCTGGACCCTGAGAGATTCTGC' 'AGCCCAGCTCCAGATTGCTTGTGGTCTGACAGGCTGCAACTGTGAGCCATCACAATGAAC' 'AACAGGAAGAAAAGGTCTTTCAAAAGGTGATGTGTGTTCTCATCAACCTCATACACACAC' 'ATGGTTTAGGGGTATAATACCTCTACATGGCTGATTATGAAAACAATGTTCCCCAGATAC' 'CATCCCTGTCTTACTTCCAGCTCCCCAGAGGGAAAGCTTTCAACGCTTCTAGCCATTTCT' 'TTTGGCATTTGCCTTCAGACCCTACACGAATGCGTCTCTACCACAGGGGGCTGCGCGGTT' 'TCCCATCATGAAGCACTGAACTTCCACGTCTCATCTAGGGGAACAGGGAGGTGCACTAAT' 'GCGCTCCACGCCCAAGCCCTTCTCACAGTTTCTGCCCCCAGCATGGTTGTACTGGGCAAT' 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA' 'ACCACACATTAATACTATGTTTCTTATCTGCACATTACTACCCTGCAATTAATATAATTG' 'TGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA' 'CGTCCTATCTTCTTCTTAGGGAAGAACAGCTTAGGTATCAATTTGGTGTTCTGTGTAAAG' 'TCTCAGGGAGCCGTCCGTGTCCTCCCATCTGGCCTCGTCCACACTGGTTCTCTTGAAAGC' 'TTGGGCTGTAATGATGCCCCTTGGCCATCACCCAGTCCCTGCCCCATCTCTTGTAATCTC' 'TCTCCTTTTTGCTGCATCCCTGTCTTCCTCTGTCTTGATTTACTTGTTGTTGGTTTTCTG' 'TTTCTTTGTTTGATTTGGTGGAAGACATAATCCCACGCTTCCTATGGAAAGGTTGTTGGG' 'AGATTTTTAATGATTCCTCAATGTTAAAATGTCTATTTTTGTCTTGACACCCAACTAATA' 'TTTGTCTGAGCAAAACAGTCTAGATGAGAGAGAACTTCCCTGGAGGTCTGATGGCGTTTC' 'TCCCTCGTCTTCTTA') seq1 = 'GCAATCCCACTTGTGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN' seq1 = 'GTAGGAATGTAAAATGGTAGAGCCACTATGGAAAACAGTATGGAGGGTCCTCAAAACATTAAAAAATAGACCTACCATATGATGCAGCAATCCCACTTGTGNNNNNNNNNNNNNN' seq1 = 'GTAAAATGGTAGAGCCACTATGGAAAACAGTATGGAGGGTCCTCAAAACATTAAAAAATAGACCTACCATATGATGCAGCAATCCCACTTGTGGGCATTTNNNNNNN' seq2 = 'GTAAAATGGTAGAGCCACTATGGAAAACAGTATGGAGGGTCCTCAAAACATTAAAAAATAGACCTACCATATGATGCAGCAGTCCCACTTGTGGGCATTT' qual = '<<86<<;<78<<<)<;4<67<;<;<74-7;,;8,;88888888888888888888888888888888888888888888888888888888888888888' aln1 = ''.join(['\0' for i in range(2 * len(seq2) + 15)]) aln2 = ''.join(['\0' for i in range(2 * len(seq2) + 15)]) #local_gap_open = 'NKJHFA=854210/.-,,+**))(((\'\'\'&&&%%%$$$$#####"""""' local_gap_open = '--------------------*----------------------------------------------------------------------------------------------' read_start_in_hap = 0 align.fastAlignmentRoutine.restype = ctypes.POINTER(AlignTagPointer) score = align.fastAlignmentRoutine(seq1, seq2, qual, len(seq2) + 15, len(seq2), 3, 2, local_gap_open, aln1, aln2) if score.contents.score == -1: score.contents.score = 1000 print '\n\n*** After Align ***' print 'align score:', score.contents.score, ', POS:', score.contents.pos print 'align1: ', aln1, len(aln1) print 'align2: ', aln2, len(aln2) print '\n'
ShujiaHuang/AsmVar2
tests/asmvar_tests.py
Python
mit
8,854
[ "pysam" ]
eeed9411d728951be09cfe8b52e39cd725b2a88d31b47df388ce2d13cb1deba9
#!/bin/python from new-vm.py import * from libvirt-ks-kvm.conf import * #Generates a KS file. #This KS file is just an example and will not work with your environment. You will need to manually edit this config file. def ks_configurator(): KS = " install text cdrom lang en_US.UTF-8 keyboard us network --onboot yes --device eth0 --bootproto dhcp --hostname " + NAME + " rootpw --iscrypted " + ROOTPW + " firewall --disabled authconfig --enableshadow --sha-512 selinux --disabled timezone --utc America/Vancouver zerombr clearpart --all --initlabel part /boot --fstype=xfs --size=512 part pv.01 --size=1 --grow volgroup vg00 pv.01 logvol swap --fstype=swap --name=swap --vgname=vg00 --recommended logvol / --fstype=xfs --name=lv_root --vgname=vg00 --size=1 --grow bootloader --location=mbr --append="crashkernel=auto rhgb quiet" "console=ttyS0,115200" user --name=" + LOCALADMIN + " --iscrypted --groups=wheel --password=" + LOCALADMINPW + " reboot %packages @core -NetworkManager* %end %post --nochroot %end %post #!/bin/bash yum -y update yum -y install openssh-server yum -y install ipa-client yum -y install vim yum -y install wget yum -y install nfs-utils yum -y install git yum -y install curl yum -y install iptables yum -y install rsync systemctl enable sshd systemctl enable nfs-server systemctl enable rpcbind systemctl enable nfs-idmap systemctl enable nfs-lock echo "192.168.69.10:/mnt/Primary /mnt/share nfs auto 0 0" >> /etc/fstab echo $hostname > /etc/hostname hostname=$(curl http://cobbler.lilac.red/centos-7-install/hostname.cfg) echo "$hostname" > /etc/hostname d=$(echo "DHCP_HOSTNAME=") h=$(cat /etc/hostname) echo $d$h >> /etc/sysconfig/network-scripts/ifcfg-eth0 ipa-client-install --server=freeipa.lilac.red --domain=lilac.red --mkhomedir --hostname=$hostname --principal=join --password=MQIZE10ruI85tVkWaJI5 --unattended gpasswd -a brian wheel reboot %end " return KS
brianfarlinger/Quick-Configuration
ks-configurator.py
Python
gpl-3.0
1,928
[ "Brian" ]
42eae39ddb16cb79ae2e4d403fd6ae4fa6138537bee460fbd74103f8e86e887b
# Copyright 2014-2018 The PySCF Developers. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function import numpy as np from ctypes import POINTER, c_double, c_int64 from pyscf.nao.m_libnao import libnao libnao.aos_libnao.argtypes = ( POINTER(c_int64), # ncoords POINTER(c_double), # coords POINTER(c_int64), # norbs POINTER(c_double), # res[icoord, orb] POINTER(c_int64)) # ldres leading dimension (fastest changing dimension) of res (norbs) """ The purpose of this is to evaluate the atomic orbitals at a given set of atomic coordinates """ def aos_libnao(coords, norbs): assert len(coords.shape) == 2 assert coords.shape[1] == 3 assert norbs>0 ncoords = coords.shape[0] co2val = np.require( np.zeros((ncoords,norbs)), dtype=c_double, requirements='CW') crd_copy = np.require(coords, dtype=c_double, requirements='C') libnao.aos_libnao( c_int64(ncoords), crd_copy.ctypes.data_as(POINTER(c_double)), c_int64(norbs), co2val.ctypes.data_as(POINTER(c_double)), c_int64(norbs)) return co2val
gkc1000/pyscf
pyscf/nao/m_aos_libnao.py
Python
apache-2.0
1,597
[ "PySCF" ]
215c88ddbcd77a44164cba8535ee58a6ef38d7da9201296f0fa04c7c5df1254a
"""\ @file llmessage.py @brief Message template parsing and compatiblity $LicenseInfo:firstyear=2007&license=mit$ Copyright (c) 2007-2009, Linden Research, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. $/LicenseInfo$ """ from compatibility import Incompatible, Older, Newer, Same from tokenstream import TokenStream ### ### Message Template ### class Template: def __init__(self): self.messages = { } def addMessage(self, m): self.messages[m.name] = m def compatibleWithBase(self, base): messagenames = ( frozenset(self.messages.keys()) | frozenset(base.messages.keys()) ) compatibility = Same() for name in messagenames: selfmessage = self.messages.get(name, None) basemessage = base.messages.get(name, None) if not selfmessage: c = Older("missing message %s, did you mean to deprecate?" % name) elif not basemessage: c = Newer("added message %s" % name) else: c = selfmessage.compatibleWithBase(basemessage) c.prefix("in message %s: " % name) compatibility = compatibility.combine(c) return compatibility class Message: HIGH = "High" MEDIUM = "Medium" LOW = "Low" FIXED = "Fixed" priorities = [ HIGH, MEDIUM, LOW, FIXED ] prioritieswithnumber = [ FIXED ] TRUSTED = "Trusted" NOTTRUSTED = "NotTrusted" trusts = [ TRUSTED, NOTTRUSTED ] UNENCODED = "Unencoded" ZEROCODED = "Zerocoded" encodings = [ UNENCODED, ZEROCODED ] NOTDEPRECATED = "NotDeprecated" DEPRECATED = "Deprecated" UDPDEPRECATED = "UDPDeprecated" UDPBLACKLISTED = "UDPBlackListed" deprecations = [ NOTDEPRECATED, UDPDEPRECATED, UDPBLACKLISTED, DEPRECATED ] # in order of increasing deprecation def __init__(self, name, number, priority, trust, coding): self.name = name self.number = number self.priority = priority self.trust = trust self.coding = coding self.deprecateLevel = 0 self.blocks = [ ] def deprecated(self): return self.deprecateLevel != 0 def deprecate(self, deprecation): self.deprecateLevel = self.deprecations.index(deprecation) def addBlock(self, block): self.blocks.append(block) def compatibleWithBase(self, base): if self.name != base.name: # this should never happen in real life because of the # way Template matches up messages by name return Incompatible("has different name: %s vs. %s in base" % (self.name, base.name)) if self.priority != base.priority: return Incompatible("has different priority: %s vs. %s in base" % (self.priority, base.priority)) if self.trust != base.trust: return Incompatible("has different trust: %s vs. %s in base" % (self.trust, base.trust)) if self.coding != base.coding: return Incompatible("has different coding: %s vs. %s in base" % (self.coding, base.coding)) if self.number != base.number: return Incompatible("has different number: %s vs. %s in base" % (self.number, base.number)) compatibility = Same() if self.deprecateLevel != base.deprecateLevel: if self.deprecateLevel < base.deprecateLevel: c = Older("is less deprecated: %s vs. %s in base" % ( self.deprecations[self.deprecateLevel], self.deprecations[base.deprecateLevel])) else: c = Newer("is more deprecated: %s vs. %s in base" % ( self.deprecations[self.deprecateLevel], self.deprecations[base.deprecateLevel])) compatibility = compatibility.combine(c) selflen = len(self.blocks) baselen = len(base.blocks) samelen = min(selflen, baselen) for i in xrange(0, samelen): selfblock = self.blocks[i] baseblock = base.blocks[i] c = selfblock.compatibleWithBase(baseblock) if not c.same(): c = Incompatible("block %d isn't identical" % i) compatibility = compatibility.combine(c) if selflen > baselen: c = Newer("has %d extra blocks" % (selflen - baselen)) elif selflen < baselen: c = Older("missing %d extra blocks" % (baselen - selflen)) else: c = Same() compatibility = compatibility.combine(c) return compatibility class Block(object): SINGLE = "Single" MULTIPLE = "Multiple" VARIABLE = "Variable" repeats = [ SINGLE, MULTIPLE, VARIABLE ] repeatswithcount = [ MULTIPLE ] def __init__(self, name, repeat, count=None): self.name = name self.repeat = repeat self.count = count self.variables = [ ] def addVariable(self, variable): self.variables.append(variable) def compatibleWithBase(self, base): if self.name != base.name: return Incompatible("has different name: %s vs. %s in base" % (self.name, base.name)) if self.repeat != base.repeat: return Incompatible("has different repeat: %s vs. %s in base" % (self.repeat, base.repeat)) if self.repeat in Block.repeatswithcount: if self.count != base.count: return Incompatible("has different count: %s vs. %s in base" % (self.count, base.count)) compatibility = Same() selflen = len(self.variables) baselen = len(base.variables) for i in xrange(0, min(selflen, baselen)): selfvar = self.variables[i] basevar = base.variables[i] c = selfvar.compatibleWithBase(basevar) if not c.same(): c = Incompatible("variable %d isn't identical" % i) compatibility = compatibility.combine(c) if selflen > baselen: c = Newer("has %d extra variables" % (selflen - baselen)) elif selflen < baselen: c = Older("missing %d extra variables" % (baselen - selflen)) else: c = Same() compatibility = compatibility.combine(c) return compatibility class Variable: U8 = "U8"; U16 = "U16"; U32 = "U32"; U64 = "U64" S8 = "S8"; S16 = "S16"; S32 = "S32"; S64 = "S64" F32 = "F32"; F64 = "F64" LLVECTOR3 = "LLVector3"; LLVECTOR3D = "LLVector3d"; LLVECTOR4 = "LLVector4" LLQUATERNION = "LLQuaternion" LLUUID = "LLUUID" BOOL = "BOOL" IPADDR = "IPADDR"; IPPORT = "IPPORT" FIXED = "Fixed" VARIABLE = "Variable" types = [ U8, U16, U32, U64, S8, S16, S32, S64, F32, F64, LLVECTOR3, LLVECTOR3D, LLVECTOR4, LLQUATERNION, LLUUID, BOOL, IPADDR, IPPORT, FIXED, VARIABLE ] typeswithsize = [ FIXED, VARIABLE ] def __init__(self, name, type, size): self.name = name self.type = type self.size = size def compatibleWithBase(self, base): if self.name != base.name: return Incompatible("has different name: %s vs. %s in base" % (self.name, base.name)) if self.type != base.type: return Incompatible("has different type: %s vs. %s in base" % (self.type, base.type)) if self.type in Variable.typeswithsize: if self.size != base.size: return Incompatible("has different size: %s vs. %s in base" % (self.size, base.size)) return Same() ### ### Parsing Message Templates ### class TemplateParser: def __init__(self, tokens): self._tokens = tokens self._version = 0 self._numbers = { } for p in Message.priorities: self._numbers[p] = 0 def parseTemplate(self): tokens = self._tokens t = Template() while True: if tokens.want("version"): v = float(tokens.require(tokens.wantFloat())) self._version = v t.version = v continue m = self.parseMessage() if m: t.addMessage(m) continue if self._version >= 2.0: tokens.require(tokens.wantEOF()) break else: if tokens.wantEOF(): break tokens.consume() # just assume (gulp) that this is a comment # line 468: "sim -> dataserver" return t def parseMessage(self): tokens = self._tokens if not tokens.want("{"): return None name = tokens.require(tokens.wantSymbol()) priority = tokens.require(tokens.wantOneOf(Message.priorities)) if self._version >= 2.0 or priority in Message.prioritieswithnumber: number = int("+" + tokens.require(tokens.wantInteger()), 0) else: self._numbers[priority] += 1 number = self._numbers[priority] trust = tokens.require(tokens.wantOneOf(Message.trusts)) coding = tokens.require(tokens.wantOneOf(Message.encodings)) m = Message(name, number, priority, trust, coding) if self._version >= 2.0: d = tokens.wantOneOf(Message.deprecations) if d: m.deprecate(d) while True: b = self.parseBlock() if not b: break m.addBlock(b) tokens.require(tokens.want("}")) return m def parseBlock(self): tokens = self._tokens if not tokens.want("{"): return None name = tokens.require(tokens.wantSymbol()) repeat = tokens.require(tokens.wantOneOf(Block.repeats)) if repeat in Block.repeatswithcount: count = int(tokens.require(tokens.wantInteger())) else: count = None b = Block(name, repeat, count) while True: v = self.parseVariable() if not v: break b.addVariable(v) tokens.require(tokens.want("}")) return b def parseVariable(self): tokens = self._tokens if not tokens.want("{"): return None name = tokens.require(tokens.wantSymbol()) type = tokens.require(tokens.wantOneOf(Variable.types)) if type in Variable.typeswithsize: size = tokens.require(tokens.wantInteger()) else: tokens.wantInteger() # in LandStatRequest: "{ ParcelLocalID S32 1 }" size = None tokens.require(tokens.want("}")) return Variable(name, type, size) def parseTemplateString(s): return TemplateParser(TokenStream().fromString(s)).parseTemplate() def parseTemplateFile(f): return TemplateParser(TokenStream().fromFile(f)).parseTemplate()
gabeharms/firestorm
indra/lib/python/indra/ipc/llmessage.py
Python
lgpl-2.1
12,631
[ "GULP" ]
65c366e5b998f682f4d6fd32562ac7b7588ff09322c2cb55b3626d82c25dba9b
############################################################################## # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # # For details, see https://github.com/spack/spack # Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (as # published by the Free Software Foundation) version 2.1, February 1999. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and # conditions of the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * class RGcrma(RPackage): """Background adjustment using sequence information""" homepage = "https://bioconductor.org/packages/gcrma/" git = "https://git.bioconductor.org/packages/gcrma.git" version('2.48.0', commit='3ea0eb0b5c15ffb24df76620667ae7996ed715b4') depends_on('r-affy', type=('build', 'run')) depends_on('r-biobase', type=('build', 'run')) depends_on('r-affyio', type=('build', 'run')) depends_on('r-xvector', type=('build', 'run')) depends_on('r-biostrings', type=('build', 'run')) depends_on('r-biocinstaller', type=('build', 'run')) depends_on('r@3.4.0:3.4.9', when='@2.48.0')
krafczyk/spack
var/spack/repos/builtin/packages/r-gcrma/package.py
Python
lgpl-2.1
1,898
[ "Bioconductor" ]
b8193d4a0ff74dd4bbb81a6149f1d628ea7aec125e5a0fb300d9e8276e548a5b
from __future__ import print_function import os import sys import argparse import pysam def convert_sams2bams(sams): separator = "," split_sams = sams.split(separator) bams = list() for sam in split_sams: bam = sam.replace(".sam", ".bam") bams.append(bam) os.system("samtools view -Sbh {} > {}".format(sam, bam)) return separator.join(bams) def index_bams(bams): split_bams = bams.split(",") for bam in split_bams: index_files = [bam + '.bai', bam + '.csi'] for index_file in index_files: if os.path.isfile(index_file): # if the bam file has been indexed. print("'{}' is indexed already: '{}'".format(bam, index_file)) return print("Indexing '{}'.".format(bam)) os.system("samtools index " + bam) def prepare_bams(options): """ convert sam files to bam files and store the filename in options.b1 & options.b2. Ensure bams are indexed. """ if options.s1: options.b1 = convert_sams2bams(options.s1) if options.s2: options.b2 = convert_sams2bams(options.s2) if options.b1: index_bams(options.b1) if options.b2: index_bams(options.b2) def file_check(string, expected_ext): """ check the existence of the files and whether they are with the right extensions :param string: original string jointed file names by comma :param extension: a string like ".bam" in lowercase :return: error message or None """ name_arr = string.split(',') for name in name_arr: if not os.path.isfile(name): return '{} is not a file'.format(name) extension = os.path.splitext(name)[1] if extension.lower() != expected_ext.lower(): return '{} has extension {} but expected {} (ignoring case)'.format( name, extension, expected_ext) return None def checkout(parser, options): """ check out the required arguments :return: None """ # bam files and sam files are alternative, the same for the case of events_file and coordinate # events_file should be provided together with event_type if ((options.s1 is None and options.b1 is None and options.s2 is None and options.b2 is None)): parser.error("Not enough arguments! Please provide at least one of" " --s1, --b1, --s2, --b2") if (((options.s1 is not None or options.s2 is not None) and (options.b1 is not None or options.b2 is not None))): parser.error("Specify either sam files or bam files not both") if (options.events_file is None or options.event_type is None) and options.coordinate is None: parser.error("Not enough arguments! Please provide " "1) coordinates with gff3 files. or " "2) events files together with events type.") used_sample_1 = False used_sample_2 = False if options.s1 is not None: used_sample_1 = True file_check_error = file_check(options.s1, ".sam") if file_check_error: parser.error("Error checking sam files given as --s1: {}".format( file_check_error)) if options.s2 is not None: used_sample_2 = True file_check_error = file_check(options.s2, ".sam") if file_check_error: parser.error("Error checking sam files given as --s2: {}".format( file_check_error)) if options.b1 is not None: used_sample_1 = True file_check_error = file_check(options.b1, ".bam") if file_check_error: parser.error("Error checking bam files given as --b1: {}".format( file_check_error)) if options.b2 is not None: used_sample_2 = True file_check_error = file_check(options.b2, ".bam") if file_check_error: parser.error("Error checking bam files given as --b2: {}".format( file_check_error)) if options.l1 is None: if used_sample_1: parser.error('Must provide --l1 if using --s1 or --b1') else: options.l1 = 'DefaultLabel1' if options.l2 is None: if used_sample_2: parser.error('Must provide --l2 if using --s2 or --b2') else: options.l2 = 'DefaultLabel2' if options.events_file: file_check_error = file_check(options.events_file, ".txt") if file_check_error: parser.error("Error checking rMATS output given as -e: {}".format( file_check_error)) def conf_setting_file(options, gene_no_str=None, gene_symbol=None, events_name_level=None, id_str=None): """ configure the setting files the empty of gene_no_str means plotting with events file, otherwise with coordinates """ if gene_no_str is not None: setting_file = open(os.path.join(options.out_dir, "Sashimi_index_" + gene_no_str, "sashimi_plot_settings.txt"), 'w') else: setting_file = open(os.path.join(options.sashimi_path, "sashimi_plot_settings.txt"), 'w') setting_file.write("[data]\n") sam_dir = "" # since bam path is accessible, we don't need to provide a prefix particularly setting_file.write("bam_prefix = " + sam_dir + "\n") setting_file.write("miso_prefix = " + sam_dir + "\n") # setting string for replicates bam_files_arr1 = [] bam_files_arr2 = [] sample_1 = list() sample_2 = list() # sam files have already been converted into bam files and stored in options.b1&b2 if options.b1: sample_1 = options.b1.split(',') if options.b2: sample_2 = options.b2.split(',') for s in sample_1: # sample1 bam_files_arr1.append('\"' + s + '\"') for s in sample_2: # sample2 bam_files_arr2.append('\"' + s + '\"') setting_bam_str = ','.join(bam_files_arr1 + bam_files_arr2) len_sample1 = len(sample_1) len_sample2 = len(sample_2) setting_file.write("bam_files = [{0}]\n".format(setting_bam_str)) setting_file.write("miso_files = [{0}]\n".format(setting_bam_str)) setting_file.write("[plotting]\n") # use a dict to store the configuration setting = {} if len_sample1 < 5: setting['fig_height'] = 7 else: setting["fig_height"] = 14 setting["fig_width"] = 8 setting["exon_scale"] = str(options.exon_s) setting["intron_scale"] = str(options.intron_s) setting["logged"] = False setting["font_size"] = options.font_size setting["bar_posteriors"] = False setting["nyticks"] = 4 if gene_no_str is None: setting["nxticks"] = 11 else: setting["nxticks"] = 6 setting["show_ylabel"] = True setting["show_xlabel"] = True setting["plot_title"] = "\"gene symbol\"" setting["plot_label"] = "plot_label" setting["show_posteriors"] = False setting["number_junctions"] = not options.hide_number setting["resolution"] = ".5" setting["reverse_minus"] = True setting["min_counts"] = max(options.min_counts, 0) setting["text_background"] = options.text_background if options.group_info is None: setting["group_info"] = False else: setting["group_info"] = True for item in setting: setting_file.write("{0} = {1}\n".format(item, setting[item])) # setting color setting_color_str = "" if options.color is None: colors_arr1 = ['\"#CC0011\"'] * len_sample1 colors_arr2 = ['\"#FF8800\"'] * len_sample2 setting_color_str = ','.join(colors_arr1 + colors_arr2) else: colors_arr = ["\"{0}\"".format(c) for c in options.color.split(',')] setting_color_str = ','.join(colors_arr) setting_file.write("colors = [{0}]\n".format(setting_color_str)) # setting label sample_labels_arr1 = [] sample_labels_arr2 = [] if gene_no_str is None: # the case with coordinate for rr in range(0, len_sample1): sample_labels_arr1.append('\"{0}-{1}\"'.format(options.l1, str(rr + 1))) for rr in range(0, len_sample2): sample_labels_arr2.append('\"{0}-{1}\"'.format(options.l2, str(rr + 1))) else: # the case with events file inc_level_str = events_name_level.get(gene_symbol) items = inc_level_str.split('_') inc_level1 = items[0] inc_level2 = items[1] inc_items1 = inc_level1.split(',') inc_items2 = inc_level2.split(',') warning_flag = False for rr in range(0, len_sample1): try: inc_1 = "{0:.2f}".format(float(inc_items1[rr])) except Exception: inc_1 = "{0:.2f}".format(float('nan')) warning_flag = True sample_labels_arr1.append('\"' + gene_symbol + ' ' + options.l1 + '-' + str(rr + 1) + ' IncLevel: ' + inc_1 + '\"') for rr in range(0, len_sample2): try: inc_2 = "{0:.2f}".format(float(inc_items2[rr])) except Exception: inc_2 = "{0:.2f}".format(float('nan')) warning_flag = True sample_labels_arr2.append('\"' + gene_symbol + ' ' + options.l2 + '-' + str(rr + 1) + ' IncLevel: ' + inc_2 + '\"') if warning_flag: print("Warning: The inclusion levels of Event '{}' contains" " 'NA' value, which could lead to unexpected output." .format(id_str), file=sys.stderr) setting_label_str = ','.join(sample_labels_arr1 + sample_labels_arr2) setting_file.write("sample_labels = [{0}]\n".format(setting_label_str)) setting_file.close() def parse_gff3_record(record): """TODO: Docstring for parse_gff3_record. :returns: TODO """ res = {} eles = record.split('\t') res['seqid'] = eles[0] res['source'] = eles[1] res['type'] = eles[2] res['start'] = eles[3] res['end'] = eles[4] res['score'] = eles[5] res['strand'] = eles[6] res['phase'] = eles[7] res['attributes'] = eles[8] return res def get_python_executable(): # Try to get the absolute path of the executable for the running # Python interpreter. python_executable = sys.executable if not python_executable: # Fallback print('Absolute path for current Python interpreter not found.' ' Using "python" without a full path to run scripts', file=sys.stderr) python_executable = 'python' return python_executable def plot_c(options, id_str): """ the plot part of the coordinate method """ path_index_gff = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'MISO/misopy/index_gff.py') path_sashimi_plot = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'MISO/misopy/sashimi_plot/sashimi_plot.py') python_executable = get_python_executable() # call python index_gff.py tmp_str = os.path.join(options.sashimi_path, "tmp.gff3") os.system("{} {} --index {} {}".format(python_executable, path_index_gff, tmp_str, options.sashimi_path)) # call python sashimi_plot.py setting_str = os.path.join(options.sashimi_path, "sashimi_plot_settings.txt") output_path = os.path.join(options.out_dir, "Sashimi_plot") if options.group_info is not None: os.system("{} {} --plot-event \"{}\" {} {} " "--output-dir {} --group-info {}".format( python_executable, path_sashimi_plot, id_str, options.sashimi_path, setting_str, output_path, options.group_info)) else: os.system("{} {} --plot-event \"{}\" {} {} " "--output-dir {}".format( python_executable, path_sashimi_plot, id_str, options.sashimi_path, setting_str, output_path)) return def plot_e(options, id_str, gene_symbol, events_no): """ the plot part of the events file method """ path_index_gff = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'MISO/misopy/index_gff.py') path_sashimi_plot = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'MISO/misopy/sashimi_plot/sashimi_plot.py') python_executable = get_python_executable() # call python index_gff.py out_index = os.path.join(options.out_dir, "Sashimi_index_" + gene_symbol + '_' + str(events_no)) tmp_str = os.path.join(out_index, "tmp.gff3") os.system("{} {} --index {} {}".format(python_executable, path_index_gff, tmp_str, out_index)) # call python sashimi_plot.py setting_str = os.path.join(out_index, "sashimi_plot_settings.txt") output_path = os.path.join(options.out_dir, "Sashimi_plot") print("{} {} --plot-event \"{}\" {} {} " "--output-dir {}".format(python_executable, path_sashimi_plot, id_str, out_index, setting_str, output_path)) if options.group_info is not None: os.system("{} {} --plot-event \"{}\" {} {} " "--output-dir {} --group-info {}".format( python_executable, path_sashimi_plot, id_str, out_index, setting_str, output_path, options.group_info)) else: os.system("{} {} --plot-event \"{}\" {} {} " "--output-dir {}".format( python_executable, path_sashimi_plot, id_str, out_index, setting_str, output_path)) # move pdf file old_file = os.path.join(options.out_dir, "Sashimi_plot", id_str + '.pdf') new_file = os.path.join(options.out_dir, "Sashimi_plot", str(events_no) + '_' + gene_symbol + '_' + id_str + '.pdf') os.system("mv {0} {1}".format(old_file, new_file)) return def plot_with_coordinate(options): """ if the user provides with coordinate, then plot in this way """ try: tmp_str = options.coordinate.split(':') in_chr = tmp_str[0] # if not in_chr.startswith("chr"): # add 'chr' prefix to the sequence name which is from the input arguement # in_chr = "chr" + in_chr in_strand = tmp_str[1] in_coor_s = tmp_str[2] in_coor_e = int(tmp_str[3]) + 1 id_str = in_chr + "_" + in_coor_s + "_" + str(in_coor_e) + "_" + in_strand # chr2_10101175_10104171_+ gff3_file = tmp_str[4] fo = open(gff3_file, 'r') w2 = open(os.path.join(options.sashimi_path, "SE.event.list.txt"), 'w') w1 = open(os.path.join(options.sashimi_path, "tmp.gff3"), 'w') w1.write("%s\tensGene\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % (in_chr, in_coor_s, in_coor_e, in_strand, id_str, id_str)) # w1.write("%s\tensGene\tmRNA\t%s\t%s\t.\t%s\t.\tName=ENST00000000000;Parent=%s;ID=ENST00000000000\n" % # (in_chr, in_coor_s, in_coor_e, in_strand, id_str)) events_no = 0 for line in fo: if line.startswith('#'): continue events_no += 1 items = line.split("\t") # if items[0].startswith("chr"): # item_chr = items[0] # else: # add 'chr' prefix to the seqence name which is from the gff3 file # item_chr = "chr" + items[0] item_chr = items[0] if in_chr != item_chr: continue item_type = items[2] is_mrna_or_transcript = item_type in ["mRNA", "transcript"] if is_mrna_or_transcript or item_type == "exon": coor_s = items[3] coor_e = items[4] strand = items[6] annot_str = items[8].strip() # judge whether the coordinates fit in the item if (in_strand == strand and ((item_type == 'exon' and int(in_coor_s) <= int(coor_s) and int(coor_e) <= int(in_coor_e)) or (is_mrna_or_transcript and int(coor_s) < int(in_coor_e) and int(coor_e) > int(in_coor_s)))): if is_mrna_or_transcript: if int(coor_s) < int(in_coor_s): coor_s = in_coor_s if int(coor_e) > int(in_coor_e): coor_e = in_coor_e annot_str = annot_str.replace('Parent', 'Note') w1.write("%s\tensGene\t%s\t%s\t%s\t.\t%s\t.\tParent=%s;%s\n" % (item_chr, item_type, coor_s, coor_e, strand, id_str, annot_str)) if item_type == "exon": w1.write("%s\tensGene\t%s\t%s\t%s\t.\t%s\t.\t%s\n" % (item_chr, item_type, coor_s, coor_e, strand, annot_str)) w1.close() try: conf_setting_file(options) except Exception as e: print(e) print("There is an exception in preparing coordinate setting file") raise plot_c(options, id_str) fo.close() except Exception as e: print(e) print("There is an exception in plot_with_coordinate") raise return class EventCoor(object): """ to store the coordinates regarding to the event_type """ def __init__(self, event_type, items): if event_type == "MXE": self.e1st_s = str(int(items[5]) + 1) self.e1st_e = items[6] self.e2st_s = str(int(items[7]) + 1) self.e2st_e = items[8] self.up_s = str(int(items[9]) + 1) self.up_e = items[10] self.dn_s = str(int(items[11]) + 1) self.dn_e = items[12] self.inc_level1 = items[22] # IncLevel1 self.inc_level2 = items[23] # IncLevel2 elif event_type == "SE" or event_type == "RI": self.se_s = str(int(items[5]) + 1) self.se_e = items[6] self.up_s = str(int(items[7]) + 1) self.up_e = items[8] self.dn_s = str(int(items[9]) + 1) self.dn_e = items[10] self.inc_level1 = items[20] # IncLevel1 self.inc_level2 = items[21] # IncLevel2 else: # A3SS or A5SS self.lo_s = str(int(items[5]) + 1) # long self.lo_e = items[6] self.sh_s = str(int(items[7]) + 1) # short self.sh_e = items[8] self.fl_s = str(int(items[9]) + 1) # flanking self.fl_e = items[10] self.inc_level1 = items[20] # IncLevel1 self.inc_level2 = items[21] # IncLevel2 self.name_str = '' self.id_str = '' def generate_in_positive_order(self, seq_chr, gene_symbol, strand, event_type): if event_type == 'MXE': self.id_str = (seq_chr + "_" + self.up_s + "_" + self.up_e + "_" + strand + "@" + seq_chr + "_" + self.e1st_s + "_" + self.e1st_e + "_" + strand + "@" + seq_chr + "_" + self.e2st_s + "_" + self.e2st_e + "_" + strand + "@" + seq_chr + "_" + self.dn_s + "_" + self.dn_e + "_" + strand) elif event_type == 'A5SS': self.id_str = (seq_chr + "_" + self.sh_s + "_" + self.sh_e + "_" + strand + "@" + seq_chr + "_" + self.lo_s + "_" + self.lo_e + "_" + strand + "@" + seq_chr + "_" + self.fl_s + "_" + self.fl_e + "_" + strand) elif event_type == 'A3SS': self.id_str = (seq_chr + "_" + self.fl_s + "_" + self.fl_e + "_" + strand + "@" + seq_chr + "_" + self.lo_s + "_" + self.lo_e + "_" + strand + "@" + seq_chr + "_" + self.sh_s + "_" + self.sh_e + "_" + strand) elif event_type == 'SE' or event_type == 'RI': self.id_str = (seq_chr + "_" + self.up_s + "_" + self.up_e + "_" + strand + "@" + seq_chr + "_" + self.se_s + "_" + self.se_e + "_" + strand + "@" + seq_chr + "_" + self.dn_s + "_" + self.dn_e + "_" + strand) self.name_str = gene_symbol + "_" + self.id_str def generate_in_reversed_order(self, seq_chr, gene_symbol, strand, event_type): if event_type == 'MXE': self.id_str = (seq_chr + "_" + self.dn_s + "_" + self.dn_e + "_" + strand + "@" + seq_chr + "_" + self.e2st_s + "_" + self.e2st_e + "_" + strand + "@" + seq_chr + "_" + self.e1st_s + "_" + self.e1st_e + "_" + strand + "@" + seq_chr + "_" + self.up_s + "_" + self.up_e + "_" + strand) elif event_type == 'A3SS': # the same as the positive order in A5SS self.id_str = (seq_chr + "_" + self.sh_s + "_" + self.sh_e + "_" + strand + "@" + seq_chr + "_" + self.lo_s + "_" + self.lo_e + "_" + strand + "@" + seq_chr + "_" + self.fl_s + "_" + self.fl_e + "_" + strand) elif event_type == 'A5SS': # the same as the positive order in A3SS self.id_str = (seq_chr + "_" + self.fl_s + "_" + self.fl_e + "_" + strand + "@" + seq_chr + "_" + self.lo_s + "_" + self.lo_e + "_" + strand + "@" + seq_chr + "_" + self.sh_s + "_" + self.sh_e + "_" + strand) elif event_type == 'SE' or event_type == 'RI': self.id_str = (seq_chr + "_" + self.dn_s + "_" + self.dn_e + "_" + strand + "@" + seq_chr + "_" + self.se_s + "_" + self.se_e + "_" + strand + "@" + seq_chr + "_" + self.up_s + "_" + self.up_e + "_" + strand) self.name_str = gene_symbol + "_" + self.id_str def create_chr_aware_events_file(options): """ The *.MATS.*.txt events file from rmats includes the prefix 'chr' for chromosomes. If the BAM files do not have the 'chr' prefix then remove the prefix from the events file. Consistent presence or absence of 'chr' is needed to search for reads in the BAM files. """ orig_events_file_path = options.events_file new_events_file_path = os.path.join(options.sashimi_path, 'events_file.txt') if options.b1: first_bam_path = options.b1.split(',')[0] else: first_bam_path = options.b2.split(',')[0] with pysam.AlignmentFile(first_bam_path, 'rb') as bam_file: for alignment in bam_file.fetch(until_eof=True): ref_name = alignment.reference_name sam_has_chr_prefix = ref_name.startswith('chr') break # only check first alignment remove_chr_prefix = (not options.keep_event_chr_prefix and (options.remove_event_chr_prefix or not sam_has_chr_prefix)) with open(orig_events_file_path, 'rt') as orig_handle: with open(new_events_file_path, 'wt') as new_handle: for i, line in enumerate(orig_handle): is_header_line = i == 0 columns = line.rstrip('\n').split('\t') if is_header_line: chr_index = columns.index('chr') elif remove_chr_prefix: orig_chr_column = columns[chr_index] if orig_chr_column.startswith('chr'): columns[chr_index] = orig_chr_column[3:] new_line = '\t'.join(columns) new_handle.write('{}\n'.format(new_line)) return new_events_file_path def plot_with_eventsfile(options): """ if the user provides with event files, then plot in this way """ try: options.events_file = create_chr_aware_events_file(options) fo = open(options.events_file, 'r') w2 = open(os.path.join(options.sashimi_path, options.event_type + ".event.list.txt"), 'w') events_name_level = {} events_no = 0 for line in fo: if line.startswith('ID'): continue events_no += 1 items = line.split("\t") gene_symbol = items[2] gene_symbol = gene_symbol.replace("\"", '') gene_no_str = gene_symbol + '_' + str(events_no) sashimi_path = os.path.join(options.out_dir, "Sashimi_index_" + gene_symbol + '_' + str(events_no)) if not os.path.isdir(sashimi_path): os.makedirs(sashimi_path) w1 = open(os.path.join(sashimi_path, "tmp.gff3"), 'w') seq_chr = items[3] strand = items[4] # construct the events coordinates depending on the event type coor = EventCoor(options.event_type, items) events_name_level[gene_symbol] = coor.inc_level1 + "_" + coor.inc_level2 if strand == '+': coor.generate_in_positive_order(seq_chr, gene_symbol, strand, options.event_type) w2.write("%s\n" % coor.name_str) if options.event_type == "SE" or options.event_type == "RI": w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.se_s, coor.se_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "A3SS": # flanking -- long/short TODO: change the ID name w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "A5SS": # short/long -- flanking TODO: change the ID name w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "MXE": w1.write("%s\tMXE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tMXE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.1st;Parent=%s.A\n" % ( seq_chr, coor.e1st_s, coor.e1st_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.2st;Parent=%s.B\n" % ( seq_chr, coor.e2st_s, coor.e2st_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) elif strand == '-': coor.generate_in_reversed_order(seq_chr, gene_symbol, strand, options.event_type) w2.write("%s\n" % coor.name_str) if options.event_type == "SE" or options.event_type == "RI": w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.se_s, coor.se_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "A5SS": # flanking -- long/short TODO: change the ID name w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.fl_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "A3SS": # short/long -- flanking TODO: change the ID name w1.write("%s\tSE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.sh_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.se;Parent=%s.A\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.fl_s, coor.fl_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.sh_s, coor.sh_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tSE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.lo_s, coor.lo_e, strand, coor.id_str, coor.id_str)) elif options.event_type == "MXE": w1.write("%s\tMXE\tgene\t%s\t%s\t.\t%s\t.\tID=%s;Name=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.name_str)) w1.write("%s\tMXE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.A;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\tmRNA\t%s\t%s\t.\t%s\t.\tID=%s.B;Parent=%s\n" % ( seq_chr, coor.up_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.up;Parent=%s.A\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.1st;Parent=%s.A\n" % ( seq_chr, coor.e1st_s, coor.e1st_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.A.dn;Parent=%s.A\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.up;Parent=%s.B\n" % ( seq_chr, coor.dn_s, coor.dn_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.2st;Parent=%s.B\n" % ( seq_chr, coor.e2st_s, coor.e2st_e, strand, coor.id_str, coor.id_str)) w1.write("%s\tMXE\texon\t%s\t%s\t.\t%s\t.\tID=%s.B.dn;Parent=%s.B\n" % ( seq_chr, coor.up_s, coor.up_e, strand, coor.id_str, coor.id_str)) w1.close() try: conf_setting_file(options, gene_no_str, gene_symbol, events_name_level, coor.id_str) except Exception as e: print(e) print("There is an exception in preparing coordinate setting file") raise plot_e(options, coor.id_str, gene_symbol, events_no) fo.close() w2.close() except Exception as e: print(e) print("There is an exception in plot_with_eventsfile") raise def main(): parser = argparse.ArgumentParser(prog="rmats2sashimiplot") required_group = parser.add_argument_group('Required') required_group.add_argument("-o", dest="out_dir", required=True, help="The output directory.") label_group = parser.add_argument_group('Labels') label_group.add_argument("--l1", dest="l1", help="The label for the first sample.") label_group.add_argument("--l2", dest="l2", help="The label for the second sample.") rmats_group_str = 'rMATS event input' coord_group_str = 'Coordinate and annotation input' rmats_group = parser.add_argument_group( rmats_group_str, 'Use either ({}) or ({})'.format(rmats_group_str, coord_group_str)) coordinate_group = parser.add_argument_group( coord_group_str, 'Use either ({}) or ({})'.format(coord_group_str, rmats_group_str)) rmats_group.add_argument( "-t", dest="event_type", choices=['SE', 'A5SS', 'A3SS', 'MXE', 'RI'], help=("Type of event from rMATS result used in the analysis." " 'SE': skipped exon," " 'A5SS': alternative 5' splice site," " 'A3SS' alternative 3' splice site," " 'MXE': mutually exclusive exons," " 'RI': retained intron." " (Only if using " + rmats_group_str + ")")) rmats_group.add_argument( "-e", dest="events_file", help=("The rMATS output event file (Only if using " + rmats_group_str + ")")) coordinate_group.add_argument( "-c", dest="coordinate", help=("The genome region coordinates and a GFF3 (not GTF) annotation" " file of genes and transcripts. The format is" " -c {chromosome}:{strand}:{start}:{end}:{/path/to/gff3}" " (Only if using " + coord_group_str + ")")) sam_bam_group_str_template = '{} Files' sam_bam_group_desc_template = ( 'Mapping results for sample_1 & sample_2 in {0} format.' ' Replicates must be in a comma separated list.' ' (Only if using {0})') sam_bam_sample_arg_desc_template = ( 'sample_{num} {kind} files: s{num}_rep1.{kind}[,s{num}_rep2.{kind}]') group_sam = parser.add_argument_group( sam_bam_group_str_template.format('SAM'), sam_bam_group_desc_template.format('SAM')) group_sam.add_argument( "--s1", dest="s1", help=sam_bam_sample_arg_desc_template.format(num=1, kind='sam')) group_sam.add_argument( "--s2", dest="s2", help=sam_bam_sample_arg_desc_template.format(num=2, kind='sam')) group_bam = parser.add_argument_group( sam_bam_group_str_template.format('BAM'), sam_bam_group_desc_template.format('BAM')) group_bam.add_argument( "--b1", dest="b1", help=sam_bam_sample_arg_desc_template.format(num=1, kind='bam')) group_bam.add_argument( "--b2", dest="b2", help=sam_bam_sample_arg_desc_template.format(num=2, kind='bam')) optional_group = parser.add_argument_group('Optional') optional_group.add_argument( "--exon_s", dest="exon_s", type=int, default=1, help="How much to scale down exons. Default: %(default)s") optional_group.add_argument( "--intron_s", dest="intron_s", type=int, default=1, help=("How much to scale down introns. For example, --intron_s 5" " results in an intron with real length of 100 being plotted as" " 100/5 = 20. Default: %(default)s")) optional_group.add_argument( "--group-info", dest="group_info", help=('The path to a *.gf file which groups the replicates. One' ' sashimi plot will be generated for each group instead of' ' the default behavior of one plot per replicate')) optional_group.add_argument( "--min-counts", dest="min_counts", default=0, help=("Individual junctions with read count below --min-counts will" " be omitted from the plot. Default: %(default)s")) optional_group.add_argument( "--color", dest="color", help=('Specify a list of colors with one color per plot. Without' ' grouping there is one plot per replicate. With grouping there' ' is one plot per group: --color \'#CC0011[,#FF8800]\'')) optional_group.add_argument("--font-size", dest="font_size", default=8, help="Set the font size. Default: %(default)s") optional_group.add_argument( "--hide-number", dest="hide_number", action="store_true", help='Do not display the read count on the junctions') optional_group.add_argument( "--no-text-background", dest="text_background", action="store_false", help='Do not put a white box behind the junction read count') optional_group.add_argument( "--keep-event-chr-prefix", action="store_true", help='force the contig name in the provided events file to be used') optional_group.add_argument( "--remove-event-chr-prefix", action="store_true", help=('remove any leading "chr" from contig names in the provided' ' events file')) options = parser.parse_args() out_path = os.path.abspath(os.path.expanduser(options.out_dir)) checkout(parser, options) # 0.check out the arguments sashimi_path = os.path.join(out_path, "Sashimi_index") if not os.path.isdir(sashimi_path): os.makedirs(sashimi_path) options.out_dir = out_path options.sashimi_path = sashimi_path prepare_bams(options) # 1.convert sam to bam format if options.events_file is None: # 2.setting and plot plot_with_coordinate(options) else: plot_with_eventsfile(options) if __name__ == '__main__': main()
Xinglab/rmats2sashimiplot
src/rmats2sashimiplot/rmats2sashimiplot.py
Python
gpl-2.0
44,567
[ "pysam" ]
b6ed489b9d42159885bcef87864018bdfaeaa6870e3235945af1c653ce063d39
# ---------------------------------------------------------------------- # Copyright (c) 2016, The Regents of the University of California All # rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # # * Neither the name of The Regents of the University of California # nor the names of its contributors may be used to endorse or # promote products derived from this software without specific # prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE # UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. # ---------------------------------------------------------------------- # Filename: QDR.py # Version: 0.1 # Description: Object that defines a QDR Memory Instance/Interface in a Board # architecture # Author: Dustin Richmond import Tinker, Phy import xml.etree.ElementTree as ET from IP import parse_int class QDR(Phy.Phy): _C_BURST_WIDTHS = range(1,5) _C_BURST_DEFAULT = 4 _C_CLOCK_RATIOS = set(["Half", "Full"]) _C_RATE = 2 # Double Data Rate (Not Quad. Thanks, Marketing) def __init__(self, e): super(QDR,self).__init__(e) @classmethod def validate(cls, d): """ Validate the parameters that describe the intrinsic settings of this IP Arguments: d -- A Description object, containing the parsed user description of a custom board """ d = super(QDR,cls).validate(d) return def parse(self,e): """ Parse the description of this IP object from an element tree element and return a dictionary with the parameters found. Arguments: e -- An element tree element containing the description of this object """ d = super(QDR,self).parse(e) d["type"] = "QDRII" pow2_dq_pins = d["pow2_dq_pins"] address_pins = parse_int(e, "address_pins") phyburst = parse_int(e, "phyburst") size = pow2_dq_pins/8 * (2**address_pins) * phyburst d["size"] = int(size) return d def get_interface_element(self, sid, version, verbose): self.validate(self) e = super(QDR,self).get_interface_element(sid, version, verbose) e.set("size", str(hex(self["size"]))) ra = {"name":"kernel_%s_if_%s_r" % (sid, self["id"]), "direction":"r"} re = ET.Element("port",attrib=ra) e.append(re) wa = {"name":"kernel_%s_if_%s_w" % (sid, self["id"]), "direction":"w"} we = ET.Element("port",attrib=wa) e.append(we) return e
drichmond/tinker
python/QDR.py
Python
bsd-3-clause
3,773
[ "TINKER" ]
a3eaf3efbb037f0f3a10972346dc7ab86668853d17ff61af14c4d9bc83d46692
### Script calculates probability as area under a normal gaussian curve, ### given inputs of x1, x2, mu (mean), sigma(standard deviation) and computes ### the probabability using the integral function and the gaussian curve. from math import sqrt,erf ## If plotting as well #import matplotlib.pyplot as plt #import numpy as np ### *** Change the following inputs *** ### mu= 979.8 # mean of the sample sigma= 73.1 # standard deviation of the sample x1= 900 # lower x, use -float('inf') for negative infinity x2= 1100 # upper x, use float('inf') for infinity ############################################ # Probability from 0 to upper double_prob = erf( (x1-mu) / (sigma*sqrt(2)) ) Plower = double_prob/2 #print('\n' + str(Plower)) # Probability from lower to 0 double_prob = erf( (x2-mu) / (sigma*sqrt(2)) ) Pupper = double_prob/2 #print('\n'+ str(Pupper)) Pin=Pupper-Plower print('\n') print('mean = %.2f std dev = %.2f \n' % (mu,sigma)) print('Calculating probability of occuring between %.4f <--> %.4f \n' % (x1,x2)) print('inside interval Pin = %.2f%% \n' % (Pin*100)) print('outside interval Pout = %.2f%% \n' % ((1-Pin)*100)) print('\n')
ProfessorKazarinoff/staticsite
content/code/statistics/area_under_normal_curve.py
Python
gpl-3.0
1,147
[ "Gaussian" ]
47c92b165fcf267efd879f63f2a64d6f4e3e8020523f5aa2700df88770abe980
#!/usr/bin/env python # megamapper intersector # by Nikolaus Obholzer, Jan 2012 import sys, re, tempfile, subprocess import os, shutil #import pkg_resources; pkg_resources.require( "bx-python" ) #from bx.cookbook import doc_optparse from galaxy import eggs def stop_err(msg): sys.stderr.write(msg) sys.exit() def main(): # Handle input params in_fname1 = sys.argv[1] in_fname2 = sys.argv[2] out_file1 = sys.argv[3] rscript_path = '/export/local_tools/MegaMapper/candidator.R' try: #prepare command line # print os.getcwd() cmd = 'Rscript --vanilla %s %s %s %s' %(rscript_path, in_fname1, in_fname2, out_file1 ) # print cmd # for debugging os.system(cmd) # subprocess.Popen(args=cmd, shell=True).wait finally: # check that there are results in the output file if os.path.getsize( out_file1 ) >= 0: sys.stdout.write( 'Candidate list compiled.' ) else: stop_err( 'The output file is empty. Your input file may not have had SNPs, or there may be an error with your input file or settings.' ) if __name__ == "__main__": main()
maxplanck-ie/Megamapper
candidator.py
Python
bsd-3-clause
1,163
[ "Galaxy" ]
e54da51ea92e27d654a558c84d07a80ad334308dd42c3f1da6d0137342cb697f
import time import numpy as np from ase.transport.tools import dagger from ase.transport.selfenergy import LeadSelfEnergy from ase.transport.greenfunction import GreenFunction from ase.parallel import world class STM: def __init__(self, h1, s1, h2, s2 ,h10, s10, h20, s20, eta1, eta2, w=0.5, pdos=[], logfile = None): """XXX 1. Tip 2. Surface h1: ndarray Hamiltonian and overlap matrix for the isolated tip calculation. Note, h1 should contain (at least) one principal layer. h2: ndarray Same as h1 but for the surface. h10: ndarray periodic part of the tip. must include two and only two principal layers. h20: ndarray same as h10, but for the surface The s* are the corresponding overlap matrices. eta1, and eta 2 are (finite) infinitesimals. """ self.pl1 = len(h10) // 2 #principal layer size for the tip self.pl2 = len(h20) // 2 #principal layer size for the surface self.h1 = h1 self.s1 = s1 self.h2 = h2 self.s2 = s2 self.h10 = h10 self.s10 = s10 self.h20 = h20 self.s20 = s20 self.eta1 = eta1 self.eta2 = eta2 self.w = w #asymmetry of the applied bias (0.5=>symmetric) self.pdos = [] self.log = logfile def initialize(self, energies, bias=0): """ energies: list of energies for which the transmission function should be evaluated. bias. Will precalculate the surface greenfunctions of the tip and surface. """ self.bias = bias self.energies = energies nenergies = len(energies) pl1, pl2 = self.pl1, self.pl2 nbf1, nbf2 = len(self.h1), len(self.h2) #periodic part of the tip hs1_dii = self.h10[:pl1, :pl1], self.s10[:pl1, :pl1] hs1_dij = self.h10[:pl1, pl1:2*pl1], self.s10[:pl1, pl1:2*pl1] #coupling betwen per. and non. per part of the tip h1_im = np.zeros((pl1, nbf1), complex) s1_im = np.zeros((pl1, nbf1), complex) h1_im[:pl1, :pl1], s1_im[:pl1, :pl1] = hs1_dij hs1_dim = [h1_im, s1_im] #periodic part the surface hs2_dii = self.h20[:pl2, :pl2], self.s20[:pl2, :pl2] hs2_dij = self.h20[pl2:2*pl2, :pl2], self.s20[pl2:2*pl2, :pl2] #coupling betwen per. and non. per part of the surface h2_im = np.zeros((pl2, nbf2), complex) s2_im = np.zeros((pl2, nbf2), complex) h2_im[-pl2:, -pl2:], s2_im[-pl2:, -pl2:] = hs2_dij hs2_dim = [h2_im, s2_im] #tip and surface greenfunction self.selfenergy1 = LeadSelfEnergy(hs1_dii, hs1_dij, hs1_dim, self.eta1) self.selfenergy2 = LeadSelfEnergy(hs2_dii, hs2_dij, hs2_dim, self.eta2) self.greenfunction1 = GreenFunction(self.h1-self.bias*self.w*self.s1, self.s1, [self.selfenergy1], self.eta1) self.greenfunction2 = GreenFunction(self.h2-self.bias*(self.w-1)*self.s2, self.s2, [self.selfenergy2], self.eta2) #Shift the bands due to the bias. bias_shift1 = -bias * self.w bias_shift2 = -bias * (self.w - 1) self.selfenergy1.set_bias(bias_shift1) self.selfenergy2.set_bias(bias_shift2) #tip and surface greenfunction matrices. nbf1_small = nbf1 #XXX Change this for efficiency in the future nbf2_small = nbf2 #XXX -||- coupling_list1 = list(range(nbf1_small))# XXX -||- coupling_list2 = list(range(nbf2_small))# XXX -||- self.gft1_emm = np.zeros((nenergies, nbf1_small, nbf1_small), complex) self.gft2_emm = np.zeros((nenergies, nbf2_small, nbf2_small), complex) for e, energy in enumerate(self.energies): if self.log != None: # and world.rank == 0: T = time.localtime() self.log.write(' %d:%02d:%02d, ' % (T[3], T[4], T[5]) + '%d, %d, %02f\n' % (world.rank, e, energy)) gft1_mm = self.greenfunction1.retarded(energy)[coupling_list1] gft1_mm = np.take(gft1_mm, coupling_list1, axis=1) gft2_mm = self.greenfunction2.retarded(energy)[coupling_list2] gft2_mm = np.take(gft2_mm, coupling_list2, axis=1) self.gft1_emm[e] = gft1_mm self.gft2_emm[e] = gft2_mm if self.log != None and world.rank == 0: self.log.flush() def get_transmission(self, v_12, v_11_2=None, v_22_1=None): """XXX v_12: coupling between tip and surface v_11_2: correction to "on-site" tip elements due to the surface (eq.16). Is only included to first order. v_22_1: corretion to "on-site" surface elements due to he tip (eq.17). Is only included to first order. """ dim0 = v_12.shape[0] dim1 = v_12.shape[1] nenergies = len(self.energies) T_e = np.empty(nenergies,float) v_21 = dagger(v_12) for e, energy in enumerate(self.energies): gft1 = self.gft1_emm[e] if v_11_2!=None: gf1 = np.dot(v_11_2, np.dot(gft1, v_11_2)) gf1 += gft1 #eq. 16 else: gf1 = gft1 gft2 = self.gft2_emm[e] if v_22_1!=None: gf2 = np.dot(v_22_1,np.dot(gft2, v_22_1)) gf2 += gft2 #eq. 17 else: gf2 = gft2 a1 = (gf1 - dagger(gf1)) a2 = (gf2 - dagger(gf2)) self.v_12 = v_12 self.a2 = a2 self.v_21 = v_21 self.a1 = a1 v12_a2 = np.dot(v_12, a2[:dim1]) v21_a1 = np.dot(v_21, a1[-dim0:]) self.v12_a2 = v12_a2 self.v21_a1 = v21_a1 T = -np.trace(np.dot(v12_a2[:,:dim1], v21_a1[:,-dim0:])) #eq. 11 assert abs(T.imag).max() < 1e-14 T_e[e] = T.real self.T_e = T_e return T_e def get_current(self, bias, v_12, v_11_2=None, v_22_1=None): """Very simple function to calculate the current. Asummes zero temperature. bias: type? XXX bias voltage (V) v_12: XXX coupling between tip and surface. v_11_2: correction to onsite elements of the tip due to the potential of the surface. v_22_1: correction to onsite elements of the surface due to the potential of the tip. """ energies = self.energies T_e = self.get_transmission(v_12, v_11_2, v_22_1) bias_window = sorted(-np.array([bias * self.w, bias * (self.w - 1)])) self.bias_window = bias_window #print 'bias window', np.around(bias_window,3) #print 'Shift of tip lead do to the bias:', self.selfenergy1.bias #print 'Shift of surface lead do to the bias:', self.selfenergy2.bias i1 = sum(energies < bias_window[0]) i2 = sum(energies < bias_window[1]) step = 1 if i2 < i1: step = -1 return np.sign(bias)*np.trapz(x=energies[i1:i2:step], y=T_e[i1:i2:step])
suttond/MODOI
ase/transport/stm.py
Python
lgpl-3.0
7,518
[ "ASE" ]
557f4bb7671409d2992177d2629f4584f3b1f64897bfd6c08e21769e8745ef69
# (c) 2014, Brian Coca <bcoca@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import import math import collections from ansible import errors def unique(a): if isinstance(a,collections.Hashable): c = set(a) else: c = [] for x in a: if x not in c: c.append(x) return c def intersect(a, b): if isinstance(a,collections.Hashable) and isinstance(b,collections.Hashable): c = set(a) & set(b) else: c = unique(filter(lambda x: x in b, a)) return c def difference(a, b): if isinstance(a,collections.Hashable) and isinstance(b,collections.Hashable): c = set(a) - set(b) else: c = unique(filter(lambda x: x not in b, a)) return c def symmetric_difference(a, b): if isinstance(a,collections.Hashable) and isinstance(b,collections.Hashable): c = set(a) ^ set(b) else: c = unique(filter(lambda x: x not in intersect(a,b), union(a,b))) return c def union(a, b): if isinstance(a,collections.Hashable) and isinstance(b,collections.Hashable): c = set(a) | set(b) else: c = unique(a + b) return c def min(a): _min = __builtins__.get('min') return _min(a); def max(a): _max = __builtins__.get('max') return _max(a); def isnotanumber(x): try: return math.isnan(x) except TypeError: return False def logarithm(x, base=math.e): try: if base == 10: return math.log10(x) else: return math.log(x, base) except TypeError, e: raise errors.AnsibleFilterError('log() can only be used on numbers: %s' % str(e)) def power(x, y): try: return math.pow(x, y) except TypeError, e: raise errors.AnsibleFilterError('pow() can only be used on numbers: %s' % str(e)) def inversepower(x, base=2): try: if base == 2: return math.sqrt(x) else: return math.pow(x, 1.0/float(base)) except TypeError, e: raise errors.AnsibleFilterError('root() can only be used on numbers: %s' % str(e)) class FilterModule(object): ''' Ansible math jinja2 filters ''' def filters(self): return { # general math 'isnan': isnotanumber, 'min' : min, 'max' : max, # exponents and logarithms 'log': logarithm, 'pow': power, 'root': inversepower, # set theory 'unique' : unique, 'intersect': intersect, 'difference': difference, 'symmetric_difference': symmetric_difference, 'union': union, }
shakamunyi/ansible
v2/ansible/plugins/filter/mathstuff.py
Python
gpl-3.0
3,344
[ "Brian" ]
e9c8c07c3cf193b8b8d47726e49fa0c355ff44332d2e803522c3535a53c2bba7
from unittest import TestCase from docclass import Classifier from docclass import getwords __author__ = 'maria' class TestGetwords(TestCase): def testGetFeatures(self): c = Classifier(getwords) dict = c.getfeatures("Hello World world world , hello has cats and vervyveryveryveryveryverylongword") self.assertIsNotNone(dict) self.assertIsNotNone(dict["hello"]) self.assertEqual(dict["hello"], 1) self.assertFalse(dict.has_key("has")) self.assertFalse(dict.has_key("vervyveryveryveryveryverylongword")) def testIncF(self): c = Classifier(getwords) c.incf("hello", "Good") self.assertEqual(c.fc["hello"]["Good"], 1) c.incf("hello", "Good") self.assertEqual(c.fc["hello"]["Good"], 2) c.incf("hello", "Bad") self.assertEqual(c.fc["hello"]["Bad"], 1) def testIncC(self): c = Classifier(getwords) c.incc("Bad") self.assertEqual(c.cc["Bad"], 1) c.incc("Bad") self.assertEqual(c.cc["Bad"], 2) c.incc("Good") self.assertEqual(c.cc["Good"], 1) def testFCount(self): c = Classifier(getwords) c.incf("hello", "Good") c.incf("hello", "Good") c.incf("hello", "Bad") self.assertEqual(c.fcount("hello", "Good"), 2) self.assertEqual(c.fcount("hello", "Bad"), 1) self.assertEqual(c.fcount("wurst", "Bad"), 0) def testCatCount(self): c = Classifier(getwords) c.incc("Bad") c.incc("Bad") c.incc("Good") self.assertEqual(c.catcount("Good"), 1) self.assertEqual(c.catcount("Bad"), 2) def testTotalCount(self): c = Classifier(getwords) c.incc("Bad") c.incc("Bad") c.incc("Good") self.assertEqual(c.totalcount(), 3) def testTrain(self): c = Classifier(getwords) item = "Hello hello world, my name is Python." cat = "Good" c.train(item, cat) self.assertEqual(c.catcount("Good"), 1) self.assertEqual(c.fcount("hello", "Good"), 1) self.assertFalse(c.fc.has_key("my")) def testFProb(self): c = Classifier(getwords) c.incc("Good") c.incf("hello", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Good") c.incf("world", "Good") self.assertEqual(c.fprob("world", "Good"), 2.0/3.0) def testWeightedProb(self): c = Classifier(getwords) c.incc("Good") c.incf("hello", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Bad") c.incf("world", "Bad") self.assertEqual(c.weightedprob("world", "Good"), 5.0/8.0) self.assertEqual(c.weightedprob("wurst", "Good"), 0.5) def testProb(self): c = Classifier(getwords) # training c.incc("Good") c.incf("hello", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Bad") c.incf("world", "Bad") # classify new document item = "world world wurst Wurst wurst world" self.assertEqual(c.prob(item, "Good"), 0.234375) def testClassifier(self): c = Classifier(getwords) c.train("nobody owns the water", "Good") c.train("the quick rabbit jumps fences", "Good") c.train("buy pharmaceuticals now", "Bad") c.train("make quick money at the online casino", "Bad") c.train("the quick brown fox jumps", "Good") c.train("next meeting is at night", "Good") c.train("meeting with your superstar", "Bad") c.train("money like water", "Bad") # added quick to the test string, because with 'money jumps' Good and Bad got the same value. self.assertEqual(c.classify("the money jumps quick"), "Good")
stefanseibert/DataMining
experiment03/scripts/test_classifier.py
Python
mit
3,957
[ "CASINO" ]
7a91ece01600c680fcb7ea1a052cf147cec5938f0d919472058480c101cce064
#!/usr/bin/env python # # Author: Qiming Sun <osirpt.sun@gmail.com> # ''' Using solvent model in the CCSD calculations. When applying solvent model, this example has convergence issue. ''' from pyscf import gto, scf, cc from pyscf import solvent mol = gto.M(atom=''' C 0.000000 0.000000 -0.542500 O 0.000000 0.000000 0.677500 H 0.000000 0.9353074360871938 -1.082500 H 0.000000 -0.9353074360871938 -1.082500 ''', basis='ccpvdz', verbose=3) mf = scf.RHF(mol).run() # # 1. Allow solvent response to CASSCF optimization # mycc = solvent.ddCOSMO(cc.CCSD(mf)) # Adjust solvent model by modifying the attribute .with_solvent mycc.with_solvent.eps = 32.613 # methanol dielectric constant mycc.run() # # Freeze solvent effects in the CASSCF optimization # # In this case, we need to decide which HF reference to use in the ddCOSMO-CC # calculation. The fully relaxed solvent at HF level is preferred. # mf = solvent.ddCOSMO(scf.RHF(mol)).run() # By passing density to solvent model, the solvent potential is frozen at the # HF level. mycc = solvent.ddCOSMO(cc.CCSD(mf), dm=mf.make_rdm1()) mycc.run()
gkc1000/pyscf
examples/solvent/03-ccsd_with_ddcosmo.py
Python
apache-2.0
1,201
[ "PySCF" ]
bebfc1b0de9e4e0ef1b5886b8f795e9109fd14ff29efb7249af52095e4b0bbed
#! /usr/bin/env python """ metaHGT (meta-community Horizontal Gene Transfer tracker): in-situ and real time HGT tracker for series metagenomes Copyright(c) 2013 Chengwei Luo (luo.chengwei@gatech.edu) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> https://github.com/luo-chengwei/metaHGT for help, type: python metaHGT.py --help """ import sys import os import re import pysam import math from scipy import stats import numpy as np from scipy.stats import norm from itertools import product from operator import itemgetter, attrgetter class Span: def __init__(self): self.reference = None self.left = 0 self.right = 0 class BreakPoint: def __init__(self): self.reference = None self.direction = '>' self.loc = 0 class HGT: def __init__(self): self.genome_a = None self.genome_b = None self.reference_a = None self.reference_b = None self.breakpoint_a = BreakPoint() self.breakpoint_b = BreakPoint() self.percentage_a = 0. self.percentage_b = 0. self.pvalue = 1. self.adj_pvalue = 1. def printHGT(self): sys.stdout.write('%s\t%s\t%i\t%s\t%s\t%s\t%i\t%s\t' % (self.genome_a, self.reference_a, \ self.breakpoint_a.loc, self.breakpoint_a.direction, self.genome_b, \ self.reference_b, self.breakpoint_b.loc, self.breakpoint_b.direction)) sys.stdout.write('%.4f\t%.4f\t%.4f\t%.4f\n' % (self.percentage_a, self.percentage_b, \ self.pvalue, self.adj_pvalue)) def strHGT(self): return '%s\t%s\t%i\t%s\t%s\t%s\t%i\t%s\t%.4f\t%.4f\t%.4f\t%.4f' % (self.genome_a, self.reference_a, \ self.breakpoint_a.loc, self.breakpoint_a.direction, self.genome_b, \ self.reference_b, self.breakpoint_b.loc, self.breakpoint_b.direction, \ self.percentage_a, self.percentage_b, self.pvalue, self.adj_pvalue) def BH_correction(HGTs): m = len(HGTs) sorted_HGTs = sorted(HGTs, key = lambda x: x.pvalue) for k, x in enumerate(sorted_HGTs): sorted_HGTs[k].adj_pvalue = min(1., x.pvalue * (float(m)/(k+1))) return sorted_HGTs # End of BH_correction def GtoP(g,df): return 1-stats.chi2.cdf(g, df) # End of GtoP def flnf(f): return f*math.log(f) if f >0.5 else 0 # End of flnf def gtest(table): a, b, c, d = table row1 = a+b row2 = c+d col1 = a+c col2 = b+d total = flnf(a+b+c+d) celltotals = flnf(a)+flnf(b)+flnf(c)+flnf(d) rowtotals = flnf(row1)+flnf(row2) coltotals = flnf(col1)+flnf(col2) gscore = 2*(celltotals + total-(rowtotals+coltotals)) return GtoP(gscore, 1) # return gscore # End of gtest def estimate_library(bamfh, ref_length, projInfo): # library size estimate library_sizes = [] size_limit = 1e5 for reference in ref_length: length = ref_length[reference] if length < projInfo.contig_length: continue try: reads = bamfh.fetch(reference) except ValueError: continue for read in reads: if read.mapq < projInfo.mapq: continue if float(read.alen)/read.rlen < projInfo.align_perc: continue if read.tid == read.mrnm and (read.is_reverse ^ read.mate_is_reverse): library_sizes.append(abs(read.pos - read.mpos) + 1+ read.rlen) if len(library_sizes) > size_limit: break mean = np.mean(np.array(library_sizes)) std = np.std(np.array(library_sizes)) return mean, std # End of estimate_library def infer_breakpoint(reference, reads10): bk = BreakPoint() bk.reference = reference positions = [] for read in reads10: if read.is_secondary or read.mapq < 30: continue if read.tid == read.mrnm: continue if read.is_read1 and not read.is_reverse: positions.append((read.pos + read.qlen, '>')) elif read.is_read1 and read.is_reverse: positions.append((read.pos, '<')) elif read.is_read2 and not read.is_reverse: positions.append((read.pos + read.qlen, '>')) elif read.is_read2 and read.is_reverse: positions.append((read.pos, '<')) dir = map(itemgetter(1), positions) pos = map(itemgetter(0), positions) if dir.count('>') > dir.count('<') and dir.count('<') <= 1: bk.direction = '>' bk.loc = max(pos) elif dir.count('>') < dir.count('<') and dir.count('>') <= 1: bk.direction = '<' bk.loc = min(pos) else: return None return bk # End of infer_breakpoint def test_HGT(mappings0, breakpoint_a, mappings1, breakpoint_b): # init basic parameters ref0_self = [0, 0, 0, 0] ref1_self = [0, 0, 0, 0] crossing0 = [0, 0, 0, 0] crossing1 = [0, 0, 0, 0] # render ref0 for index, mapping in enumerate(mappings0): for read in mapping: if read.mapq < 30 or read.is_secondary: continue if read.tid == read.mrnm: if read.pos < read.pnext: start, end = read.pos, read.pnext else: start, end = read.pnext, read.pos if start <= breakpoint_a.loc and end >= breakpoint_a.loc: ref0_self[index] += 1 else: continue else: if breakpoint_a.direction == '>': if read.pos <= breakpoint_a.loc and not read.is_reverse: crossing0[index] += 1 elif breakpoint_a.direction == '<': if read.pos >= breakpoint_a.loc and read.is_reverse: crossing0[index] += 1 # render ref1 for index, mapping in enumerate(mappings1): for read in mapping: if read.mapq < 30 or read.is_secondary: continue if read.tid == read.mrnm: if read.pos < read.pnext: start, end = read.pos, read.pnext else: start, end = read.pnext, read.pos if start <= breakpoint_b.loc and end >= breakpoint_b.loc: ref1_self[index] += 1 else: continue else: if breakpoint_b.direction == '>': if read.pos <= breakpoint_b.loc and not read.is_reverse: crossing1[index] += 1 elif breakpoint_b.direction == '<': if read.pos >= breakpoint_b.loc and read.is_reverse: crossing1[index] += 1 # perform hypothesis testing if ref0_self[-1] + crossing0[-1] > 0: percentage_a = (100. * crossing0[-1]) / (ref0_self[-1] + crossing0[-1]) else: percentage_a = None if ref1_self[-1] + crossing1[-1] > 0: percentage_b = (100. * crossing1[-1]) / (ref1_self[-1] + crossing1[-1]) else: percentage_b = None # first need to satisfy that self-mapping has no crossing if sum([crossing0[0], crossing1[0]]) > 0: return None, None, None table = [ref0_self[0] + ref1_self[0], crossing0[0] + crossing1[0], ref0_self[-1] + ref1_self[-1], crossing0[-1] + crossing1[-1]] pvalue = gtest(table) return pvalue, percentage_a, percentage_b # End of test_HGT def infer_HGT(spans0, spans1, bamfhs): # bamfhs order: 00, 11, 01, 10 HGTs = [] for span0, span1 in product(spans0, spans1): try: ref0_reads10 = bamfhs[3].fetch(span0.reference, span0.left, span0.right) ref1_reads10 = bamfhs[3].fetch(span1.reference, span1.left, span1.right) except ValueError: continue breakpoint0 = infer_breakpoint(span0.reference, ref0_reads10) breakpoint1 = infer_breakpoint(span1.reference, ref1_reads10) if breakpoint0 == None or breakpoint1 == None: continue e = HGT() e.genome_a = span0.genome e.genome_b = span1.genome e.reference_a = span0.reference e.reference_b = span1.reference e.breakpoint_a = breakpoint0 e.breakpoint_b = breakpoint1 try: ref0_reads00 = bamfhs[0].fetch(span0.reference, span0.left, span0.right) ref0_reads11 = bamfhs[1].fetch(span0.reference, span0.left, span0.right) ref0_reads01 = bamfhs[2].fetch(span0.reference, span0.left, span0.right) ref0_reads10 = bamfhs[3].fetch(span0.reference, span0.left, span0.right) ref0_mappings = [ref0_reads00, ref0_reads11, ref0_reads01, ref0_reads10] ref1_reads00 = bamfhs[0].fetch(span1.reference, span1.left, span1.right) ref1_reads11 = bamfhs[1].fetch(span1.reference, span1.left, span1.right) ref1_reads01 = bamfhs[2].fetch(span1.reference, span1.left, span1.right) ref1_reads10 = bamfhs[3].fetch(span1.reference, span1.left, span1.right) ref1_mappings = [ref1_reads00, ref1_reads11, ref1_reads01, ref1_reads10] except ValueError: continue pvalue, percentage_a, percentage_b = test_HGT(ref0_mappings, e.breakpoint_a, \ ref1_mappings, e.breakpoint_b) if percentage_a == None or percentage_b == None or pvalue == None: continue else: e.percentage_a = percentage_a e.percentage_b = percentage_b e.pvalue = pvalue HGTs.append(e) return HGTs # end of infer_HGT def HGT_search(lib_stats, bamfhs, projInfo): sampleIDs = {} for sample in projInfo.samples: for x in sample: sampleIDs[x] = 1 ## bamfhs: [bam00, bam11, bam01, bam10] references0 = bamfhs[0].references lengths0 = bamfhs[0].lengths refs0 = {} for ref, lgth in zip(references0, lengths0): refs0[ref] = lgth references1 = bamfhs[1].references lengths1 = bamfhs[1].lengths refs1 = {} for ref, lgth in zip(references1, lengths1): refs1[ref] = lgth mean0, std0 = lib_stats[0] mean1, std1 = lib_stats[1] G = {} # Graph that holds the hotspot candidates # scan for hotspot candidate if not projInfo.quiet: sys.stdout.write('Scanning for hotspots...\n') for read in bamfhs[3].fetch(until_eof = True): if read.mapq < projInfo.mapq: continue if float(read.alen)/read.rlen < projInfo.align_perc: continue if read.is_paired and not read.is_secondary: if read.mrnm == read.tid: continue if read.is_reverse: strand0 = '-' else: strand0 = '+' if read.mate_is_reverse: strand1 = '-' else: strand1 = '+' ref1 = bamfhs[3].getrname(read.mrnm) ref0 = bamfhs[3].getrname(read.tid) if ref0 not in refs0 or ref1 not in refs0: continue # length filter if refs0[ref0] < projInfo.contig_length or refs0[ref1] < projInfo.contig_length: continue (ref0, pos0, strand0), (ref1, pos1, strand1) = \ sorted([(ref0, read.pos, strand0), (ref1, read.mpos, strand1)], key = lambda x: x[0]) binID0 = re.search('(.+)\.contig\d+', ref0).group(1) binID1 = re.search('(.+)\.contig\d+', ref1).group(1) # cross bin filter if binID0 in sampleIDs or binID1 in sampleIDs or binID1 == binID0: continue if (binID0, binID1) not in G: G[(binID0, binID1)] = {} if (ref0, ref1) not in G[(binID0, binID1)]: G[(binID0, binID1)][(ref0, ref1)] = [] G[(binID0, binID1)][(ref0, ref1)].append((pos0, strand0, pos1, strand1)) # scan through all candidate hotspot and calculate new genotype # and corresponding percentage and p-value if not projInfo.quiet: sys.stdout.write('Calculating HGT precise locations and likelihood...\n') HGTs = [] for (binID0, binID1) in G: for (ref0, ref1) in G[(binID0, binID1)]: lgth0 = refs0[ref0] lgth1 = refs0[ref1] refined_positions = [] for index, (pos0, strand0, pos1, strand1) in enumerate(G[(binID0, binID1)][(ref0, ref1)]): if pos0 <= mean1 or pos0 >= lgth0 - mean1 or pos1 <= mean1 or pos1 >= lgth1 - mean1: continue refined_positions.append((pos0, strand0, pos1, strand1)) if len(refined_positions) < projInfo.min_links: continue span_links = [] sorted_refined_positions_0 = sorted(refined_positions, key = lambda x: x[0]) sorted_refined_positions_1 = sorted(refined_positions, key = lambda x: x[2]) ## get the spans in ref0 old_i = 0 total_ele = 0 link_groups = [] spans0 = [] for i in range(len(sorted_refined_positions_0) - 1): gap = sorted_refined_positions_0[i+1][0] - sorted_refined_positions_0[i][0] if gap > mean1 + std1: link_groups.append(sorted_refined_positions_0[old_i:i+1]) total_ele += len(sorted_refined_positions_0[old_i:i+1]) old_i = i+1 if total_ele < len(sorted_refined_positions_0): link_groups.append(sorted_refined_positions_0[old_i:]) for link_group in link_groups: s = Span() s.genome = binID0 s.reference = ref0 s.left = max(int(link_group[0][0] - mean1), 0) s.right = min(int(link_group[-1][0] + mean1), lgth0) spans0.append(s) ## get the spans in ref1 old_i = 0 total_ele = 0 link_groups = [] spans1 = [] for i in range(len(sorted_refined_positions_1) - 1): gap = sorted_refined_positions_1[i+1][2] - sorted_refined_positions_1[i][2] if gap > mean1 + std1: link_groups.append(sorted_refined_positions_1[old_i:i+1]) total_ele += len(sorted_refined_positions_1[old_i:i+1]) old_i = i+1 if total_ele < len(sorted_refined_positions_1): link_groups.append(sorted_refined_positions_1[old_i:]) for link_group in link_groups: s = Span() s.genome = binID1 s.reference = ref1 s.left = max(int(link_group[0][2] - mean1), 0) s.right = min(int(link_group[-1][2] + mean1), lgth1) spans1.append(s) ## examine between any combo of two spans results = infer_HGT(spans0, spans1, bamfhs) HGTs += results if not projInfo.quiet: sys.stdout.write('Done HGT inferences.\n') return HGTs # End of HGT_search def HGTscan(bamfhs, lib_stats, projInfo): # select hotspots and calculate HGT likelihood HGTs = HGT_search(lib_stats, bamfhs, projInfo) # FDR adjustment if not projInfo.quiet: sys.stdout.write('Correcting for FDR using Benjamini-Hochberg methods...\n') adj_HGTs = BH_correction(HGTs) return adj_HGTs # End of HGTscan def calHGT(projInfo): if not projInfo.quiet: sys.stdout.write('Now calculating HGT events...\n') all_HGTs = {} for timepair in projInfo.timepairs: if not projInfo.quiet: sys.stdout.write('[%s.vs.%s] Initiating...\n' % (timepair[0], timepair[1])) # get all the BAMs if not projInfo.quiet: sys.stdout.write('[%s.vs.%s] Interpreting BAMs...\n' % (timepair[0], timepair[1])) bamfile00, bamfile11, bamfile01, bamfile10 = projInfo.getBAMFiles(timepair[0], timepair[1]) # file handles bam00 = pysam.Samfile(bamfile00, 'rb') bam11 = pysam.Samfile(bamfile11, 'rb') bam01 = pysam.Samfile(bamfile01, 'rb') bam10 = pysam.Samfile(bamfile10, 'rb') bamfhs = [bam00, bam11, bam01, bam10] # estimate library size and std if not projInfo.quiet: sys.stdout.write('Now estimating the read library size...\n') refs0 = {} for ref, length in zip(bam00.references, bam00.lengths): refs0[ref] = length mean0, std0 = estimate_library(bam00, refs0, projInfo) if not projInfo.quiet: sys.stdout.write('[Library 1] mean +/- std: %.3f +/- %.3f\n' % (mean0, std0)) refs1 = {} for ref, length in zip(bam11.references, bam11.lengths): refs1[ref] = length mean1, std1 = estimate_library(bam11, refs1, projInfo) if not projInfo.quiet: sys.stdout.write('[Library 2] mean +/- std: %.3f +/- %.3f\n' % (mean1, std1)) lib_stats = [(mean0, std0), (mean1, std1)] # run HGT calculation HGTs = HGTscan(bamfhs, lib_stats, projInfo) for bfh in bamfhs: bfh.close() all_HGTs[timepair] = HGTs if not projInfo.quiet: sys.stdout.write('All HGT predication finished.\n') return all_HGTs
fw1121/metaHGT
src/calHGT.py
Python
gpl-3.0
15,394
[ "pysam" ]
b0294ebe877da0ba7a71df0548f70fca991a6ba629fccc97fb8fe4eaa87a0f62
from __future__ import division, absolute_import, print_function import os import sys import types import re from numpy.core.numerictypes import issubclass_, issubsctype, issubdtype from numpy.core import product, ndarray, ufunc, asarray __all__ = [ 'issubclass_', 'issubsctype', 'issubdtype', 'deprecate', 'deprecate_with_doc', 'get_include', 'info', 'source', 'who', 'lookfor', 'byte_bounds', 'safe_eval' ] def get_include(): """ Return the directory that contains the NumPy \\*.h header files. Extension modules that need to compile against NumPy should use this function to locate the appropriate include directory. Notes ----- When using ``distutils``, for example in ``setup.py``. :: import numpy as np ... Extension('extension_name', ... include_dirs=[np.get_include()]) ... """ import numpy if numpy.show_config is None: # running from numpy source directory d = os.path.join(os.path.dirname(numpy.__file__), 'core', 'include') else: # using installed numpy core headers import numpy.core as core d = os.path.join(os.path.dirname(core.__file__), 'include') return d def _set_function_name(func, name): func.__name__ = name return func class _Deprecate(object): """ Decorator class to deprecate old functions. Refer to `deprecate` for details. See Also -------- deprecate """ def __init__(self, old_name=None, new_name=None, message=None): self.old_name = old_name self.new_name = new_name self.message = message def __call__(self, func, *args, **kwargs): """ Decorator call. Refer to ``decorate``. """ old_name = self.old_name new_name = self.new_name message = self.message import warnings if old_name is None: try: old_name = func.__name__ except AttributeError: old_name = func.__name__ if new_name is None: depdoc = "`%s` is deprecated!" % old_name else: depdoc = "`%s` is deprecated, use `%s` instead!" % \ (old_name, new_name) if message is not None: depdoc += "\n" + message def newfunc(*args,**kwds): """`arrayrange` is deprecated, use `arange` instead!""" warnings.warn(depdoc, DeprecationWarning) return func(*args, **kwds) newfunc = _set_function_name(newfunc, old_name) doc = func.__doc__ if doc is None: doc = depdoc else: doc = '\n\n'.join([depdoc, doc]) newfunc.__doc__ = doc try: d = func.__dict__ except AttributeError: pass else: newfunc.__dict__.update(d) return newfunc def deprecate(*args, **kwargs): """ Issues a DeprecationWarning, adds warning to `old_name`'s docstring, rebinds ``old_name.__name__`` and returns the new function object. This function may also be used as a decorator. Parameters ---------- func : function The function to be deprecated. old_name : str, optional The name of the function to be deprecated. Default is None, in which case the name of `func` is used. new_name : str, optional The new name for the function. Default is None, in which case the deprecation message is that `old_name` is deprecated. If given, the deprecation message is that `old_name` is deprecated and `new_name` should be used instead. message : str, optional Additional explanation of the deprecation. Displayed in the docstring after the warning. Returns ------- old_func : function The deprecated function. Examples -------- Note that ``olduint`` returns a value after printing Deprecation Warning: >>> olduint = np.deprecate(np.uint) >>> olduint(6) /usr/lib/python2.5/site-packages/numpy/lib/utils.py:114: DeprecationWarning: uint32 is deprecated warnings.warn(str1, DeprecationWarning) 6 """ # Deprecate may be run as a function or as a decorator # If run as a function, we initialise the decorator class # and execute its __call__ method. if args: fn = args[0] args = args[1:] # backward compatibility -- can be removed # after next release if 'newname' in kwargs: kwargs['new_name'] = kwargs.pop('newname') if 'oldname' in kwargs: kwargs['old_name'] = kwargs.pop('oldname') return _Deprecate(*args, **kwargs)(fn) else: return _Deprecate(*args, **kwargs) deprecate_with_doc = lambda msg: _Deprecate(message=msg) #-------------------------------------------- # Determine if two arrays can share memory #-------------------------------------------- def byte_bounds(a): """ Returns pointers to the end-points of an array. Parameters ---------- a : ndarray Input array. It must conform to the Python-side of the array interface. Returns ------- (low, high) : tuple of 2 integers The first integer is the first byte of the array, the second integer is just past the last byte of the array. If `a` is not contiguous it will not use every byte between the (`low`, `high`) values. Examples -------- >>> I = np.eye(2, dtype='f'); I.dtype dtype('float32') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True >>> I = np.eye(2, dtype='G'); I.dtype dtype('complex192') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True """ ai = a.__array_interface__ a_data = ai['data'][0] astrides = ai['strides'] ashape = ai['shape'] bytes_a = asarray(a).dtype.itemsize a_low = a_high = a_data if astrides is None: # contiguous case a_high += a.size * bytes_a else: for shape, stride in zip(ashape, astrides): if stride < 0: a_low += (shape-1)*stride else: a_high += (shape-1)*stride a_high += bytes_a return a_low, a_high #----------------------------------------------------------------------------- # Function for output and information on the variables used. #----------------------------------------------------------------------------- def who(vardict=None): """ Print the Numpy arrays in the given dictionary. If there is no dictionary passed in or `vardict` is None then returns Numpy arrays in the globals() dictionary (all Numpy arrays in the namespace). Parameters ---------- vardict : dict, optional A dictionary possibly containing ndarrays. Default is globals(). Returns ------- out : None Returns 'None'. Notes ----- Prints out the name, shape, bytes and type of all of the ndarrays present in `vardict`. Examples -------- >>> a = np.arange(10) >>> b = np.ones(20) >>> np.who() Name Shape Bytes Type =========================================================== a 10 40 int32 b 20 160 float64 Upper bound on total bytes = 200 >>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str', ... 'idx':5} >>> np.who(d) Name Shape Bytes Type =========================================================== y 3 24 float64 x 2 16 float64 Upper bound on total bytes = 40 """ if vardict is None: frame = sys._getframe().f_back vardict = frame.f_globals sta = [] cache = {} for name in vardict.keys(): if isinstance(vardict[name], ndarray): var = vardict[name] idv = id(var) if idv in cache.keys(): namestr = name + " (%s)" % cache[idv] original=0 else: cache[idv] = name namestr = name original=1 shapestr = " x ".join(map(str, var.shape)) bytestr = str(var.nbytes) sta.append([namestr, shapestr, bytestr, var.dtype.name, original]) maxname = 0 maxshape = 0 maxbyte = 0 totalbytes = 0 for k in range(len(sta)): val = sta[k] if maxname < len(val[0]): maxname = len(val[0]) if maxshape < len(val[1]): maxshape = len(val[1]) if maxbyte < len(val[2]): maxbyte = len(val[2]) if val[4]: totalbytes += int(val[2]) if len(sta) > 0: sp1 = max(10, maxname) sp2 = max(10, maxshape) sp3 = max(10, maxbyte) prval = "Name %s Shape %s Bytes %s Type" % (sp1*' ', sp2*' ', sp3*' ') print(prval + "\n" + "="*(len(prval)+5) + "\n") for k in range(len(sta)): val = sta[k] print("%s %s %s %s %s %s %s" % (val[0], ' '*(sp1-len(val[0])+4), val[1], ' '*(sp2-len(val[1])+5), val[2], ' '*(sp3-len(val[2])+5), val[3])) print("\nUpper bound on total bytes = %d" % totalbytes) return #----------------------------------------------------------------------------- # NOTE: pydoc defines a help function which works simliarly to this # except it uses a pager to take over the screen. # combine name and arguments and split to multiple lines of # width characters. End lines on a comma and begin argument list # indented with the rest of the arguments. def _split_line(name, arguments, width): firstwidth = len(name) k = firstwidth newstr = name sepstr = ", " arglist = arguments.split(sepstr) for argument in arglist: if k == firstwidth: addstr = "" else: addstr = sepstr k = k + len(argument) + len(addstr) if k > width: k = firstwidth + 1 + len(argument) newstr = newstr + ",\n" + " "*(firstwidth+2) + argument else: newstr = newstr + addstr + argument return newstr _namedict = None _dictlist = None # Traverse all module directories underneath globals # to see if something is defined def _makenamedict(module='numpy'): module = __import__(module, globals(), locals(), []) thedict = {module.__name__:module.__dict__} dictlist = [module.__name__] totraverse = [module.__dict__] while True: if len(totraverse) == 0: break thisdict = totraverse.pop(0) for x in thisdict.keys(): if isinstance(thisdict[x], types.ModuleType): modname = thisdict[x].__name__ if modname not in dictlist: moddict = thisdict[x].__dict__ dictlist.append(modname) totraverse.append(moddict) thedict[modname] = moddict return thedict, dictlist def _info(obj, output=sys.stdout): """Provide information about ndarray obj. Parameters ---------- obj: ndarray Must be ndarray, not checked. output: Where printed output goes. Notes ----- Copied over from the numarray module prior to its removal. Adapted somewhat as only numpy is an option now. Called by info. """ extra = "" tic = "" bp = lambda x: x cls = getattr(obj, '__class__', type(obj)) nm = getattr(cls, '__name__', cls) strides = obj.strides endian = obj.dtype.byteorder print("class: ", nm, file=output) print("shape: ", obj.shape, file=output) print("strides: ", strides, file=output) print("itemsize: ", obj.itemsize, file=output) print("aligned: ", bp(obj.flags.aligned), file=output) print("contiguous: ", bp(obj.flags.contiguous), file=output) print("fortran: ", obj.flags.fortran, file=output) print("data pointer: %s%s" % (hex(obj.ctypes._as_parameter_.value), extra), file=output) print("byteorder: ", end=' ', file=output) if endian in ['|', '=']: print("%s%s%s" % (tic, sys.byteorder, tic), file=output) byteswap = False elif endian == '>': print("%sbig%s" % (tic, tic), file=output) byteswap = sys.byteorder != "big" else: print("%slittle%s" % (tic, tic), file=output) byteswap = sys.byteorder != "little" print("byteswap: ", bp(byteswap), file=output) print("type: %s" % obj.dtype, file=output) def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): """ Get help information for a function, class, or module. Parameters ---------- object : object or str, optional Input object or name to get information about. If `object` is a numpy object, its docstring is given. If it is a string, available modules are searched for matching objects. If None, information about `info` itself is returned. maxwidth : int, optional Printing width. output : file like object, optional File like object that the output is written to, default is ``stdout``. The object has to be opened in 'w' or 'a' mode. toplevel : str, optional Start search at this level. See Also -------- source, lookfor Notes ----- When used interactively with an object, ``np.info(obj)`` is equivalent to ``help(obj)`` on the Python prompt or ``obj?`` on the IPython prompt. Examples -------- >>> np.info(np.polyval) # doctest: +SKIP polyval(p, x) Evaluate the polynomial p at x. ... When using a string for `object` it is possible to get multiple results. >>> np.info('fft') # doctest: +SKIP *** Found in numpy *** Core FFT routines ... *** Found in numpy.fft *** fft(a, n=None, axis=-1) ... *** Repeat reference found in numpy.fft.fftpack *** *** Total of 3 references found. *** """ global _namedict, _dictlist # Local import to speed up numpy's import time. import pydoc, inspect if hasattr(object, '_ppimport_importer') or \ hasattr(object, '_ppimport_module'): object = object._ppimport_module elif hasattr(object, '_ppimport_attr'): object = object._ppimport_attr if object is None: info(info) elif isinstance(object, ndarray): _info(object, output=output) elif isinstance(object, str): if _namedict is None: _namedict, _dictlist = _makenamedict(toplevel) numfound = 0 objlist = [] for namestr in _dictlist: try: obj = _namedict[namestr][object] if id(obj) in objlist: print("\n *** Repeat reference found in %s *** " % namestr, file=output) else: objlist.append(id(obj)) print(" *** Found in %s ***" % namestr, file=output) info(obj) print("-"*maxwidth, file=output) numfound += 1 except KeyError: pass if numfound == 0: print("Help for %s not found." % object, file=output) else: print("\n *** Total of %d references found. ***" % numfound, file=output) elif inspect.isfunction(object): name = object.__name__ arguments = inspect.formatargspec(*inspect.getargspec(object)) if len(name+arguments) > maxwidth: argstr = _split_line(name, arguments, maxwidth) else: argstr = name + arguments print(" " + argstr + "\n", file=output) print(inspect.getdoc(object), file=output) elif inspect.isclass(object): name = object.__name__ arguments = "()" try: if hasattr(object, '__init__'): arguments = inspect.formatargspec(*inspect.getargspec(object.__init__.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] arguments = ", ".join(arglist[1:]) except: pass if len(name+arguments) > maxwidth: argstr = _split_line(name, arguments, maxwidth) else: argstr = name + arguments print(" " + argstr + "\n", file=output) doc1 = inspect.getdoc(object) if doc1 is None: if hasattr(object, '__init__'): print(inspect.getdoc(object.__init__), file=output) else: print(inspect.getdoc(object), file=output) methods = pydoc.allmethods(object) if methods != []: print("\n\nMethods:\n", file=output) for meth in methods: if meth[0] == '_': continue thisobj = getattr(object, meth, None) if thisobj is not None: methstr, other = pydoc.splitdoc(inspect.getdoc(thisobj) or "None") print(" %s -- %s" % (meth, methstr), file=output) elif (sys.version_info[0] < 3 and isinstance(object, types.InstanceType)): # check for __call__ method # types.InstanceType is the type of the instances of oldstyle classes print("Instance of class: ", object.__class__.__name__, file=output) print(file=output) if hasattr(object, '__call__'): arguments = inspect.formatargspec(*inspect.getargspec(object.__call__.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] arguments = ", ".join(arglist[1:]) else: arguments = "()" if hasattr(object, 'name'): name = "%s" % object.name else: name = "<name>" if len(name+arguments) > maxwidth: argstr = _split_line(name, arguments, maxwidth) else: argstr = name + arguments print(" " + argstr + "\n", file=output) doc = inspect.getdoc(object.__call__) if doc is not None: print(inspect.getdoc(object.__call__), file=output) print(inspect.getdoc(object), file=output) else: print(inspect.getdoc(object), file=output) elif inspect.ismethod(object): name = object.__name__ arguments = inspect.formatargspec(*inspect.getargspec(object.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] arguments = ", ".join(arglist[1:]) else: arguments = "()" if len(name+arguments) > maxwidth: argstr = _split_line(name, arguments, maxwidth) else: argstr = name + arguments print(" " + argstr + "\n", file=output) print(inspect.getdoc(object), file=output) elif hasattr(object, '__doc__'): print(inspect.getdoc(object), file=output) def source(object, output=sys.stdout): """ Print or write to a file the source code for a Numpy object. The source code is only returned for objects written in Python. Many functions and classes are defined in C and will therefore not return useful information. Parameters ---------- object : numpy object Input object. This can be any object (function, class, module, ...). output : file object, optional If `output` not supplied then source code is printed to screen (sys.stdout). File object must be created with either write 'w' or append 'a' modes. See Also -------- lookfor, info Examples -------- >>> np.source(np.interp) #doctest: +SKIP In file: /usr/lib/python2.6/dist-packages/numpy/lib/function_base.py def interp(x, xp, fp, left=None, right=None): \"\"\".... (full docstring printed)\"\"\" if isinstance(x, (float, int, number)): return compiled_interp([x], xp, fp, left, right).item() else: return compiled_interp(x, xp, fp, left, right) The source code is only returned for objects written in Python. >>> np.source(np.array) #doctest: +SKIP Not available for this object. """ # Local import to speed up numpy's import time. import inspect try: print("In file: %s\n" % inspect.getsourcefile(object), file=output) print(inspect.getsource(object), file=output) except: print("Not available for this object.", file=output) # Cache for lookfor: {id(module): {name: (docstring, kind, index), ...}...} # where kind: "func", "class", "module", "object" # and index: index in breadth-first namespace traversal _lookfor_caches = {} # regexp whose match indicates that the string may contain a function signature _function_signature_re = re.compile(r"[a-z0-9_]+\(.*[,=].*\)", re.I) def lookfor(what, module=None, import_modules=True, regenerate=False, output=None): """ Do a keyword search on docstrings. A list of of objects that matched the search is displayed, sorted by relevance. All given keywords need to be found in the docstring for it to be returned as a result, but the order does not matter. Parameters ---------- what : str String containing words to look for. module : str or list, optional Name of module(s) whose docstrings to go through. import_modules : bool, optional Whether to import sub-modules in packages. Default is True. regenerate : bool, optional Whether to re-generate the docstring cache. Default is False. output : file-like, optional File-like object to write the output to. If omitted, use a pager. See Also -------- source, info Notes ----- Relevance is determined only roughly, by checking if the keywords occur in the function name, at the start of a docstring, etc. Examples -------- >>> np.lookfor('binary representation') Search results for 'binary representation' ------------------------------------------ numpy.binary_repr Return the binary representation of the input number as a string. numpy.core.setup_common.long_double_representation Given a binary dump as given by GNU od -b, look for long double numpy.base_repr Return a string representation of a number in the given base system. ... """ import pydoc # Cache cache = _lookfor_generate_cache(module, import_modules, regenerate) # Search # XXX: maybe using a real stemming search engine would be better? found = [] whats = str(what).lower().split() if not whats: return for name, (docstring, kind, index) in cache.items(): if kind in ('module', 'object'): # don't show modules or objects continue ok = True doc = docstring.lower() for w in whats: if w not in doc: ok = False break if ok: found.append(name) # Relevance sort # XXX: this is full Harrison-Stetson heuristics now, # XXX: it probably could be improved kind_relevance = {'func': 1000, 'class': 1000, 'module': -1000, 'object': -1000} def relevance(name, docstr, kind, index): r = 0 # do the keywords occur within the start of the docstring? first_doc = "\n".join(docstr.lower().strip().split("\n")[:3]) r += sum([200 for w in whats if w in first_doc]) # do the keywords occur in the function name? r += sum([30 for w in whats if w in name]) # is the full name long? r += -len(name) * 5 # is the object of bad type? r += kind_relevance.get(kind, -1000) # is the object deep in namespace hierarchy? r += -name.count('.') * 10 r += max(-index / 100, -100) return r def relevance_value(a): return relevance(a, *cache[a]) found.sort(key=relevance_value) # Pretty-print s = "Search results for '%s'" % (' '.join(whats)) help_text = [s, "-"*len(s)] for name in found[::-1]: doc, kind, ix = cache[name] doclines = [line.strip() for line in doc.strip().split("\n") if line.strip()] # find a suitable short description try: first_doc = doclines[0].strip() if _function_signature_re.search(first_doc): first_doc = doclines[1].strip() except IndexError: first_doc = "" help_text.append("%s\n %s" % (name, first_doc)) if not found: help_text.append("Nothing found.") # Output if output is not None: output.write("\n".join(help_text)) elif len(help_text) > 10: pager = pydoc.getpager() pager("\n".join(help_text)) else: print("\n".join(help_text)) def _lookfor_generate_cache(module, import_modules, regenerate): """ Generate docstring cache for given module. Parameters ---------- module : str, None, module Module for which to generate docstring cache import_modules : bool Whether to import sub-modules in packages. regenerate : bool Re-generate the docstring cache Returns ------- cache : dict {obj_full_name: (docstring, kind, index), ...} Docstring cache for the module, either cached one (regenerate=False) or newly generated. """ global _lookfor_caches # Local import to speed up numpy's import time. import inspect if sys.version_info[0] >= 3: # In Python3 stderr, stdout are text files. from io import StringIO else: from StringIO import StringIO if module is None: module = "numpy" if isinstance(module, str): try: __import__(module) except ImportError: return {} module = sys.modules[module] elif isinstance(module, list) or isinstance(module, tuple): cache = {} for mod in module: cache.update(_lookfor_generate_cache(mod, import_modules, regenerate)) return cache if id(module) in _lookfor_caches and not regenerate: return _lookfor_caches[id(module)] # walk items and collect docstrings cache = {} _lookfor_caches[id(module)] = cache seen = {} index = 0 stack = [(module.__name__, module)] while stack: name, item = stack.pop(0) if id(item) in seen: continue seen[id(item)] = True index += 1 kind = "object" if inspect.ismodule(item): kind = "module" try: _all = item.__all__ except AttributeError: _all = None # import sub-packages if import_modules and hasattr(item, '__path__'): for pth in item.__path__: for mod_path in os.listdir(pth): this_py = os.path.join(pth, mod_path) init_py = os.path.join(pth, mod_path, '__init__.py') if os.path.isfile(this_py) and mod_path.endswith('.py'): to_import = mod_path[:-3] elif os.path.isfile(init_py): to_import = mod_path else: continue if to_import == '__init__': continue try: # Catch SystemExit, too base_exc = BaseException except NameError: # Python 2.4 doesn't have BaseException base_exc = Exception try: old_stdout = sys.stdout old_stderr = sys.stderr try: sys.stdout = StringIO() sys.stderr = StringIO() __import__("%s.%s" % (name, to_import)) finally: sys.stdout = old_stdout sys.stderr = old_stderr except base_exc: continue for n, v in _getmembers(item): try: item_name = getattr(v, '__name__', "%s.%s" % (name, n)) mod_name = getattr(v, '__module__', None) except NameError: # ref. SWIG's global cvars # NameError: Unknown C global variable item_name = "%s.%s" % (name, n) mod_name = None if '.' not in item_name and mod_name: item_name = "%s.%s" % (mod_name, item_name) if not item_name.startswith(name + '.'): # don't crawl "foreign" objects if isinstance(v, ufunc): # ... unless they are ufuncs pass else: continue elif not (inspect.ismodule(v) or _all is None or n in _all): continue stack.append(("%s.%s" % (name, n), v)) elif inspect.isclass(item): kind = "class" for n, v in _getmembers(item): stack.append(("%s.%s" % (name, n), v)) elif hasattr(item, "__call__"): kind = "func" try: doc = inspect.getdoc(item) except NameError: # ref SWIG's NameError: Unknown C global variable doc = None if doc is not None: cache[name] = (doc, kind, index) return cache def _getmembers(item): import inspect try: members = inspect.getmembers(item) except AttributeError: members = [(x, getattr(item, x)) for x in dir(item) if hasattr(item, x)] return members #----------------------------------------------------------------------------- # The following SafeEval class and company are adapted from Michael Spencer's # ASPN Python Cookbook recipe: # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469 # Accordingly it is mostly Copyright 2006 by Michael Spencer. # The recipe, like most of the other ASPN Python Cookbook recipes was made # available under the Python license. # http://www.python.org/license # It has been modified to: # * handle unary -/+ # * support True/False/None # * raise SyntaxError instead of a custom exception. class SafeEval(object): """ Object to evaluate constant string expressions. This includes strings with lists, dicts and tuples using the abstract syntax tree created by ``compiler.parse``. For an example of usage, see `safe_eval`. See Also -------- safe_eval """ if sys.version_info[0] < 3: def visit(self, node, **kw): cls = node.__class__ meth = getattr(self, 'visit'+cls.__name__, self.default) return meth(node, **kw) def default(self, node, **kw): raise SyntaxError("Unsupported source construct: %s" % node.__class__) def visitExpression(self, node, **kw): for child in node.getChildNodes(): return self.visit(child, **kw) def visitConst(self, node, **kw): return node.value def visitDict(self, node,**kw): return dict([(self.visit(k), self.visit(v)) for k, v in node.items]) def visitTuple(self, node, **kw): return tuple([self.visit(i) for i in node.nodes]) def visitList(self, node, **kw): return [self.visit(i) for i in node.nodes] def visitUnaryAdd(self, node, **kw): return +self.visit(node.getChildNodes()[0]) def visitUnarySub(self, node, **kw): return -self.visit(node.getChildNodes()[0]) def visitName(self, node, **kw): if node.name == 'False': return False elif node.name == 'True': return True elif node.name == 'None': return None else: raise SyntaxError("Unknown name: %s" % node.name) else: def visit(self, node): cls = node.__class__ meth = getattr(self, 'visit' + cls.__name__, self.default) return meth(node) def default(self, node): raise SyntaxError("Unsupported source construct: %s" % node.__class__) def visitExpression(self, node): return self.visit(node.body) def visitNum(self, node): return node.n def visitStr(self, node): return node.s def visitBytes(self, node): return node.s def visitDict(self, node,**kw): return dict([(self.visit(k), self.visit(v)) for k, v in zip(node.keys, node.values)]) def visitTuple(self, node): return tuple([self.visit(i) for i in node.elts]) def visitList(self, node): return [self.visit(i) for i in node.elts] def visitUnaryOp(self, node): import ast if isinstance(node.op, ast.UAdd): return +self.visit(node.operand) elif isinstance(node.op, ast.USub): return -self.visit(node.operand) else: raise SyntaxError("Unknown unary op: %r" % node.op) def visitName(self, node): if node.id == 'False': return False elif node.id == 'True': return True elif node.id == 'None': return None else: raise SyntaxError("Unknown name: %s" % node.id) def visitNameConstant(self, node): return node.value def safe_eval(source): """ Protected string evaluation. Evaluate a string containing a Python literal expression without allowing the execution of arbitrary non-literal code. Parameters ---------- source : str The string to evaluate. Returns ------- obj : object The result of evaluating `source`. Raises ------ SyntaxError If the code has invalid Python syntax, or if it contains non-literal code. Examples -------- >>> np.safe_eval('1') 1 >>> np.safe_eval('[1, 2, 3]') [1, 2, 3] >>> np.safe_eval('{"foo": ("bar", 10.0)}') {'foo': ('bar', 10.0)} >>> np.safe_eval('import os') Traceback (most recent call last): ... SyntaxError: invalid syntax >>> np.safe_eval('open("/home/user/.ssh/id_dsa").read()') Traceback (most recent call last): ... SyntaxError: Unsupported source construct: compiler.ast.CallFunc """ # Local imports to speed up numpy's import time. import warnings with warnings.catch_warnings(): # compiler package is deprecated for 3.x, which is already solved here warnings.simplefilter('ignore', DeprecationWarning) try: import compiler except ImportError: import ast as compiler walker = SafeEval() try: ast = compiler.parse(source, mode="eval") except SyntaxError as err: raise try: return walker.visit(ast) except SyntaxError as err: raise #-----------------------------------------------------------------------------
techtonik/numpy
numpy/lib/utils.py
Python
bsd-3-clause
36,391
[ "VisIt" ]
37bd6d1e1dc3eb3375d4d7a807d0a14b0ac34d54014ded2c0a4fcffe382d16a0
from fractions import Fraction """ We want to determine the optimum polynomial OP(k,n) for a given degree k-1: OP(k,n) = a(0) + a(1) * n + a(2) * n^2 + ... + a(k-1) * n^(k-1) Plugging values n = 1...k into OP(k, n) must generate the series u(n): OP(k, 1) = u(1) OP(k, 2) = u(2) OP(k, 3) = u(3) ... OP(k, k) = u(k) Expanding OP we get: a(0) + a(1) * 1 + a(2) * 1^2 + ... + a(k-1) * 1^(k-1) = u(1) a(0) + a(1) * 2 + a(2) * 2^2 + ... + a(k-1) * 2^(k-1) = u(2) a(0) + a(1) * 3 + a(2) * 2^2 + ... + a(k-1) * 2^(k-1) = u(2) ... a(0) + a(1) * k + a(2) * k^2 + ... + a(k-1) * k^(k-1) = u(k) Rewriting this in matrix form, we have to solve the following matrix equation for a: M * a = u where M, a, and u are as follows: [ 1 1 1 ... 1 ] [ a(0) ] [ u(1) ] [ 1 2 4 ... 2^(k-1) ] [ a(1) ] [ u(2) ] [ 1 3 27 ... 3^(k-1) ] [ a(2) ] = [ u(3) ] ... ... [ k k^2 k^3 ... k^(k-1) ] [ a(k-1) ] [ u(k) ] Note that indexing is it bit akward because of the choice of indexing in the Euler problem: in the above equation we sometimes start with index 0 and sometimes with index 1. We solve this matrix equation by constructing the following augmented matrix of dimensions k * k+1 and then applying Gaussian elimination. For exact precision we store all numbers are fractions. Once we have OP(k,n) it is trivial to find the FIT for values n. """ def u_example(n): return n**3 def u_problem(n): return 1 - n + n**2 - n**3 + n**4 - n**5 + n**6 - n**7 + n**8 - n**9 + n**10 def make_augmented_matrix(u_function, k): matrix = [] for r in range(0, k): row = [] for c in range(0, k): row.append(Fraction((r+1) ** c)) row.append(Fraction(u_function(r+1))) matrix.append(row) return matrix def sweep_row(matrix, target_row_index, adjust_row_index, factor): nr_columns = len(matrix[0]) for c in range(0, nr_columns): matrix[target_row_index][c] -= factor * matrix[adjust_row_index][c] def gaussian_elimination(matrix): nr_rows = len(matrix) nr_columns = len(matrix[0]) # Sweep down for ari in range(0, nr_rows): for tri in range(ari+1, nr_rows): factor = Fraction(matrix[tri][ari], matrix[ari][ari]) sweep_row(matrix, tri, ari, factor) # Sweep up for ari in reversed(range(1, nr_rows)): for tri in reversed(range(0, ari)): factor = Fraction(matrix[tri][ari], matrix[ari][ari]) sweep_row(matrix, tri, ari, factor) # Normalize for ri in range(0, nr_rows): matrix[ri][nr_rows] /= matrix[ri][ri] matrix[ri][ri] = Fraction(1, 1) # Return solution solution = [] for ri in range(0, nr_rows): solution.append(matrix[ri][nr_columns-1]) return solution def compute_optimum_polynomial_coeficients(u_function, k): matrix = make_augmented_matrix(u_function, k) coeficients = gaussian_elimination(matrix) return coeficients def optimum_polynomial(coeficients, n): k = len(coeficients) fn = Fraction(n) result = Fraction(0) for i in range(0, k): fi = Fraction(i) result += coeficients[i] * (fn ** fi) return result def first_incorrect_term(u_function, k): coeficients = compute_optimum_polynomial_coeficients(u_function, k) n = k + 1 while True: potentially_incorrect_term = optimum_polynomial(coeficients, n) if potentially_incorrect_term != u_function(n): return potentially_incorrect_term n += 1 def sum_of_first_incorrect_terms(u_function, u_degree): sum = 0 for k in range(1, u_degree+1): sum += first_incorrect_term(u_function, k) return sum assert(sum_of_first_incorrect_terms(u_example, 3) == 74) print(sum_of_first_incorrect_terms(u_problem, 10))
brunorijsman/euler-problems-python
euler/problem101.py
Python
bsd-2-clause
4,006
[ "Gaussian" ]
6fbc9d753efeaa1638c0ed25ddfb7f9bad68088d4c0976dc3dd051b69f6dace5
""" Profile Model Access """ import logging from ozpcenter import errors from ozpcenter import models from ozpcenter import utils from django.contrib import auth import ozpcenter.model_access as generic_model_access import ozpcenter.api.storefront.model_access as storefront_model_access from plugins import plugin_manager system_has_access_control = plugin_manager.system_has_access_control logger = logging.getLogger('ozp-center.' + str(__name__)) def get_self(username): """ Get Profile by username Args: username(str) Return: Profile """ return generic_model_access.get_profile(username) def get_all_profiles(): """ Get All Profiles """ return models.Profile.objects.all().order_by('display_name') def get_profile_by_id(profile_id): """ Get profile by id """ try: return models.Profile.objects.get(id=profile_id) except models.Listing.DoesNotExist: return None def get_all_listings_for_profile_by_id(current_request_username, profile_id, listing_id=None, ordering=None): """ Get all Listing for a profile by profile_id and listing_id Args: current_request_username profile_id listing_id ordering Raises: models.Profile.DoesNotExist models.Listing.DoesNotExist """ if not profile_id or profile_id == 'self': profile_instance = models.Profile.objects.get(user__username=current_request_username) else: profile_instance = models.Profile.objects.get(id=profile_id) listings = (models.Listing.objects.for_user(current_request_username) .filter(owners__in=[profile_instance.id]) .filter(is_deleted=False).order_by('approval_status')) if listing_id: listings = listings.get(id=listing_id) else: listings = storefront_model_access.custom_sort_listings(listings.all(), ordering) return listings def get_visit_count_by_id(id): """ Get listing visit count by id """ return models.ListingVisitCount.objects.get(id=id) def get_listing_visit_counts_for_profile(current_request_username, profile_id, listing_id=None): """ Get listing visit counts for a profile_id and listing_id Args: current_request_username profile_id listing_id Raises: models.Profile.DoesNotExist models.Listing.DoesNotExist """ if not profile_id or profile_id == 'self': profile_instance = models.Profile.objects.get(user__username=current_request_username) else: profile_instance = models.Profile.objects.get(id=profile_id) visit_counts = models.ListingVisitCount.objects.for_user(current_request_username).filter(profile=profile_instance) if listing_id: visit_counts = visit_counts.filter(listing_id=listing_id) return visit_counts.order_by('-count') def get_frequently_visited_listings(current_request_username, profile_id, ordering=None): """ Get frequently visited Listing objects for a profile by profile_id Args: current_request_username profile_id ordering Raises: models.Profile.DoesNotExist """ if not profile_id or profile_id == 'self': profile_instance = models.Profile.objects.get(user__username=current_request_username) else: profile_instance = models.Profile.objects.get(id=profile_id) visit_counts = (models.ListingVisitCount.objects.select_related('listing') .filter(profile=profile_instance, count__gt=0, listing__is_deleted=False, listing__is_enabled=True) .order_by('-count', 'listing__title')) listings = [vc.listing for vc in visit_counts] listings = storefront_model_access.custom_sort_listings(listings, ordering) return listings def create_or_update_storefront_customization(profile, section, position=None, is_hidden=None, size=None): """ Updates the storefront customization settings for a given profile and section, or creates a new one if it doesn't exist """ customizations = profile.storefront_customizations.filter(section=section) if customizations.exists(): customization = customizations.first() else: customization = models.StorefrontCustomization(profile=profile, section=section) if position is not None: customization.position = position if is_hidden is not None: customization.is_hidden = is_hidden if size is not None: customization.size = size return customization.save() def create_listing_visit_count(profile, listing, count, last_visit_date=None): """ Set initial visit count for a given profile and listing. Ensures that there is only one visit count object per profile/listing combination. """ if not last_visit_date: last_visit_date = utils.get_now_utc() filtered_counts = models.ListingVisitCount.objects.filter(profile=profile, listing=listing) if filtered_counts.count() > 1: raise errors.RequestException('Only one visit count object can exist for profile {0} and listing {1}'.format(profile.display_name, listing.title)) elif filtered_counts.count() == 1: return update_listing_visit_count(filtered_counts.first(), count, last_visit_date) else: visit_count = models.ListingVisitCount(profile=profile, listing=listing) visit_count.count = count visit_count.last_visit_date = last_visit_date visit_count.save() return visit_count def update_listing_visit_count(visit_count, count, last_visit_date=None): """ Update visit count for a given profile and listing. """ if not last_visit_date: last_visit_date = utils.get_now_utc() visit_count.count = count visit_count.last_visit_date = last_visit_date visit_count.save() return visit_count def delete_listing_visit_count(visit_count): """ Delete visit count """ visit_count.delete() def clear_all_listing_visit_counts(current_request_username, profile_id): """ Clear all listing visit counts for a profile_id Args: current_request_username profile_id Raises: models.Profile.DoesNotExist """ if profile_id == 'self': profile_instance = models.Profile.objects.get(user__username=current_request_username) else: profile_instance = models.Profile.objects.get(id=profile_id) visit_counts = models.ListingVisitCount.objects.for_user(current_request_username).filter(profile=profile_instance).update(count=0) return visit_counts def get_profiles_by_role(role): """ Get Profiles by the role and ordered by display_name Args: role(str): Role of user - USER, ORG_STEWARD.. """ return models.Profile.objects.filter( user__groups__name__exact=role).order_by('display_name') def filter_queryset_by_username_starts_with(queryset, starts_with): return queryset.filter(user__username__startswith=starts_with) def get_all_users(): """ Get all Users (User Objects) """ return auth.models.User.objects.all() def get_all_groups(): """ Get all groups """ return auth.models.Group.objects.all()
aml-development/ozp-backend
ozpcenter/api/profile/model_access.py
Python
apache-2.0
7,248
[ "VisIt" ]
d8d19b9c0724459f5f2122c950c42a00c166d72d2cfeaa32ebfdceab00708410
from neuron import h def shape_3D(self): self.dend[0].connect(self.soma, 0.5, 0) for i in range(1, 2): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[3].connect(self.dend[1], 1, 0) for i in range(4, 6): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[7].connect(self.dend[5], 1, 0) self.dend[8].connect(self.dend[4], 1, 0) for i in range(9, 10): self.dend[i].connect(self.dend[8], 1, 0) self.dend[11].connect(self.dend[3], 1, 0) for i in range(12, 13): self.dend[i].connect(self.dend[11], 1, 0) for i in range(14, 15): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[16].connect(self.dend[14], 1, 0) for i in range(17, 18): self.dend[i].connect(self.dend[16], 1, 0) for i in range(19, 21): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[22].connect(self.dend[20], 1, 0) self.dend[23].connect(self.dend[19], 1, 0) self.dend[24].connect(self.dend[18], 1, 0) self.dend[25].connect(self.dend[13], 1, 0) for i in range(26, 27): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[28].connect(self.dend[26], 1, 0) self.dend[29].connect(self.dend[25], 1, 0) for i in range(30, 31): self.dend[i].connect(self.dend[29], 1, 0) self.dend[32].connect(self.dend[0], 1, 0) for i in range(33, 34): self.dend[i].connect(self.dend[32], 1, 0) for i in range(35, 36): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[37].connect(self.dend[35], 1, 0) for i in range(38, 39): self.dend[i].connect(self.dend[37], 1, 0) for i in range(40, 41): self.dend[i].connect(self.dend[39], 1, 0) for i in range(42, 43): self.dend[i].connect(self.dend[41], 1, 0) self.dend[44].connect(self.dend[34], 1, 0) for i in range(45, 46): self.dend[i].connect(self.dend[44], 1, 0) self.dend[47].connect(self.soma, 0.5, 0) for i in range(48, 49): self.dend[i].connect(self.dend[47], 1, 0) self.dend[50].connect(self.soma, 0.5, 0) for i in range(51, 52): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[53].connect(self.dend[51], 1, 0) for i in range(54, 55): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[56].connect(self.dend[54], 1, 0) self.dend[57].connect(self.dend[53], 1, 0) for i in range(58, 59): self.dend[i].connect(self.dend[57], 1, 0) self.dend[60].connect(self.dend[50], 1, 0) for i in range(61, 62): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[63].connect(self.dend[61], 1, 0) self.dend[64].connect(self.dend[60], 1, 0) self.dend[65].connect(self.soma, 0.5, 0) for i in range(66, 67): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[68].connect(self.dend[66], 1, 0) self.dend[69].connect(self.dend[65], 1, 0) for i in range(70, 71): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[72].connect(self.dend[70], 1, 0) self.dend[73].connect(self.dend[69], 1, 0) for i in range(74, 75): self.dend[i].connect(self.dend[73], 1, 0) for i in range(76, 77): self.dend[i].connect(self.dend[75], 1, 0) for i in range(78, 79): self.dend[i].connect(self.dend[77], 1, 0) for i in range(80, 81): self.dend[i].connect(self.dend[79], 1, 0) self.dend[82].connect(self.soma, 0.5, 0) for i in range(83, 84): self.dend[i].connect(self.dend[82], 1, 0) for i in range(85, 86): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[87].connect(self.dend[85], 1, 0) self.dend[88].connect(self.dend[84], 1, 0) for i in range(89, 90): self.dend[i].connect(self.dend[88], 1, 0) for i in range(91, 92): self.dend[i].connect(self.dend[90], 1, 0) self.dend[93].connect(self.soma, 0.5, 0) for i in range(94, 96): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[97].connect(self.dend[95], 1, 0) self.dend[98].connect(self.dend[94], 1, 0) for i in range(99, 101): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[102].connect(self.dend[100], 1, 0) for i in range(103, 104): self.dend[i].connect(self.dend[102], 1, 0) self.dend[105].connect(self.dend[99], 1, 0) self.dend[106].connect(self.dend[98], 1, 0) self.dend[107].connect(self.dend[93], 1, 0) for i in range(108, 109): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[110].connect(self.dend[108], 1, 0) self.dend[111].connect(self.dend[107], 1, 0) for i in range(112, 113): self.dend[i].connect(self.dend[111], 1, 0) for i in range(114, 115): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[116].connect(self.dend[114], 1, 0) self.dend[117].connect(self.dend[113], 1, 0) for i in range(118, 119): self.dend[i].connect(self.dend[117], 1, 0) for i in range(120, 121): self.dend[i].connect(self.dend[119], 1, 0) for i in range(122, 123): self.dend[i].connect(self.dend[121], 1, 0) self.dend[124].connect(self.soma, 0.5, 0) for i in range(125, 126): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[127].connect(self.dend[125], 1, 0) for i in range(128, 129): self.dend[i].connect(self.dend[127], 1, 0) for i in range(130, 131): self.dend[i].connect(self.dend[129], 1, 0) self.dend[132].connect(self.dend[124], 1, 0) for i in range(133, 135): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[136].connect(self.dend[134], 1, 0) self.dend[137].connect(self.dend[133], 1, 0) for i in range(138, 139): self.dend[i].connect(self.dend[137], 1, 0) for i in range(140, 141): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[142].connect(self.dend[140], 1, 0) self.dend[143].connect(self.dend[139], 1, 0) for i in range(144, 145): self.dend[i].connect(self.dend[143], 1, 0) self.dend[146].connect(self.dend[132], 1, 0) for i in range(147, 149): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[150].connect(self.dend[148], 1, 0) self.dend[151].connect(self.dend[147], 1, 0) for i in range(152, 153): self.dend[i].connect(self.dend[151], 1, 0) self.dend[154].connect(self.dend[146], 1, 0) for i in range(155, 157): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[158].connect(self.dend[156], 1, 0) self.dend[159].connect(self.dend[155], 1, 0) self.dend[160].connect(self.dend[154], 1, 0) for i in range(161, 162): self.dend[i].connect(self.dend[160], 1, 0) for i in range(163, 164): self.dend[i].connect(self.dend[162], 1, 0) for i in range(165, 166): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[167].connect(self.dend[165], 1, 0) self.dend[168].connect(self.dend[164], 1, 0) for i in range(169, 170): self.dend[i].connect(self.dend[168], 1, 0) for i in range(171, 172): self.dend[i].connect(self.dend[170], 1, 0) for i in range(173, 174): self.dend[i].connect(self.dend[172], 1, 0) self.dend[175].connect(self.soma, 0.5, 0) for i in range(176, 177): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[178].connect(self.dend[176], 1, 0) for i in range(179, 180): self.dend[i].connect(self.dend[178], 1, 0) for i in range(181, 182): self.dend[i].connect(self.dend[180], 1, 0) self.dend[183].connect(self.dend[175], 1, 0) for i in range(184, 185): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[186].connect(self.dend[184], 1, 0) for i in range(187, 188): self.dend[i].connect(self.dend[186], 1, 0) for i in range(189, 190): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[191].connect(self.dend[189], 1, 0) self.dend[192].connect(self.dend[188], 1, 0) self.dend[193].connect(self.dend[183], 1, 0) for i in range(194, 195): self.dend[i].connect(self.dend[193], 1, 0) for i in range(196, 197): self.dend[i].connect(self.dend[195], 1, 0) for i in range(198, 199): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[200].connect(self.dend[198], 1, 0) self.dend[201].connect(self.dend[197], 1, 0) for i in range(202, 203): self.dend[i].connect(self.dend[201], 1, 0) self.dend[204].connect(self.soma, 0.5, 0) for i in range(205, 207): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[208].connect(self.dend[206], 1, 0) self.dend[209].connect(self.dend[205], 1, 0) for i in range(210, 211): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[212].connect(self.dend[210], 1, 0) self.dend[213].connect(self.dend[209], 1, 0) for i in range(214, 215): self.dend[i].connect(self.dend[213], 1, 0) for i in range(216, 217): self.dend[i].connect(self.dend[215], 1, 0) self.dend[218].connect(self.dend[204], 1, 0) for i in range(219, 220): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[221].connect(self.dend[219], 1, 0) self.dend[222].connect(self.dend[218], 1, 0) for i in range(223, 224): self.dend[i].connect(self.dend[222], 1, 0) for i in range(225, 226): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[227].connect(self.dend[225], 1, 0) for i in range(228, 229): self.dend[i].connect(self.dend[227], 1, 0) for i in range(230, 231): self.dend[i].connect(self.dend[229], 1, 0) self.dend[232].connect(self.dend[224], 1, 0) self.dend[233].connect(self.soma, 0.5, 0) for i in range(234, 237): self.dend[i].connect(self.dend[i-1], 1, 0) self.dend[238].connect(self.dend[236], 1, 0) self.dend[239].connect(self.dend[235], 1, 0) for i in range(240, 241): self.dend[i].connect(self.dend[239], 1, 0) for i in range(242, 243): self.dend[i].connect(self.dend[241], 1, 0) self.dend[244].connect(self.dend[234], 1, 0) self.dend[245].connect(self.dend[233], 1, 0) for i in range(246, 247): self.dend[i].connect(self.dend[245], 1, 0) self.dend[248].connect(self.soma, 0.5, 0) h.pt3dclear(sec = self.soma) h.pt3dadd(8.934, 29.98, -13.49, 60.812, sec = self.soma) h.pt3dadd(39.34, 29.98, -13.49, 60.812, sec = self.soma) h.pt3dadd(69.746, 29.98, -13.49, 60.812, sec = self.soma) h.pt3dclear(sec = self.dend[0]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[0]) h.pt3dadd(3, 21.5, -5, 10.6, sec = self.dend[0]) h.pt3dadd(0.5, 21, -5.5, 10.2, sec = self.dend[0]) h.pt3dadd(-3.5, 18, -4, 9.9, sec = self.dend[0]) h.pt3dadd(-6, 18.5, -1, 9.3, sec = self.dend[0]) h.pt3dclear(sec = self.dend[1]) h.pt3dadd(-6, 18.5, -1, 9.3, sec = self.dend[1]) h.pt3dadd(-11, 20, -3.5, 9, sec = self.dend[1]) h.pt3dadd(-17, 23, -3.5, 9.5, sec = self.dend[1]) h.pt3dadd(-20, 25.5, -3.5, 9.9, sec = self.dend[1]) h.pt3dadd(-24, 28, -3.5, 9.2, sec = self.dend[1]) h.pt3dadd(-28.5, 30.5, -1, 8.6, sec = self.dend[1]) h.pt3dadd(-34, 32, 4.5, 8.6, sec = self.dend[1]) h.pt3dadd(-38.5, 33, 10, 8.6, sec = self.dend[1]) h.pt3dadd(-42, 34, 10, 7.8, sec = self.dend[1]) h.pt3dadd(-46.5, 34.5, 10, 7.3, sec = self.dend[1]) h.pt3dadd(-50.5, 36.5, 10, 7.6, sec = self.dend[1]) h.pt3dadd(-55, 37.5, 16, 7.6, sec = self.dend[1]) h.pt3dadd(-61, 40, 18.5, 7.1, sec = self.dend[1]) h.pt3dadd(-64.5, 40.5, 21.5, 7.3, sec = self.dend[1]) h.pt3dadd(-69, 41.5, 21.5, 8, sec = self.dend[1]) h.pt3dadd(-72.5, 43, 21.5, 9.3, sec = self.dend[1]) h.pt3dadd(-77.5, 44, 21.5, 11.4, sec = self.dend[1]) h.pt3dadd(-83.5, 46.5, 21.5, 12.5, sec = self.dend[1]) h.pt3dadd(-86.5, 46.5, 24, 13, sec = self.dend[1]) h.pt3dadd(-90.5, 48.5, 27, 10.2, sec = self.dend[1]) h.pt3dadd(-92, 49.5, 27, 8.4, sec = self.dend[1]) h.pt3dadd(-93, 50, 27, 8.9, sec = self.dend[1]) h.pt3dclear(sec = self.dend[2]) h.pt3dadd(-93, 50, 27, 8.9, sec = self.dend[2]) h.pt3dadd(-103.5, 51, 18.5, 1.8, sec = self.dend[2]) h.pt3dadd(-106.5, 51, 21.5, 1.8, sec = self.dend[2]) h.pt3dadd(-111, 49.5, 24, 1.9, sec = self.dend[2]) h.pt3dadd(-115.5, 48.5, 18.5, 2.3, sec = self.dend[2]) h.pt3dadd(-118, 48.5, 21.5, 2.3, sec = self.dend[2]) h.pt3dadd(-120, 48, 18.5, 2.6, sec = self.dend[2]) h.pt3dadd(-124, 48, 21.5, 2.1, sec = self.dend[2]) h.pt3dadd(-126.5, 48.5, 13, 1.4, sec = self.dend[2]) h.pt3dadd(-128.5, 48.5, 18.5, 1.4, sec = self.dend[2]) h.pt3dadd(-130.5, 49.5, 21.5, 1.4, sec = self.dend[2]) h.pt3dadd(-133, 49.5, 21.5, 1.1, sec = self.dend[2]) h.pt3dadd(-135.5, 49.5, 21.5, 0.9, sec = self.dend[2]) h.pt3dadd(-138.5, 49.5, 16, 0.9, sec = self.dend[2]) h.pt3dadd(-141, 49.5, 16, 0.7, sec = self.dend[2]) h.pt3dadd(-143.5, 49.5, 21.5, 0.3, sec = self.dend[2]) h.pt3dadd(-146.5, 49.5, 21.5, 0.3, sec = self.dend[2]) h.pt3dadd(-148, 49, 13, 1.4, sec = self.dend[2]) h.pt3dadd(-150, 48, 13, 1.8, sec = self.dend[2]) h.pt3dadd(-152, 48, 16, 1.3, sec = self.dend[2]) h.pt3dadd(-154, 47.5, 7.5, 0.9, sec = self.dend[2]) h.pt3dadd(-156, 45.5, 10, 1.2, sec = self.dend[2]) h.pt3dadd(-158, 45.5, 10, 1.7, sec = self.dend[2]) h.pt3dadd(-160, 44, 10, 1.3, sec = self.dend[2]) h.pt3dadd(-161, 44, 10, 0.4, sec = self.dend[2]) h.pt3dadd(-163, 43, 10, 0.5, sec = self.dend[2]) h.pt3dadd(-165, 43, 13, 1.6, sec = self.dend[2]) h.pt3dadd(-167, 42, 13, 3, sec = self.dend[2]) h.pt3dadd(-169.5, 41.5, 2, 2.1, sec = self.dend[2]) h.pt3dadd(-171.5, 41, 4.5, 0.6, sec = self.dend[2]) h.pt3dadd(-174, 40, 4.5, 0.8, sec = self.dend[2]) h.pt3dadd(-177.5, 38.5, 7.5, 0.9, sec = self.dend[2]) h.pt3dadd(-180, 38.5, 7.5, 0.9, sec = self.dend[2]) h.pt3dadd(-180, 36.5, 7.5, 0.9, sec = self.dend[2]) h.pt3dadd(-181.5, 35, 4.5, 0.9, sec = self.dend[2]) h.pt3dadd(-182.5, 32.5, 10, 0.9, sec = self.dend[2]) h.pt3dadd(-183.5, 30.5, 2, 1.5, sec = self.dend[2]) h.pt3dadd(-186, 30, 4.5, 1.5, sec = self.dend[2]) h.pt3dadd(-190.5, 29.5, 5.5, 0.8, sec = self.dend[2]) h.pt3dadd(-193, 29.5, 5.5, 0.8, sec = self.dend[2]) h.pt3dadd(-194.5, 29, 5.5, 0.8, sec = self.dend[2]) h.pt3dadd(-195.5, 27, 7.5, 1.4, sec = self.dend[2]) h.pt3dadd(-197.5, 25.5, 6.5, 1.9, sec = self.dend[2]) h.pt3dadd(-200.5, 25.5, 6.5, 1.5, sec = self.dend[2]) h.pt3dadd(-202.5, 25.5, 6.5, 0.3, sec = self.dend[2]) h.pt3dadd(-204.5, 24, 6.5, 0.3, sec = self.dend[2]) h.pt3dadd(-204.5, 22.5, 6.5, 1.1, sec = self.dend[2]) h.pt3dadd(-206, 22, 0, 1.2, sec = self.dend[2]) h.pt3dadd(-207.5, 22, 2, 0.5, sec = self.dend[2]) h.pt3dadd(-209.5, 22, 3, 0.3, sec = self.dend[2]) h.pt3dadd(-211, 21.5, 2, 0.3, sec = self.dend[2]) h.pt3dadd(-213, 20, 4.5, 1.2, sec = self.dend[2]) h.pt3dadd(-214.5, 18, 3.5, 0.2, sec = self.dend[2]) h.pt3dadd(-215.5, 17.5, 3, 1.5, sec = self.dend[2]) h.pt3dadd(-216, 16.5, 3, 2.3, sec = self.dend[2]) h.pt3dadd(-216.5, 15.5, 3, 2.4, sec = self.dend[2]) h.pt3dadd(-218, 15, 3, 1.9, sec = self.dend[2]) h.pt3dadd(-219, 14.5, 3, 0.8, sec = self.dend[2]) h.pt3dadd(-219, 13.5, 1, 0.2, sec = self.dend[2]) h.pt3dadd(-221.5, 13, 1, 0.2, sec = self.dend[2]) h.pt3dadd(-223, 13, 3, 1.7, sec = self.dend[2]) h.pt3dadd(-224.5, 12.5, 3, 2.3, sec = self.dend[2]) h.pt3dadd(-226.5, 12, 3, 0.9, sec = self.dend[2]) h.pt3dadd(-227, 11, 3, 0.3, sec = self.dend[2]) h.pt3dadd(-229, 10, 3, 0.3, sec = self.dend[2]) h.pt3dadd(-230.5, 10, 3, 1.4, sec = self.dend[2]) h.pt3dadd(-232.5, 10, 3, 2.4, sec = self.dend[2]) h.pt3dadd(-234.5, 9.5, 3, 2, sec = self.dend[2]) h.pt3dadd(-236.5, 9, 3, 0.3, sec = self.dend[2]) h.pt3dadd(-237.5, 8, -1, 0.5, sec = self.dend[2]) h.pt3dadd(-238.5, 6, -1, 0.7, sec = self.dend[2]) h.pt3dadd(-241, 6, 0, 0.7, sec = self.dend[2]) h.pt3dadd(-245.5, 4.5, 0, 1.1, sec = self.dend[2]) h.pt3dadd(-247.5, 2.5, 0, 1.1, sec = self.dend[2]) h.pt3dadd(-250, 2.5, 1, 1.8, sec = self.dend[2]) h.pt3dadd(-251.5, 1.5, 1, 3.1, sec = self.dend[2]) h.pt3dadd(-253.5, -1, -1.5, 1.6, sec = self.dend[2]) h.pt3dadd(-253.5, -2, -1.5, 0.6, sec = self.dend[2]) h.pt3dadd(-253.5, -4, -2.5, 0.6, sec = self.dend[2]) h.pt3dadd(-254.5, -4.5, -1.5, 1.6, sec = self.dend[2]) h.pt3dadd(-256, -7.5, -1.5, 2.8, sec = self.dend[2]) h.pt3dadd(-258, -9.5, -1.5, 0.9, sec = self.dend[2]) h.pt3dadd(-259.5, -13, -1.5, 0.3, sec = self.dend[2]) h.pt3dadd(-261, -13, -1.5, 0.7, sec = self.dend[2]) h.pt3dadd(-263, -13, -1.5, 1.7, sec = self.dend[2]) h.pt3dadd(-265, -14, -1.5, 2, sec = self.dend[2]) h.pt3dadd(-266.5, -14, -1.5, 0.9, sec = self.dend[2]) h.pt3dadd(-269, -16.5, -1.5, 2.8, sec = self.dend[2]) h.pt3dadd(-270, -18, -1.5, 0.3, sec = self.dend[2]) h.pt3dadd(-272, -20.5, -1.5, 0.5, sec = self.dend[2]) h.pt3dadd(-273.5, -20, -1.5, 0.7, sec = self.dend[2]) h.pt3dadd(-276.5, -19.5, -1, 0.7, sec = self.dend[2]) h.pt3dadd(-280.5, -19, -7, 0.8, sec = self.dend[2]) h.pt3dclear(sec = self.dend[3]) h.pt3dadd(-93, 50, 27, 8.9, sec = self.dend[3]) h.pt3dadd(-98, 54, 24, 8.9, sec = self.dend[3]) h.pt3dadd(-104.5, 57.5, 24, 7.9, sec = self.dend[3]) h.pt3dadd(-110.5, 60.5, 27, 7.9, sec = self.dend[3]) h.pt3dadd(-115.5, 62.5, 28.5, 8.3, sec = self.dend[3]) h.pt3dadd(-121, 64.5, 28.5, 8.5, sec = self.dend[3]) h.pt3dadd(-124, 66.5, 28.5, 8.5, sec = self.dend[3]) h.pt3dadd(-128.5, 69, 31.5, 8.2, sec = self.dend[3]) h.pt3dadd(-132, 70.5, 30, 8.2, sec = self.dend[3]) h.pt3dadd(-135.5, 71.5, 32.5, 8.2, sec = self.dend[3]) h.pt3dadd(-140, 73.5, 34, 9, sec = self.dend[3]) h.pt3dadd(-147, 77, 34, 9.9, sec = self.dend[3]) h.pt3dclear(sec = self.dend[4]) h.pt3dadd(-147, 77, 34, 9.9, sec = self.dend[4]) h.pt3dadd(-153, 80, 31.5, 3.1, sec = self.dend[4]) h.pt3dadd(-156.5, 82.5, 31.5, 3.4, sec = self.dend[4]) h.pt3dadd(-158.5, 86.5, 32.5, 4.1, sec = self.dend[4]) h.pt3dadd(-159.5, 90, 34, 4.7, sec = self.dend[4]) h.pt3dadd(-161.5, 92, 34, 4.9, sec = self.dend[4]) h.pt3dadd(-164, 95.5, 37, 4.3, sec = self.dend[4]) h.pt3dadd(-166, 97.5, 37, 4.4, sec = self.dend[4]) h.pt3dadd(-168.5, 101.5, 37, 5.3, sec = self.dend[4]) h.pt3dadd(-171, 104, 38.5, 5.6, sec = self.dend[4]) h.pt3dadd(-173.5, 108, 45.5, 4, sec = self.dend[4]) h.pt3dadd(-176, 109.5, 47, 5.4, sec = self.dend[4]) h.pt3dadd(-179, 113, 38.5, 5.7, sec = self.dend[4]) h.pt3dadd(-181.5, 117, 40, 5.7, sec = self.dend[4]) h.pt3dadd(-183, 119, 40, 4.9, sec = self.dend[4]) h.pt3dadd(-185.5, 120.5, 41.5, 4.2, sec = self.dend[4]) h.pt3dadd(-187, 123, 41.5, 3.3, sec = self.dend[4]) h.pt3dadd(-189.5, 125, 42.5, 2.8, sec = self.dend[4]) h.pt3dadd(-191.5, 126.5, 42.5, 2.8, sec = self.dend[4]) h.pt3dadd(-192, 129.5, 42.5, 3.1, sec = self.dend[4]) h.pt3dadd(-194.5, 130, 42.5, 2.7, sec = self.dend[4]) h.pt3dadd(-197.5, 131, 42.5, 3.1, sec = self.dend[4]) h.pt3dadd(-201.5, 132.5, 42.5, 2.4, sec = self.dend[4]) h.pt3dadd(-204.5, 134.5, 42.5, 2.6, sec = self.dend[4]) h.pt3dadd(-204.5, 137.5, 42.5, 4.3, sec = self.dend[4]) h.pt3dadd(-208, 139.5, 44, 5, sec = self.dend[4]) h.pt3dadd(-209, 141.5, 44, 6, sec = self.dend[4]) h.pt3dadd(-212, 141.5, 44, 5.8, sec = self.dend[4]) h.pt3dadd(-214.5, 143.5, 44, 5.2, sec = self.dend[4]) h.pt3dadd(-215.5, 146, 44, 5.3, sec = self.dend[4]) h.pt3dadd(-219, 148.5, 44, 5.6, sec = self.dend[4]) h.pt3dadd(-222.5, 148.5, 45.5, 6.3, sec = self.dend[4]) h.pt3dadd(-226.5, 150.5, 48.5, 7.4, sec = self.dend[4]) h.pt3dclear(sec = self.dend[5]) h.pt3dadd(-226.5, 150.5, 48.5, 7.4, sec = self.dend[5]) h.pt3dadd(-230, 156, 50, 4.7, sec = self.dend[5]) h.pt3dadd(-233, 159, 51.5, 4.1, sec = self.dend[5]) h.pt3dadd(-236, 161.5, 51.5, 4.1, sec = self.dend[5]) h.pt3dadd(-240, 164.5, 51.5, 5.2, sec = self.dend[5]) h.pt3dadd(-244.5, 169, 51.5, 4.4, sec = self.dend[5]) h.pt3dadd(-245.5, 170, 51.5, 3.6, sec = self.dend[5]) h.pt3dadd(-247.5, 172.5, 51.5, 3.8, sec = self.dend[5]) h.pt3dadd(-249, 174, 51.5, 3.8, sec = self.dend[5]) h.pt3dadd(-254.5, 175.5, 52.5, 3.5, sec = self.dend[5]) h.pt3dadd(-256.5, 179, 54, 3.6, sec = self.dend[5]) h.pt3dadd(-259, 183, 55.5, 3.8, sec = self.dend[5]) h.pt3dadd(-263, 186, 55.5, 4.1, sec = self.dend[5]) h.pt3dadd(-263.5, 187.5, 55.5, 4.2, sec = self.dend[5]) h.pt3dadd(-266.5, 188.5, 55.5, 4.5, sec = self.dend[5]) h.pt3dadd(-266.5, 190, 55.5, 4.6, sec = self.dend[5]) h.pt3dadd(-269, 192.5, 55.5, 3.1, sec = self.dend[5]) h.pt3dadd(-269.5, 196, 55.5, 2.5, sec = self.dend[5]) h.pt3dadd(-272, 197.5, 55.5, 2.4, sec = self.dend[5]) h.pt3dadd(-273, 200.5, 55.5, 3.2, sec = self.dend[5]) h.pt3dadd(-274, 203.5, 55.5, 3.5, sec = self.dend[5]) h.pt3dadd(-275, 206, 55.5, 4.1, sec = self.dend[5]) h.pt3dadd(-276, 208.5, 55.5, 5.1, sec = self.dend[5]) h.pt3dadd(-277.5, 212, 55.5, 3.7, sec = self.dend[5]) h.pt3dadd(-277.5, 216.5, 55.5, 3.7, sec = self.dend[5]) h.pt3dadd(-278.5, 218, 55.5, 4.8, sec = self.dend[5]) h.pt3dclear(sec = self.dend[6]) h.pt3dadd(-278.5, 218, 55.5, 4.8, sec = self.dend[6]) h.pt3dadd(-281.5, 218, 55.5, 3.3, sec = self.dend[6]) h.pt3dadd(-284.5, 219, 60, 2.3, sec = self.dend[6]) h.pt3dadd(-286, 219.5, 60, 2.3, sec = self.dend[6]) h.pt3dadd(-288.5, 222, 60, 2.7, sec = self.dend[6]) h.pt3dadd(-288.5, 224, 60, 3.7, sec = self.dend[6]) h.pt3dadd(-290.5, 228, 60, 4.1, sec = self.dend[6]) h.pt3dadd(-291, 230.5, 60, 4.1, sec = self.dend[6]) h.pt3dadd(-293, 231, 60, 2.2, sec = self.dend[6]) h.pt3dadd(-293.5, 233, 61.5, 1.2, sec = self.dend[6]) h.pt3dadd(-293.5, 235, 62.5, 2.8, sec = self.dend[6]) h.pt3dadd(-294.5, 240, 62.5, 2.7, sec = self.dend[6]) h.pt3dadd(-295.5, 242.5, 50, 4, sec = self.dend[6]) h.pt3dadd(-296.5, 245.5, 50, 4, sec = self.dend[6]) h.pt3dadd(-298, 246, 50, 3.1, sec = self.dend[6]) h.pt3dadd(-301, 249, 51.5, 2.1, sec = self.dend[6]) h.pt3dadd(-301, 251.5, 52.5, 2.4, sec = self.dend[6]) h.pt3dadd(-302, 254, 52.5, 2.9, sec = self.dend[6]) h.pt3dadd(-303, 256, 52.5, 2.9, sec = self.dend[6]) h.pt3dadd(-305, 257.5, 55.5, 2.7, sec = self.dend[6]) h.pt3dadd(-306.5, 258.5, 57, 2.6, sec = self.dend[6]) h.pt3dadd(-309.5, 260.5, 57, 2.6, sec = self.dend[6]) h.pt3dadd(-311.5, 260.5, 57, 2.4, sec = self.dend[6]) h.pt3dadd(-311.5, 262.5, 55.5, 2, sec = self.dend[6]) h.pt3dadd(-320.5, 264, 32.5, 2.7, sec = self.dend[6]) h.pt3dadd(-321.5, 266.5, 32.5, 2.7, sec = self.dend[6]) h.pt3dadd(-322.5, 270, 35.5, 2.6, sec = self.dend[6]) h.pt3dadd(-322, 272, 37, 1.9, sec = self.dend[6]) h.pt3dadd(-322, 274.5, 37, 1.9, sec = self.dend[6]) h.pt3dadd(-322, 276, 37, 1.8, sec = self.dend[6]) h.pt3dadd(-324, 277, 34, 1.6, sec = self.dend[6]) h.pt3dadd(-324.5, 278, 34, 2.8, sec = self.dend[6]) h.pt3dadd(-324.5, 280.5, 34, 3.3, sec = self.dend[6]) h.pt3dadd(-324.5, 282.5, 34, 3.6, sec = self.dend[6]) h.pt3dadd(-325.5, 287, 32.5, 3, sec = self.dend[6]) h.pt3dadd(-325.5, 288.5, 32.5, 2.6, sec = self.dend[6]) h.pt3dadd(-326, 291, 32.5, 3.1, sec = self.dend[6]) h.pt3dadd(-326, 293, 32.5, 2.8, sec = self.dend[6]) h.pt3dadd(-325, 295, 35.5, 2.1, sec = self.dend[6]) h.pt3dadd(-325, 296, 27, 2.1, sec = self.dend[6]) h.pt3dadd(-322, 298, 25.5, 2.1, sec = self.dend[6]) h.pt3dadd(-320.5, 300.5, 28.5, 2.1, sec = self.dend[6]) h.pt3dadd(-318.5, 303.5, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-317.5, 306.5, 25.5, 2.4, sec = self.dend[6]) h.pt3dadd(-314.5, 309, 28.5, 2.6, sec = self.dend[6]) h.pt3dadd(-313, 312.5, 28.5, 2.5, sec = self.dend[6]) h.pt3dadd(-310.5, 315.5, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-312, 319, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-315.5, 321.5, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-315.5, 324.5, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-315, 330, 28.5, 2.4, sec = self.dend[6]) h.pt3dadd(-315, 331.5, 27, 2.4, sec = self.dend[6]) h.pt3dadd(-318, 331.5, 27, 2.4, sec = self.dend[6]) h.pt3dadd(-320.5, 335.5, 27, 2.4, sec = self.dend[6]) h.pt3dadd(-323.5, 338.5, 27, 2.4, sec = self.dend[6]) h.pt3dadd(-326.5, 340.5, 27, 2.4, sec = self.dend[6]) h.pt3dadd(-326.5, 344.5, 31.5, 1.4, sec = self.dend[6]) h.pt3dadd(-326.5, 351.5, 30, 1.4, sec = self.dend[6]) h.pt3dadd(-326.5, 355, 25.5, 2.2, sec = self.dend[6]) h.pt3dadd(-329.5, 359.5, 25.5, 3, sec = self.dend[6]) h.pt3dadd(-332, 364.5, 21.5, 3, sec = self.dend[6]) h.pt3dadd(-334.5, 368.5, 10, 2.7, sec = self.dend[6]) h.pt3dadd(-334, 370.5, 18.5, 3.3, sec = self.dend[6]) h.pt3dadd(-332, 372.5, -6.5, 3.3, sec = self.dend[6]) h.pt3dadd(-332, 377, -1, 4.6, sec = self.dend[6]) h.pt3dadd(-334, 381, 4.5, 4.1, sec = self.dend[6]) h.pt3dadd(-335, 382.5, 4.5, 2.8, sec = self.dend[6]) h.pt3dadd(-337, 385.5, 4.5, 2.5, sec = self.dend[6]) h.pt3dadd(-338.5, 388.5, 4.5, 2.7, sec = self.dend[6]) h.pt3dadd(-341.5, 390.5, 4.5, 1.8, sec = self.dend[6]) h.pt3dadd(-344, 393, 4.5, 1.1, sec = self.dend[6]) h.pt3dadd(-344, 395, 4.5, 1.1, sec = self.dend[6]) h.pt3dadd(-344.5, 398.5, 10, 2.7, sec = self.dend[6]) h.pt3dadd(-344.5, 400.5, 10, 4.3, sec = self.dend[6]) h.pt3dadd(-343.5, 403.5, 10, 2.3, sec = self.dend[6]) h.pt3dadd(-343.5, 406.5, 10, 1.5, sec = self.dend[6]) h.pt3dadd(-343.5, 409.5, -1, 1.1, sec = self.dend[6]) h.pt3dadd(-344, 411, -1, 1, sec = self.dend[6]) h.pt3dadd(-344, 413.5, -1, 1, sec = self.dend[6]) h.pt3dadd(-345.5, 415.5, 4.5, 1.3, sec = self.dend[6]) h.pt3dadd(-347.5, 417, -3.5, 1.3, sec = self.dend[6]) h.pt3dadd(-348.5, 418.5, 2, 1.9, sec = self.dend[6]) h.pt3dadd(-349, 420.5, 2, 2.1, sec = self.dend[6]) h.pt3dadd(-351, 423.5, -6.5, 2, sec = self.dend[6]) h.pt3dadd(-353.5, 426, -6.5, 2.8, sec = self.dend[6]) h.pt3dadd(-354.5, 427.5, -3.5, 3.4, sec = self.dend[6]) h.pt3dadd(-355, 429, -3.5, 3.8, sec = self.dend[6]) h.pt3dadd(-358.5, 430.5, -3.5, 2.6, sec = self.dend[6]) h.pt3dadd(-361, 430.5, -1, 2.3, sec = self.dend[6]) h.pt3dadd(-363, 432.5, -1, 2.3, sec = self.dend[6]) h.pt3dadd(-363.5, 434, -1, 1.9, sec = self.dend[6]) h.pt3dadd(-365.5, 435.5, -1, 1.4, sec = self.dend[6]) h.pt3dadd(-367.5, 437.5, 2, 1.6, sec = self.dend[6]) h.pt3dadd(-370.5, 437.5, 2, 1.6, sec = self.dend[6]) h.pt3dadd(-372, 438.5, 2, 2.2, sec = self.dend[6]) h.pt3dadd(-372, 440, 2, 2.6, sec = self.dend[6]) h.pt3dadd(-374, 441.5, 4.5, 0.7, sec = self.dend[6]) h.pt3dadd(-374, 442.5, 4.5, 1.8, sec = self.dend[6]) h.pt3dadd(-376, 444, 4.5, 3.1, sec = self.dend[6]) h.pt3dadd(-378.5, 445.5, 4.5, 2.6, sec = self.dend[6]) h.pt3dadd(-379, 447.5, 4.5, 0.9, sec = self.dend[6]) h.pt3dadd(-379.5, 450, 4.5, 0.7, sec = self.dend[6]) h.pt3dadd(-381.5, 452, 7.5, 1.1, sec = self.dend[6]) h.pt3dadd(-384, 454.5, 7.5, 1.1, sec = self.dend[6]) h.pt3dadd(-386.5, 454.5, 7.5, 1.1, sec = self.dend[6]) h.pt3dadd(-389.5, 455, 7.5, 1.2, sec = self.dend[6]) h.pt3dadd(-391, 456, 10, 0.9, sec = self.dend[6]) h.pt3dadd(-392.5, 457, -3.5, 1.1, sec = self.dend[6]) h.pt3dadd(-394.5, 458, -3.5, 1.1, sec = self.dend[6]) h.pt3dadd(-396.5, 457, -3.5, 0.8, sec = self.dend[6]) h.pt3dadd(-397.5, 456.5, -3.5, 0.7, sec = self.dend[6]) h.pt3dadd(-400.5, 456.5, -1, 0.9, sec = self.dend[6]) h.pt3dadd(-402.5, 457, 4.5, 0.9, sec = self.dend[6]) h.pt3dadd(-405.5, 459, 4.5, 0.9, sec = self.dend[6]) h.pt3dadd(-407, 458.5, 4.5, 0.9, sec = self.dend[6]) h.pt3dadd(-409.5, 457.5, -1, 1.8, sec = self.dend[6]) h.pt3dadd(-411.5, 457.5, -1, 1.6, sec = self.dend[6]) h.pt3dadd(-413, 460.5, -1, 2.5, sec = self.dend[6]) h.pt3dadd(-413, 462, -6.5, 2.3, sec = self.dend[6]) h.pt3dadd(-413, 465.5, -1, 2.3, sec = self.dend[6]) h.pt3dadd(-413, 467, -1, 1.8, sec = self.dend[6]) h.pt3dadd(-413, 469.5, -1, 1.8, sec = self.dend[6]) h.pt3dadd(-414, 471.5, -1, 1.4, sec = self.dend[6]) h.pt3dadd(-413.5, 473, -3.5, 1, sec = self.dend[6]) h.pt3dadd(-412.5, 475, -3.5, 1.5, sec = self.dend[6]) h.pt3dadd(-412.5, 477, -3.5, 2.2, sec = self.dend[6]) h.pt3dadd(-411, 480.5, -3.5, 1.9, sec = self.dend[6]) h.pt3dadd(-411, 482, -3.5, 1.5, sec = self.dend[6]) h.pt3dadd(-410, 484.5, -6.5, 1.9, sec = self.dend[6]) h.pt3dadd(-408.5, 485.5, -6.5, 1.9, sec = self.dend[6]) h.pt3dadd(-407.5, 488, -6.5, 1.9, sec = self.dend[6]) h.pt3dadd(-407.5, 490, -6.5, 1.7, sec = self.dend[6]) h.pt3dadd(-405.5, 493, -3.5, 1.4, sec = self.dend[6]) h.pt3dadd(-405, 494, -3.5, 1.4, sec = self.dend[6]) h.pt3dadd(-403, 495.5, -3.5, 1.4, sec = self.dend[6]) h.pt3dadd(-401, 497, -9.5, 1.4, sec = self.dend[6]) h.pt3dadd(-401, 499.5, -9.5, 1.4, sec = self.dend[6]) h.pt3dadd(-402.5, 502, -9.5, 1.9, sec = self.dend[6]) h.pt3dadd(-404.5, 504, -9.5, 2.1, sec = self.dend[6]) h.pt3dadd(-405.5, 506.5, -9.5, 1.6, sec = self.dend[6]) h.pt3dadd(-405.5, 508, -9.5, 1.3, sec = self.dend[6]) h.pt3dadd(-406, 511, -9.5, 1.3, sec = self.dend[6]) h.pt3dadd(-405.5, 514.5, -12, 1.8, sec = self.dend[6]) h.pt3dadd(-405.5, 517.5, -12, 1.8, sec = self.dend[6]) h.pt3dadd(-405, 519, -26, 1.6, sec = self.dend[6]) h.pt3dclear(sec = self.dend[7]) h.pt3dadd(-278.5, 218, 55.5, 4.8, sec = self.dend[7]) h.pt3dadd(-279, 222.5, 55.5, 2, sec = self.dend[7]) h.pt3dadd(-280, 225, 48.5, 3.2, sec = self.dend[7]) h.pt3dadd(-280, 226, 50, 3.4, sec = self.dend[7]) h.pt3dadd(-280, 229.5, 51.5, 3.8, sec = self.dend[7]) h.pt3dadd(-279.5, 233.5, 48.5, 2.9, sec = self.dend[7]) h.pt3dadd(-280, 237.5, 48.5, 2.5, sec = self.dend[7]) h.pt3dadd(-280, 240, 48.5, 2.5, sec = self.dend[7]) h.pt3dadd(-280, 243, 48.5, 2.5, sec = self.dend[7]) h.pt3dadd(-280, 246, 48.5, 2.7, sec = self.dend[7]) h.pt3dadd(-280.5, 249.5, 48.5, 2.3, sec = self.dend[7]) h.pt3dadd(-281, 251, 48.5, 1.9, sec = self.dend[7]) h.pt3dadd(-281.5, 253, 50.5, 1.6, sec = self.dend[7]) h.pt3dadd(-283, 254, 52, 1.9, sec = self.dend[7]) h.pt3dadd(-283, 255, 54, 1.9, sec = self.dend[7]) h.pt3dadd(-283, 257, 50.5, 1.8, sec = self.dend[7]) h.pt3dadd(-284.5, 259, 55.5, 2.3, sec = self.dend[7]) h.pt3dadd(-286, 260, 52, 1.8, sec = self.dend[7]) h.pt3dadd(-287.5, 261.5, 55.5, 1.9, sec = self.dend[7]) h.pt3dadd(-288, 265, 59.5, 2.5, sec = self.dend[7]) h.pt3dadd(-288.5, 267, 59.5, 2.7, sec = self.dend[7]) h.pt3dadd(-290, 268, 59.5, 3.3, sec = self.dend[7]) h.pt3dadd(-291.5, 270.5, 54, 4, sec = self.dend[7]) h.pt3dadd(-292, 272.5, 54, 2.9, sec = self.dend[7]) h.pt3dadd(-293.5, 275.5, 52, 1.9, sec = self.dend[7]) h.pt3dadd(-294.5, 278.5, 63, 1.5, sec = self.dend[7]) h.pt3dadd(-296, 280.5, 61, 1.6, sec = self.dend[7]) h.pt3dadd(-296.5, 281.5, 61, 1.6, sec = self.dend[7]) h.pt3dadd(-298, 284, 57.5, 2.8, sec = self.dend[7]) h.pt3dadd(-298, 286.5, 61, 1.6, sec = self.dend[7]) h.pt3dadd(-298.5, 288.5, 61, 1.3, sec = self.dend[7]) h.pt3dadd(-300.5, 290.5, 63, 1.8, sec = self.dend[7]) h.pt3dadd(-301.5, 294, 63, 1.8, sec = self.dend[7]) h.pt3dadd(-301.5, 295.5, 63, 1.7, sec = self.dend[7]) h.pt3dadd(-303, 296.5, 61, 2.2, sec = self.dend[7]) h.pt3dadd(-304.5, 298, 63, 4.1, sec = self.dend[7]) h.pt3dadd(-306.5, 299, 63, 3.6, sec = self.dend[7]) h.pt3dadd(-308, 302.5, 59.5, 2.2, sec = self.dend[7]) h.pt3dadd(-307.5, 303.5, 61, 0.1, sec = self.dend[7]) h.pt3dadd(-307.5, 307, 61, 0.1, sec = self.dend[7]) h.pt3dadd(-309.5, 307, 63, 0.1, sec = self.dend[7]) h.pt3dadd(-312.5, 311, 63, 2.8, sec = self.dend[7]) h.pt3dadd(-312.5, 314, 63, 2.5, sec = self.dend[7]) h.pt3dadd(-314.5, 315, 64.5, 1.9, sec = self.dend[7]) h.pt3dadd(-317.5, 318, 66, 1.3, sec = self.dend[7]) h.pt3dadd(-319, 319.5, 67.5, 1.7, sec = self.dend[7]) h.pt3dadd(-321.5, 322, 67.5, 1.8, sec = self.dend[7]) h.pt3dadd(-323, 324, 69, 1.5, sec = self.dend[7]) h.pt3dadd(-325.5, 325.5, 70.5, 1.5, sec = self.dend[7]) h.pt3dadd(-326.5, 327.5, 66, 2.5, sec = self.dend[7]) h.pt3dadd(-329.5, 331, 66, 2.2, sec = self.dend[7]) h.pt3dadd(-331.5, 333, 67.5, 2.2, sec = self.dend[7]) h.pt3dadd(-333.5, 333.5, 66, 1.6, sec = self.dend[7]) h.pt3dadd(-337, 334, 66, 1.4, sec = self.dend[7]) h.pt3dadd(-339.5, 337.5, 66, 1.4, sec = self.dend[7]) h.pt3dadd(-342.5, 340, 66, 1.5, sec = self.dend[7]) h.pt3dadd(-342.5, 343, 63, 1.9, sec = self.dend[7]) h.pt3dadd(-343.5, 343, 66, 3.4, sec = self.dend[7]) h.pt3dadd(-345.5, 343.5, 63, 3.7, sec = self.dend[7]) h.pt3dadd(-347, 345, 64.5, 2.5, sec = self.dend[7]) h.pt3dadd(-348.5, 346, 69, 2.3, sec = self.dend[7]) h.pt3dadd(-352.5, 347.5, 66, 1.6, sec = self.dend[7]) h.pt3dadd(-355, 349.5, 69, 1.7, sec = self.dend[7]) h.pt3dadd(-358, 351.5, 69, 2, sec = self.dend[7]) h.pt3dadd(-361, 353.5, 70.5, 2, sec = self.dend[7]) h.pt3dadd(-364.5, 353, 67.5, 1.3, sec = self.dend[7]) h.pt3dadd(-366, 353, 67.5, 1.4, sec = self.dend[7]) h.pt3dadd(-368, 354, 70.5, 1.7, sec = self.dend[7]) h.pt3dadd(-370.5, 355, 70.5, 2.5, sec = self.dend[7]) h.pt3dadd(-372, 355, 70.5, 1.8, sec = self.dend[7]) h.pt3dadd(-375.5, 356.5, 72, 1.4, sec = self.dend[7]) h.pt3dadd(-379, 358.5, 72, 1.4, sec = self.dend[7]) h.pt3dadd(-382.5, 359.5, 72, 1.6, sec = self.dend[7]) h.pt3dadd(-386, 360, 72, 1.4, sec = self.dend[7]) h.pt3dadd(-387.5, 361.5, 72, 1.2, sec = self.dend[7]) h.pt3dadd(-388, 362, 72, 1.9, sec = self.dend[7]) h.pt3dadd(-390.5, 364.5, 73.5, 3.1, sec = self.dend[7]) h.pt3dadd(-391.5, 367, 72, 1.9, sec = self.dend[7]) h.pt3dadd(-394, 367.5, 73.5, 0.9, sec = self.dend[7]) h.pt3dadd(-397, 367.5, 75, 1.3, sec = self.dend[7]) h.pt3dadd(-398.5, 368.5, 73.5, 2.4, sec = self.dend[7]) h.pt3dadd(-400.5, 370.5, 69, 4.1, sec = self.dend[7]) h.pt3dadd(-403.5, 373, 69, 1.4, sec = self.dend[7]) h.pt3dadd(-405, 376.5, 70.5, 1, sec = self.dend[7]) h.pt3dadd(-407.5, 376, 70.5, 1, sec = self.dend[7]) h.pt3dadd(-412.5, 373, 72, 1.7, sec = self.dend[7]) h.pt3dadd(-414.5, 374, 72, 1.8, sec = self.dend[7]) h.pt3dadd(-416.5, 374.5, 73.5, 2.7, sec = self.dend[7]) h.pt3dadd(-419.5, 375.5, 75, 0.7, sec = self.dend[7]) h.pt3dadd(-423, 377, 75, 0.8, sec = self.dend[7]) h.pt3dadd(-422, 380.5, 75, 0.8, sec = self.dend[7]) h.pt3dadd(-423, 381, 76.5, 2, sec = self.dend[7]) h.pt3dadd(-425, 383.5, 78, 2.4, sec = self.dend[7]) h.pt3dadd(-424.5, 384.5, 78, 2.8, sec = self.dend[7]) h.pt3dadd(-424.5, 386.5, 78, 1.9, sec = self.dend[7]) h.pt3dadd(-426, 389.5, 78, 1.2, sec = self.dend[7]) h.pt3dadd(-428, 391, 78, 1.2, sec = self.dend[7]) h.pt3dadd(-431.5, 391.5, 78, 1.2, sec = self.dend[7]) h.pt3dadd(-433, 391.5, 78, 1.2, sec = self.dend[7]) h.pt3dadd(-439.5, 391.5, 68, 2.2, sec = self.dend[7]) h.pt3dadd(-441, 390.5, 68, 1.8, sec = self.dend[7]) h.pt3dadd(-443.5, 389.5, 68, 1.8, sec = self.dend[7]) h.pt3dadd(-446, 389.5, 68, 1.4, sec = self.dend[7]) h.pt3dadd(-446.5, 386.5, 80, 1.8, sec = self.dend[7]) h.pt3dadd(-447.5, 386, 80, 2.7, sec = self.dend[7]) h.pt3dadd(-449.5, 384.5, 84, 1.9, sec = self.dend[7]) h.pt3dadd(-451, 383, 82, 1.2, sec = self.dend[7]) h.pt3dadd(-452.5, 381, 82, 1.2, sec = self.dend[7]) h.pt3dadd(-453.5, 382, 86, 1.1, sec = self.dend[7]) h.pt3dadd(-454, 382.5, 86, 1.6, sec = self.dend[7]) h.pt3dadd(-455, 380.5, 86, 1.4, sec = self.dend[7]) h.pt3dadd(-456.5, 380.5, 86, 0.7, sec = self.dend[7]) h.pt3dadd(-458.5, 380.5, 86, 0.8, sec = self.dend[7]) h.pt3dadd(-460, 378.5, 86, 0.9, sec = self.dend[7]) h.pt3dadd(-461.5, 377.5, 86, 1.1, sec = self.dend[7]) h.pt3dadd(-464, 377.5, 86, 1.6, sec = self.dend[7]) h.pt3dadd(-466.5, 376, 86, 2.2, sec = self.dend[7]) h.pt3dadd(-469, 376, 86, 1.6, sec = self.dend[7]) h.pt3dadd(-470.5, 377.5, 90, 1.1, sec = self.dend[7]) h.pt3dadd(-472, 377.5, 88, 0.8, sec = self.dend[7]) h.pt3dadd(-475, 377.5, 88, 0.8, sec = self.dend[7]) h.pt3dadd(-476.5, 377.5, 94, 1.6, sec = self.dend[7]) h.pt3dadd(-479.5, 377.5, 102, 2.1, sec = self.dend[7]) h.pt3dadd(-481.5, 376, 102, 1.9, sec = self.dend[7]) h.pt3dadd(-485, 376, 102, 1.9, sec = self.dend[7]) h.pt3dadd(-486, 375, 100.5, 1.9, sec = self.dend[7]) h.pt3dadd(-487, 374.5, 100.5, 1.2, sec = self.dend[7]) h.pt3dadd(-488, 374, 100.5, 1.1, sec = self.dend[7]) h.pt3dadd(-490, 374.5, 102, 1.9, sec = self.dend[7]) h.pt3dadd(-491, 374.5, 102, 2.6, sec = self.dend[7]) h.pt3dadd(-493, 374, 102, 1.5, sec = self.dend[7]) h.pt3dadd(-495, 374, 102, 0.7, sec = self.dend[7]) h.pt3dadd(-496.5, 374, 102, 0.8, sec = self.dend[7]) h.pt3dadd(-499, 373.5, 102, 1.6, sec = self.dend[7]) h.pt3dadd(-502, 374, 104.5, 2.3, sec = self.dend[7]) h.pt3dadd(-503.5, 374, 104.5, 1.2, sec = self.dend[7]) h.pt3dadd(-504.5, 374, 104.5, 0.3, sec = self.dend[7]) h.pt3dadd(-506, 374, 104.5, 0.3, sec = self.dend[7]) h.pt3dadd(-506, 374.5, 106, 1.3, sec = self.dend[7]) h.pt3dadd(-506, 376, 106, 2.2, sec = self.dend[7]) h.pt3dadd(-507, 376.5, 106, 2.5, sec = self.dend[7]) h.pt3dadd(-508.5, 377, 106, 1.6, sec = self.dend[7]) h.pt3dadd(-509.5, 378.5, 107.5, 0.9, sec = self.dend[7]) h.pt3dadd(-511, 378.5, 107.5, 0.6, sec = self.dend[7]) h.pt3dadd(-512.5, 379, 107.5, 0.6, sec = self.dend[7]) h.pt3dadd(-513, 379, 108.5, 0.9, sec = self.dend[7]) h.pt3dadd(-514.5, 381, 110, 2.6, sec = self.dend[7]) h.pt3dadd(-516, 382, 110, 1, sec = self.dend[7]) h.pt3dadd(-517.5, 384, 110, 1, sec = self.dend[7]) h.pt3dadd(-518, 385, 110, 1.4, sec = self.dend[7]) h.pt3dadd(-520, 385, 110, 1.6, sec = self.dend[7]) h.pt3dadd(-520.5, 387, 110, 1.1, sec = self.dend[7]) h.pt3dadd(-523, 388.5, 111, 0.6, sec = self.dend[7]) h.pt3dadd(-525.5, 388.5, 111, 0.6, sec = self.dend[7]) h.pt3dadd(-527, 389, 111, 0.6, sec = self.dend[7]) h.pt3dadd(-530.5, 389.5, 111, 0.6, sec = self.dend[7]) h.pt3dadd(-531, 390.5, 111, 1.4, sec = self.dend[7]) h.pt3dadd(-533, 390.5, 111, 2.2, sec = self.dend[7]) h.pt3dadd(-534, 390.5, 111, 1.1, sec = self.dend[7]) h.pt3dadd(-534.5, 390.5, 111, 0.3, sec = self.dend[7]) h.pt3dadd(-537.5, 391, 111, 0.3, sec = self.dend[7]) h.pt3dadd(-539.5, 391.5, 112.5, 1.1, sec = self.dend[7]) h.pt3dadd(-542, 392, 112.5, 0.5, sec = self.dend[7]) h.pt3dadd(-543.5, 392, 112.5, 0.5, sec = self.dend[7]) h.pt3dadd(-545.5, 393.5, 114, 2, sec = self.dend[7]) h.pt3dadd(-547.5, 393, 114, 2, sec = self.dend[7]) h.pt3dadd(-549.5, 392, 112.5, 1.3, sec = self.dend[7]) h.pt3dadd(-551, 392, 112.5, 0.4, sec = self.dend[7]) h.pt3dadd(-553, 392, 112.5, 0.4, sec = self.dend[7]) h.pt3dadd(-553.5, 392, 112.5, 1.6, sec = self.dend[7]) h.pt3dadd(-555, 392, 114, 2.3, sec = self.dend[7]) h.pt3dadd(-558, 392.5, 116.5, 1.6, sec = self.dend[7]) h.pt3dadd(-560, 394.5, 119, 0.7, sec = self.dend[7]) h.pt3dadd(-562.5, 396, 119, 1.1, sec = self.dend[7]) h.pt3dadd(-564, 396, 120.5, 1.1, sec = self.dend[7]) h.pt3dadd(-566, 398.5, 118, 1.2, sec = self.dend[7]) h.pt3dadd(-568, 398.5, 118, 1.4, sec = self.dend[7]) h.pt3dadd(-570, 401.5, 118, 1.2, sec = self.dend[7]) h.pt3dadd(-571, 403.5, 116.5, 1.1, sec = self.dend[7]) h.pt3dclear(sec = self.dend[8]) h.pt3dadd(-226.5, 150.5, 48.5, 7.4, sec = self.dend[8]) h.pt3dadd(-235.5, 153, 50, 3.2, sec = self.dend[8]) h.pt3dadd(-239, 155.5, 51.5, 2.3, sec = self.dend[8]) h.pt3dadd(-242, 158.5, 51.5, 3, sec = self.dend[8]) h.pt3dadd(-246.5, 160, 51.5, 3.7, sec = self.dend[8]) h.pt3dadd(-251, 161.5, 51.5, 3.6, sec = self.dend[8]) h.pt3dadd(-255, 164.5, 51.5, 2.7, sec = self.dend[8]) h.pt3dadd(-260, 167.5, 51.5, 2.9, sec = self.dend[8]) h.pt3dadd(-263, 171, 52.5, 3.5, sec = self.dend[8]) h.pt3dadd(-266, 173, 54, 3.5, sec = self.dend[8]) h.pt3dadd(-268, 175.5, 54, 2.9, sec = self.dend[8]) h.pt3dadd(-270.5, 176, 54, 2.3, sec = self.dend[8]) h.pt3dadd(-272.5, 179.5, 48.5, 3.8, sec = self.dend[8]) h.pt3dadd(-276, 183, 50, 4.2, sec = self.dend[8]) h.pt3dadd(-278.5, 185.5, 50, 4.2, sec = self.dend[8]) h.pt3dadd(-281, 189, 50, 1.9, sec = self.dend[8]) h.pt3dadd(-283, 192, 51.5, 2.1, sec = self.dend[8]) h.pt3dadd(-285.5, 194, 51.5, 1.7, sec = self.dend[8]) h.pt3dadd(-286.5, 196.5, 51.5, 2, sec = self.dend[8]) h.pt3dadd(-288.5, 198, 50, 2.8, sec = self.dend[8]) h.pt3dadd(-290, 201.5, 51.5, 3.8, sec = self.dend[8]) h.pt3dadd(-292, 204, 51.5, 4.1, sec = self.dend[8]) h.pt3dadd(-293.5, 206.5, 51.5, 3.5, sec = self.dend[8]) h.pt3dadd(-294.5, 210, 51.5, 3.3, sec = self.dend[8]) h.pt3dadd(-295, 212, 51.5, 3.7, sec = self.dend[8]) h.pt3dadd(-297.5, 214, 53.5, 2.7, sec = self.dend[8]) h.pt3dadd(-298.5, 216.5, 53.5, 1.7, sec = self.dend[8]) h.pt3dadd(-300.5, 219, 53.5, 1.3, sec = self.dend[8]) h.pt3dadd(-302.5, 221, 60.5, 2.4, sec = self.dend[8]) h.pt3dadd(-303, 222.5, 60.5, 3.8, sec = self.dend[8]) h.pt3dadd(-304.5, 223.5, 60.5, 3.8, sec = self.dend[8]) h.pt3dadd(-305.5, 225.5, 60.5, 2, sec = self.dend[8]) h.pt3dadd(-308, 227.5, 60.5, 1.7, sec = self.dend[8]) h.pt3dadd(-309.5, 228, 67.5, 1.9, sec = self.dend[8]) h.pt3dadd(-310.5, 231.5, 69.5, 2.9, sec = self.dend[8]) h.pt3dadd(-313.5, 234, 67.5, 2.8, sec = self.dend[8]) h.pt3dadd(-317.5, 236.5, 67.5, 2.3, sec = self.dend[8]) h.pt3dadd(-322, 239, 67.5, 2.1, sec = self.dend[8]) h.pt3dadd(-324.5, 239, 67.5, 3.5, sec = self.dend[8]) h.pt3dadd(-326.5, 239, 67.5, 3.8, sec = self.dend[8]) h.pt3dadd(-328, 239.5, 67.5, 4.4, sec = self.dend[8]) h.pt3dadd(-331, 240, 67.5, 4.1, sec = self.dend[8]) h.pt3dadd(-333.5, 242, 71, 2.9, sec = self.dend[8]) h.pt3dadd(-334.5, 242, 69.5, 1.2, sec = self.dend[8]) h.pt3dadd(-336, 242.5, 69.5, 1.2, sec = self.dend[8]) h.pt3dadd(-338.5, 244.5, 69.5, 1.2, sec = self.dend[8]) h.pt3dadd(-339.5, 245, 71, 3.8, sec = self.dend[8]) h.pt3dadd(-343.5, 247, 66, 3.8, sec = self.dend[8]) h.pt3dadd(-346, 249.5, 67.5, 3.4, sec = self.dend[8]) h.pt3dadd(-349, 250, 67.5, 1.9, sec = self.dend[8]) h.pt3dadd(-352, 252, 69.5, 1.9, sec = self.dend[8]) h.pt3dadd(-354, 254.5, 62.5, 1.9, sec = self.dend[8]) h.pt3dadd(-355.5, 258, 64, 3.1, sec = self.dend[8]) h.pt3dadd(-356.5, 260, 64, 3.3, sec = self.dend[8]) h.pt3dadd(-358.5, 266, 71, 3.5, sec = self.dend[8]) h.pt3dadd(-360.5, 268.5, 71, 4.7, sec = self.dend[8]) h.pt3dadd(-364, 272, 74, 5.2, sec = self.dend[8]) h.pt3dclear(sec = self.dend[9]) h.pt3dadd(-364, 272, 74, 5.2, sec = self.dend[9]) h.pt3dadd(-368.5, 276, 75.5, 1.1, sec = self.dend[9]) h.pt3dadd(-370, 277.5, 74, 0.9, sec = self.dend[9]) h.pt3dadd(-370, 278.5, 72.5, 1.4, sec = self.dend[9]) h.pt3dadd(-372, 279.5, 75.5, 2.1, sec = self.dend[9]) h.pt3dadd(-373, 282, 74, 2.1, sec = self.dend[9]) h.pt3dadd(-374, 285.5, 74, 1.3, sec = self.dend[9]) h.pt3dadd(-375, 288, 75.5, 0.4, sec = self.dend[9]) h.pt3dadd(-375, 289, 75.5, 0.4, sec = self.dend[9]) h.pt3dadd(-375.5, 291, 75.5, 0.4, sec = self.dend[9]) h.pt3dadd(-377, 292.5, 80, 2.3, sec = self.dend[9]) h.pt3dadd(-378, 294, 77, 2.9, sec = self.dend[9]) h.pt3dadd(-380.5, 297, 75.5, 1.6, sec = self.dend[9]) h.pt3dadd(-381, 299, 77, 1.1, sec = self.dend[9]) h.pt3dadd(-383, 300.5, 77, 1.2, sec = self.dend[9]) h.pt3dadd(-384.5, 301, 74, 1.9, sec = self.dend[9]) h.pt3dadd(-386.5, 302.5, 75.5, 2.7, sec = self.dend[9]) h.pt3dadd(-388, 305, 77, 1.3, sec = self.dend[9]) h.pt3dadd(-388.5, 306.5, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-389.5, 308.5, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-392.5, 309, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-394.5, 310, 78.5, 1.7, sec = self.dend[9]) h.pt3dadd(-397.5, 311, 80, 0.9, sec = self.dend[9]) h.pt3dadd(-399.5, 310.5, 75.5, 0.9, sec = self.dend[9]) h.pt3dadd(-404.5, 311, 77, 1.2, sec = self.dend[9]) h.pt3dadd(-405.5, 312, 77, 1.2, sec = self.dend[9]) h.pt3dadd(-406, 313, 81.5, 1.4, sec = self.dend[9]) h.pt3dadd(-408, 314, 78.5, 1.6, sec = self.dend[9]) h.pt3dadd(-408.5, 315.5, 80, 1.4, sec = self.dend[9]) h.pt3dadd(-410, 315.5, 80, 0.2, sec = self.dend[9]) h.pt3dadd(-410.5, 317, 80, 0.2, sec = self.dend[9]) h.pt3dadd(-412.5, 317, 74, 1.4, sec = self.dend[9]) h.pt3dadd(-412.5, 319, 75.5, 1.5, sec = self.dend[9]) h.pt3dadd(-414, 320.5, 75.5, 1.5, sec = self.dend[9]) h.pt3dadd(-415.5, 322.5, 77, 0.7, sec = self.dend[9]) h.pt3dadd(-416.5, 324.5, 77, 0.7, sec = self.dend[9]) h.pt3dadd(-417.5, 324.5, 77, 2.4, sec = self.dend[9]) h.pt3dadd(-420, 325.5, 78.5, 3.4, sec = self.dend[9]) h.pt3dadd(-422, 328, 78.5, 2.4, sec = self.dend[9]) h.pt3dadd(-424, 330, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-427.5, 331.5, 78.5, 0.9, sec = self.dend[9]) h.pt3dadd(-430.5, 333.5, 78.5, 0.9, sec = self.dend[9]) h.pt3dadd(-433, 335.5, 78.5, 0.9, sec = self.dend[9]) h.pt3dadd(-434.5, 335.5, 78.5, 2.5, sec = self.dend[9]) h.pt3dadd(-435.5, 337, 80, 4.3, sec = self.dend[9]) h.pt3dadd(-437.5, 337.5, 80, 2.5, sec = self.dend[9]) h.pt3dadd(-440, 339, 80, 0.3, sec = self.dend[9]) h.pt3dadd(-441.5, 341.5, 80, 0.9, sec = self.dend[9]) h.pt3dadd(-444, 341.5, 81.5, 1.2, sec = self.dend[9]) h.pt3dadd(-445, 341.5, 81.5, 1.2, sec = self.dend[9]) h.pt3dadd(-447.5, 344, 81.5, 1.2, sec = self.dend[9]) h.pt3dadd(-449.5, 345.5, 81.5, 1.2, sec = self.dend[9]) h.pt3dadd(-450, 347, 81.5, 2.1, sec = self.dend[9]) h.pt3dadd(-452.5, 350, 83, 3.7, sec = self.dend[9]) h.pt3dadd(-454.5, 351, 81.5, 0.9, sec = self.dend[9]) h.pt3dadd(-456, 351, 81.5, 0.6, sec = self.dend[9]) h.pt3dadd(-459, 350.5, 83, 0.6, sec = self.dend[9]) h.pt3dadd(-462, 352, 86, 1.4, sec = self.dend[9]) h.pt3dadd(-464, 354.5, 81.5, 2.3, sec = self.dend[9]) h.pt3dadd(-466.5, 355, 83, 1.2, sec = self.dend[9]) h.pt3dadd(-467, 355, 83, 1, sec = self.dend[9]) h.pt3dadd(-469.5, 356, 83, 1, sec = self.dend[9]) h.pt3dadd(-473, 355, 84.5, 2.8, sec = self.dend[9]) h.pt3dadd(-474, 356.5, 83, 1.1, sec = self.dend[9]) h.pt3dadd(-474.5, 361, 83, 0.8, sec = self.dend[9]) h.pt3dadd(-476.5, 361, 83, 0.8, sec = self.dend[9]) h.pt3dadd(-476.5, 363, 86, 2.1, sec = self.dend[9]) h.pt3dadd(-478.5, 363, 84.5, 1.5, sec = self.dend[9]) h.pt3dadd(-479, 363.5, 84.5, 0.4, sec = self.dend[9]) h.pt3dadd(-481, 364, 84.5, 0.4, sec = self.dend[9]) h.pt3dadd(-483.5, 367.5, 83, 0.5, sec = self.dend[9]) h.pt3dadd(-484, 368.5, 86, 1.4, sec = self.dend[9]) h.pt3dadd(-485, 368.5, 86, 1.4, sec = self.dend[9]) h.pt3dadd(-486.5, 368.5, 86, 0.7, sec = self.dend[9]) h.pt3dadd(-489.5, 369, 86, 0.6, sec = self.dend[9]) h.pt3dadd(-490, 369, 86, 0.6, sec = self.dend[9]) h.pt3dadd(-491.5, 370.5, 87.5, 1.7, sec = self.dend[9]) h.pt3dadd(-493.5, 371.5, 81.5, 1.9, sec = self.dend[9]) h.pt3dadd(-495, 372.5, 81.5, 1.2, sec = self.dend[9]) h.pt3dadd(-496, 374.5, 80, 0.7, sec = self.dend[9]) h.pt3dadd(-499.5, 377, 80, 0.7, sec = self.dend[9]) h.pt3dadd(-501.5, 376.5, 80, 0.7, sec = self.dend[9]) h.pt3dadd(-502.5, 375.5, 78.5, 1.7, sec = self.dend[9]) h.pt3dadd(-502.5, 376.5, 78.5, 1.2, sec = self.dend[9]) h.pt3dadd(-504, 378.5, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-505, 379, 78.5, 0.7, sec = self.dend[9]) h.pt3dadd(-509, 381.5, 80, 1.3, sec = self.dend[9]) h.pt3dadd(-510, 384, 81.5, 1.4, sec = self.dend[9]) h.pt3dadd(-510, 385, 81.5, 0.8, sec = self.dend[9]) h.pt3dadd(-509, 386.5, 81.5, 0.8, sec = self.dend[9]) h.pt3dadd(-510, 388, 83, 1.1, sec = self.dend[9]) h.pt3dadd(-511, 389.5, 80, 1.3, sec = self.dend[9]) h.pt3dadd(-511.5, 391.5, 80, 1.3, sec = self.dend[9]) h.pt3dadd(-512, 394, 80, 0.6, sec = self.dend[9]) h.pt3dadd(-510, 394.5, 80, 0.6, sec = self.dend[9]) h.pt3dadd(-509.5, 395.5, 80, 0.6, sec = self.dend[9]) h.pt3dadd(-511, 399, 80, 1.1, sec = self.dend[9]) h.pt3dadd(-508, 400.5, 80, 1.1, sec = self.dend[9]) h.pt3dadd(-507.5, 402.5, 80, 1.2, sec = self.dend[9]) h.pt3dadd(-506.5, 404, 81.5, 1.6, sec = self.dend[9]) h.pt3dadd(-506.5, 406, 83, 2.7, sec = self.dend[9]) h.pt3dadd(-508, 407, 83, 1.4, sec = self.dend[9]) h.pt3dadd(-508.5, 407.5, 83, 0.9, sec = self.dend[9]) h.pt3dadd(-512, 409.5, 86, 2.2, sec = self.dend[9]) h.pt3dadd(-515, 411, 83, 0.8, sec = self.dend[9]) h.pt3dadd(-515.5, 412, 83, 0.8, sec = self.dend[9]) h.pt3dadd(-517.5, 411.5, 83, 1.2, sec = self.dend[9]) h.pt3dadd(-519.5, 413, 84.5, 1.6, sec = self.dend[9]) h.pt3dadd(-520.5, 413.5, 84.5, 1.3, sec = self.dend[9]) h.pt3dadd(-521.5, 415, 84.5, 0.9, sec = self.dend[9]) h.pt3dadd(-528, 416.5, 86, 0.7, sec = self.dend[9]) h.pt3dadd(-530.5, 416.5, 86, 0.7, sec = self.dend[9]) h.pt3dadd(-532.5, 416, 89, 1.6, sec = self.dend[9]) h.pt3dadd(-534.5, 416, 83, 2.7, sec = self.dend[9]) h.pt3dadd(-535.5, 417, 83, 1.5, sec = self.dend[9]) h.pt3dadd(-536, 417.5, 83, 0.7, sec = self.dend[9]) h.pt3dadd(-538, 419.5, 83, 0.9, sec = self.dend[9]) h.pt3dadd(-539, 420, 84.5, 1.4, sec = self.dend[9]) h.pt3dadd(-540.5, 421, 86, 2.2, sec = self.dend[9]) h.pt3dadd(-543, 423, 83, 1.1, sec = self.dend[9]) h.pt3dadd(-542.5, 424, 83, 0.6, sec = self.dend[9]) h.pt3dadd(-544.5, 424.5, 81.5, 0.6, sec = self.dend[9]) h.pt3dadd(-545.5, 424.5, 83, 1.8, sec = self.dend[9]) h.pt3dadd(-546.5, 425, 84.5, 2.7, sec = self.dend[9]) h.pt3dadd(-549.5, 427, 84.5, 1.7, sec = self.dend[9]) h.pt3dadd(-551.5, 428.5, 84.5, 0.5, sec = self.dend[9]) h.pt3dadd(-551.5, 429, 84.5, 0.5, sec = self.dend[9]) h.pt3dadd(-553.5, 429, 84.5, 0.5, sec = self.dend[9]) h.pt3dadd(-555.5, 430, 86, 2.2, sec = self.dend[9]) h.pt3dadd(-555.5, 431, 87.5, 3.3, sec = self.dend[9]) h.pt3dadd(-556, 432, 87.5, 2, sec = self.dend[9]) h.pt3dadd(-557, 435, 87.5, 1, sec = self.dend[9]) h.pt3dadd(-558.5, 437, 83, 1, sec = self.dend[9]) h.pt3dadd(-560.5, 438, 83, 1, sec = self.dend[9]) h.pt3dadd(-561.5, 439.5, 84.5, 1.1, sec = self.dend[9]) h.pt3dadd(-562.5, 442.5, 84.5, 1.1, sec = self.dend[9]) h.pt3dadd(-563, 443.5, 84.5, 1.2, sec = self.dend[9]) h.pt3dadd(-565, 444, 84.5, 1.2, sec = self.dend[9]) h.pt3dadd(-567.5, 446.5, 84.5, 1.2, sec = self.dend[9]) h.pt3dadd(-570.5, 448, 87.5, 1.1, sec = self.dend[9]) h.pt3dadd(-571, 451.5, 85.5, 0.1, sec = self.dend[9]) h.pt3dadd(-573.5, 456.5, 85.5, 0.1, sec = self.dend[9]) h.pt3dadd(-573.5, 457.5, 85.5, 0.1, sec = self.dend[9]) h.pt3dadd(-573.5, 460.5, 85.5, 0.1, sec = self.dend[9]) h.pt3dadd(-574.5, 464, 85.5, 0.1, sec = self.dend[9]) h.pt3dadd(-574, 464.5, 101.5, 1.3, sec = self.dend[9]) h.pt3dadd(-574, 465, 103.5, 2.3, sec = self.dend[9]) h.pt3dadd(-573.5, 467.5, 101.5, 0.1, sec = self.dend[9]) h.pt3dadd(-572.5, 467.5, 99.5, 0.1, sec = self.dend[9]) h.pt3dadd(-570.5, 471, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-572.5, 476, 89.5, 0.1, sec = self.dend[9]) h.pt3dadd(-572.5, 478, 89.5, 0.1, sec = self.dend[9]) h.pt3dadd(-569, 481, 89.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 482.5, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 485, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 487.5, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 490.5, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 493, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 495, 91.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 500.5, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 504, 93.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 509.5, 91.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567.5, 510, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-567, 513, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-565.5, 515.5, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-564, 517, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-564, 519.5, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-564, 521, 97.5, 0.1, sec = self.dend[9]) h.pt3dadd(-564, 523, 99.5, 1.2, sec = self.dend[9]) h.pt3dadd(-563, 524, 99.5, 0.1, sec = self.dend[9]) h.pt3dadd(-562, 529, 101.5, 0.1, sec = self.dend[9]) h.pt3dclear(sec = self.dend[10]) h.pt3dadd(-364, 272, 74, 5.2, sec = self.dend[10]) h.pt3dadd(-369, 274, 69.5, 1.8, sec = self.dend[10]) h.pt3dadd(-371, 275, 69.5, 2.2, sec = self.dend[10]) h.pt3dadd(-374, 277.5, 69.5, 2.2, sec = self.dend[10]) h.pt3dadd(-374.5, 280, 69.5, 1.6, sec = self.dend[10]) h.pt3dadd(-376.5, 279.5, 72.5, 1.5, sec = self.dend[10]) h.pt3dadd(-381.5, 283, 74, 3.7, sec = self.dend[10]) h.pt3dadd(-384.5, 283, 72.5, 2.4, sec = self.dend[10]) h.pt3dadd(-386, 283, 72.5, 1.5, sec = self.dend[10]) h.pt3dadd(-389.5, 283.5, 72.5, 1.1, sec = self.dend[10]) h.pt3dadd(-391.5, 284, 74, 1.3, sec = self.dend[10]) h.pt3dadd(-394, 286, 74, 1.6, sec = self.dend[10]) h.pt3dadd(-397, 288.5, 74, 1.9, sec = self.dend[10]) h.pt3dadd(-399.5, 289, 77, 2.5, sec = self.dend[10]) h.pt3dadd(-402, 289.5, 77, 2.6, sec = self.dend[10]) h.pt3dadd(-404, 291.5, 78.5, 3.8, sec = self.dend[10]) h.pt3dadd(-406.5, 291, 78.5, 2.6, sec = self.dend[10]) h.pt3dadd(-409, 292, 78.5, 1.7, sec = self.dend[10]) h.pt3dadd(-411, 292.5, 78.5, 1.3, sec = self.dend[10]) h.pt3dadd(-412.5, 292, 78.5, 1.3, sec = self.dend[10]) h.pt3dadd(-413, 293, 80, 2.7, sec = self.dend[10]) h.pt3dadd(-415, 293, 80, 1.5, sec = self.dend[10]) h.pt3dadd(-417.5, 295.5, 80, 2.4, sec = self.dend[10]) h.pt3dadd(-420, 296, 80, 1.6, sec = self.dend[10]) h.pt3dadd(-423, 296.5, 80, 1.6, sec = self.dend[10]) h.pt3dadd(-424, 298.5, 81.5, 2.2, sec = self.dend[10]) h.pt3dadd(-426.5, 300.5, 84.5, 2.5, sec = self.dend[10]) h.pt3dadd(-429.5, 301.5, 81.5, 1.7, sec = self.dend[10]) h.pt3dadd(-430, 304.5, 83, 1.7, sec = self.dend[10]) h.pt3dadd(-432.5, 306.5, 84.5, 1.7, sec = self.dend[10]) h.pt3dadd(-434.5, 307.5, 86, 2, sec = self.dend[10]) h.pt3dadd(-435, 309.5, 86, 2.3, sec = self.dend[10]) h.pt3dadd(-437, 310.5, 87.5, 1.9, sec = self.dend[10]) h.pt3dadd(-438.5, 311.5, 87.5, 1, sec = self.dend[10]) h.pt3dadd(-439.5, 312, 87.5, 1, sec = self.dend[10]) h.pt3dadd(-442, 311, 87.5, 1.3, sec = self.dend[10]) h.pt3dadd(-443, 312.5, 89, 2.1, sec = self.dend[10]) h.pt3dadd(-445, 313, 86, 2.7, sec = self.dend[10]) h.pt3dadd(-447, 315.5, 86, 1.9, sec = self.dend[10]) h.pt3dadd(-449, 316.5, 87.5, 0.9, sec = self.dend[10]) h.pt3dadd(-450.5, 318, 89, 1.8, sec = self.dend[10]) h.pt3dadd(-453, 318.5, 89, 2.4, sec = self.dend[10]) h.pt3dadd(-455, 318.5, 84.5, 2.8, sec = self.dend[10]) h.pt3dadd(-457.5, 317.5, 86, 1.6, sec = self.dend[10]) h.pt3dadd(-460, 318, 86, 1.3, sec = self.dend[10]) h.pt3dadd(-462, 318.5, 86, 1.7, sec = self.dend[10]) h.pt3dadd(-464.5, 320, 86, 1.7, sec = self.dend[10]) h.pt3dadd(-467, 321, 86, 1.7, sec = self.dend[10]) h.pt3dadd(-469, 322, 86, 2, sec = self.dend[10]) h.pt3dadd(-471.5, 322, 88, 2.5, sec = self.dend[10]) h.pt3dadd(-473.5, 323, 88, 2.7, sec = self.dend[10]) h.pt3dadd(-476.5, 323, 88, 2.6, sec = self.dend[10]) h.pt3dadd(-478.5, 323.5, 88, 1.6, sec = self.dend[10]) h.pt3dadd(-481, 325, 90, 0.3, sec = self.dend[10]) h.pt3dadd(-483, 326, 92, 0.2, sec = self.dend[10]) h.pt3dadd(-485, 326, 92, 0.4, sec = self.dend[10]) h.pt3dadd(-488, 326, 94, 0.5, sec = self.dend[10]) h.pt3dadd(-491, 327, 94, 0.5, sec = self.dend[10]) h.pt3dadd(-492.5, 328.5, 94, 1.5, sec = self.dend[10]) h.pt3dadd(-493.5, 329.5, 98, 2.8, sec = self.dend[10]) h.pt3dadd(-495.5, 330, 98, 3.4, sec = self.dend[10]) h.pt3dadd(-497.5, 331, 96, 2.3, sec = self.dend[10]) h.pt3dadd(-499.5, 332.5, 98, 1.4, sec = self.dend[10]) h.pt3dadd(-500.5, 333, 98, 0.7, sec = self.dend[10]) h.pt3dadd(-502, 334, 98, 1.1, sec = self.dend[10]) h.pt3dadd(-503, 335, 98, 1.5, sec = self.dend[10]) h.pt3dadd(-505.5, 335, 100, 2.2, sec = self.dend[10]) h.pt3dadd(-508, 336.5, 98, 1.9, sec = self.dend[10]) h.pt3dadd(-510, 336.5, 98, 1.2, sec = self.dend[10]) h.pt3dadd(-510.5, 337, 98, 0.6, sec = self.dend[10]) h.pt3dadd(-514.5, 337.5, 98, 0.8, sec = self.dend[10]) h.pt3dadd(-517, 338, 98, 0.8, sec = self.dend[10]) h.pt3dadd(-519.5, 338.5, 98, 0.9, sec = self.dend[10]) h.pt3dadd(-522, 341, 96, 0.9, sec = self.dend[10]) h.pt3dadd(-522.5, 341.5, 98, 1.4, sec = self.dend[10]) h.pt3dadd(-524, 343, 98, 0.7, sec = self.dend[10]) h.pt3dadd(-525.5, 343.5, 98, 0.7, sec = self.dend[10]) h.pt3dadd(-526.5, 345, 100, 2.4, sec = self.dend[10]) h.pt3dadd(-529.5, 346, 100, 4, sec = self.dend[10]) h.pt3dadd(-531, 349, 100, 2.5, sec = self.dend[10]) h.pt3dadd(-532, 351.5, 100, 1.3, sec = self.dend[10]) h.pt3dadd(-535.5, 352.5, 104, 0.7, sec = self.dend[10]) h.pt3dadd(-538, 353, 102, 1.5, sec = self.dend[10]) h.pt3dadd(-541.5, 353, 104, 2.7, sec = self.dend[10]) h.pt3dadd(-545.5, 353, 104, 1.6, sec = self.dend[10]) h.pt3dadd(-547.5, 354.5, 98, 0.8, sec = self.dend[10]) h.pt3dadd(-549.5, 355.5, 98, 0.8, sec = self.dend[10]) h.pt3dadd(-551, 356.5, 100, 2.2, sec = self.dend[10]) h.pt3dadd(-554, 357.5, 100, 3.5, sec = self.dend[10]) h.pt3dadd(-557, 359.5, 98, 1.8, sec = self.dend[10]) h.pt3dadd(-561, 359.5, 98, 1.1, sec = self.dend[10]) h.pt3dadd(-564.5, 359.5, 98, 1.3, sec = self.dend[10]) h.pt3dadd(-567.5, 358, 100, 1.5, sec = self.dend[10]) h.pt3dadd(-572.5, 358, 98, 1.4, sec = self.dend[10]) h.pt3dadd(-579.5, 358, 98, 1.4, sec = self.dend[10]) h.pt3dadd(-581.5, 357.5, 98, 2.3, sec = self.dend[10]) h.pt3dadd(-586, 356.5, 94, 2.6, sec = self.dend[10]) h.pt3dadd(-589, 357.5, 94, 1.5, sec = self.dend[10]) h.pt3dadd(-592, 358, 96, 1.2, sec = self.dend[10]) h.pt3dadd(-599, 359, 96, 1.6, sec = self.dend[10]) h.pt3dadd(-601.5, 359.5, 98, 1.2, sec = self.dend[10]) h.pt3dadd(-603.5, 361.5, 98, 1.2, sec = self.dend[10]) h.pt3dadd(-606.5, 364, 100, 1.6, sec = self.dend[10]) h.pt3dadd(-609.5, 366.5, 102, 2, sec = self.dend[10]) h.pt3dadd(-613, 367, 104, 2.2, sec = self.dend[10]) h.pt3dadd(-615.5, 367, 108, 4, sec = self.dend[10]) h.pt3dadd(-618, 367, 108, 2.2, sec = self.dend[10]) h.pt3dadd(-619.5, 369.5, 104, 0.5, sec = self.dend[10]) h.pt3dadd(-619.5, 371, 106, 0.7, sec = self.dend[10]) h.pt3dadd(-619.5, 373.5, 106, 0.7, sec = self.dend[10]) h.pt3dadd(-621.5, 374.5, 106, 1.1, sec = self.dend[10]) h.pt3dadd(-625, 376.5, 108, 1.7, sec = self.dend[10]) h.pt3dadd(-625.5, 378.5, 106, 1.5, sec = self.dend[10]) h.pt3dadd(-627, 378.5, 106, 1.7, sec = self.dend[10]) h.pt3dadd(-630.5, 378, 112, 1.7, sec = self.dend[10]) h.pt3dadd(-634, 378.5, 114.5, 2, sec = self.dend[10]) h.pt3dadd(-636.5, 381, 116, 1.8, sec = self.dend[10]) h.pt3dadd(-639.5, 382, 116, 2, sec = self.dend[10]) h.pt3dadd(-642, 383.5, 116, 2, sec = self.dend[10]) h.pt3dadd(-643, 384, 122.5, 2.2, sec = self.dend[10]) h.pt3dadd(-645, 384, 123.5, 2.8, sec = self.dend[10]) h.pt3dadd(-648, 384, 123.5, 1.5, sec = self.dend[10]) h.pt3dadd(-649, 385, 123.5, 0.8, sec = self.dend[10]) h.pt3dadd(-650.5, 385.5, 123.5, 0.8, sec = self.dend[10]) h.pt3dadd(-653.5, 385.5, 123.5, 0.8, sec = self.dend[10]) h.pt3dadd(-654.5, 385, 125, 1.7, sec = self.dend[10]) h.pt3dadd(-657, 385, 125, 2, sec = self.dend[10]) h.pt3dadd(-659.5, 385, 123.5, 3, sec = self.dend[10]) h.pt3dadd(-661.5, 386, 125, 2.1, sec = self.dend[10]) h.pt3dadd(-664, 386.5, 125, 1.8, sec = self.dend[10]) h.pt3dadd(-666, 387, 126.5, 1.8, sec = self.dend[10]) h.pt3dadd(-669, 386, 126.5, 1.8, sec = self.dend[10]) h.pt3dadd(-670.5, 387, 129, 0.8, sec = self.dend[10]) h.pt3dadd(-672, 386, 127.5, 1.7, sec = self.dend[10]) h.pt3dadd(-673.5, 385, 129, 2.8, sec = self.dend[10]) h.pt3dadd(-677.5, 384.5, 129, 1.4, sec = self.dend[10]) h.pt3dadd(-679, 384, 125, 0.4, sec = self.dend[10]) h.pt3dadd(-682.5, 384, 125, 0.4, sec = self.dend[10]) h.pt3dadd(-685.5, 384, 126.5, 0.7, sec = self.dend[10]) h.pt3dadd(-686, 386.5, 129, 2.5, sec = self.dend[10]) h.pt3dadd(-687.5, 387, 129, 3.4, sec = self.dend[10]) h.pt3dadd(-688.5, 389, 129, 2.6, sec = self.dend[10]) h.pt3dadd(-690.5, 391.5, 129, 1.1, sec = self.dend[10]) h.pt3dadd(-692, 394.5, 129, 0.7, sec = self.dend[10]) h.pt3dadd(-695, 397, 129, 0.7, sec = self.dend[10]) h.pt3dclear(sec = self.dend[11]) h.pt3dadd(-147, 77, 34, 9.9, sec = self.dend[11]) h.pt3dadd(-153, 73, 34, 3.3, sec = self.dend[11]) h.pt3dadd(-157, 74.5, 34, 3.7, sec = self.dend[11]) h.pt3dadd(-162, 75.5, 37, 4.5, sec = self.dend[11]) h.pt3dadd(-168, 76.5, 37, 5, sec = self.dend[11]) h.pt3dadd(-174, 77, 37, 5, sec = self.dend[11]) h.pt3dadd(-177.5, 77, 37, 4, sec = self.dend[11]) h.pt3dadd(-181.5, 77, 37, 4.1, sec = self.dend[11]) h.pt3dadd(-184.5, 79.5, 37, 4.3, sec = self.dend[11]) h.pt3dadd(-190, 82, 38.5, 4.9, sec = self.dend[11]) h.pt3dadd(-192.5, 83, 38.5, 4.9, sec = self.dend[11]) h.pt3dadd(-196, 85, 38.5, 4.3, sec = self.dend[11]) h.pt3dadd(-198.5, 86.5, 40, 5.2, sec = self.dend[11]) h.pt3dadd(-201.5, 88.5, 40, 4.9, sec = self.dend[11]) h.pt3dadd(-205.5, 90.5, 40, 4.8, sec = self.dend[11]) h.pt3dadd(-208, 91, 41.5, 5.8, sec = self.dend[11]) h.pt3dadd(-210, 94, 41.5, 5.6, sec = self.dend[11]) h.pt3dadd(-214.5, 95.5, 42.5, 4.7, sec = self.dend[11]) h.pt3dadd(-219, 96, 42.5, 4.7, sec = self.dend[11]) h.pt3dadd(-223.5, 96.5, 42.5, 5.1, sec = self.dend[11]) h.pt3dadd(-227, 98, 42.5, 5.8, sec = self.dend[11]) h.pt3dadd(-231.5, 98, 42.5, 5.8, sec = self.dend[11]) h.pt3dadd(-235, 98.5, 47, 5.6, sec = self.dend[11]) h.pt3dadd(-239, 102, 48.5, 5.6, sec = self.dend[11]) h.pt3dadd(-243, 102, 50, 5.6, sec = self.dend[11]) h.pt3dadd(-249.5, 104, 51.5, 5.6, sec = self.dend[11]) h.pt3dadd(-253, 104, 50, 5.6, sec = self.dend[11]) h.pt3dadd(-258, 105, 50, 4.7, sec = self.dend[11]) h.pt3dadd(-262, 106, 50, 4.7, sec = self.dend[11]) h.pt3dadd(-268, 107, 51.5, 5.7, sec = self.dend[11]) h.pt3dadd(-276, 109, 51.5, 5.7, sec = self.dend[11]) h.pt3dadd(-279, 109, 52.5, 6, sec = self.dend[11]) h.pt3dadd(-281.5, 109, 52.5, 4.8, sec = self.dend[11]) h.pt3dadd(-286.5, 108.5, 52.5, 5, sec = self.dend[11]) h.pt3dadd(-289, 109, 52.5, 3.6, sec = self.dend[11]) h.pt3dadd(-292, 109, 51.5, 4.5, sec = self.dend[11]) h.pt3dadd(-299.5, 109, 53.5, 5.7, sec = self.dend[11]) h.pt3dadd(-303, 109.5, 55.5, 5.2, sec = self.dend[11]) h.pt3dadd(-305.5, 111, 59, 5, sec = self.dend[11]) h.pt3dadd(-308, 112.5, 59, 5, sec = self.dend[11]) h.pt3dadd(-312, 112.5, 59, 4.6, sec = self.dend[11]) h.pt3dadd(-316.5, 112.5, 59, 4.6, sec = self.dend[11]) h.pt3dadd(-320.5, 112.5, 59, 4.3, sec = self.dend[11]) h.pt3dadd(-324, 112.5, 59, 5.2, sec = self.dend[11]) h.pt3dadd(-327, 112, 59, 5.3, sec = self.dend[11]) h.pt3dadd(-330.5, 112, 59, 5.3, sec = self.dend[11]) h.pt3dadd(-335.5, 112, 59, 5.8, sec = self.dend[11]) h.pt3dadd(-339.5, 113, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-343.5, 113.5, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-347.5, 114.5, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-352, 116, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-356, 116.5, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-359, 117.5, 60.5, 5.8, sec = self.dend[11]) h.pt3dadd(-361.5, 118, 60.5, 6, sec = self.dend[11]) h.pt3dadd(-364.5, 119.5, 62.5, 6.7, sec = self.dend[11]) h.pt3dadd(-367.5, 119.5, 62.5, 6.7, sec = self.dend[11]) h.pt3dadd(-368.5, 119.5, 62.5, 6.7, sec = self.dend[11]) h.pt3dadd(-374.5, 121.5, 71.5, 5.7, sec = self.dend[11]) h.pt3dadd(-381, 121.5, 71.5, 5.7, sec = self.dend[11]) h.pt3dadd(-384, 121.5, 71.5, 5.7, sec = self.dend[11]) h.pt3dadd(-388, 121.5, 71.5, 6.1, sec = self.dend[11]) h.pt3dadd(-392, 123, 71.5, 6.1, sec = self.dend[11]) h.pt3dadd(-395.5, 123, 71.5, 6.1, sec = self.dend[11]) h.pt3dadd(-399, 123, 71.5, 6.1, sec = self.dend[11]) h.pt3dadd(-405.5, 122.5, 70, 4.6, sec = self.dend[11]) h.pt3dadd(-409, 122.5, 70, 4.7, sec = self.dend[11]) h.pt3dadd(-412.5, 122.5, 70, 5.1, sec = self.dend[11]) h.pt3dadd(-415, 122.5, 71.5, 5.5, sec = self.dend[11]) h.pt3dadd(-418, 122, 71.5, 5.5, sec = self.dend[11]) h.pt3dadd(-420, 122.5, 70, 6, sec = self.dend[11]) h.pt3dclear(sec = self.dend[12]) h.pt3dadd(-420, 122.5, 70, 6, sec = self.dend[12]) h.pt3dadd(-422.5, 127, 70, 1.3, sec = self.dend[12]) h.pt3dadd(-423, 127, 70, 0.8, sec = self.dend[12]) h.pt3dadd(-424.5, 127, 70, 0.8, sec = self.dend[12]) h.pt3dadd(-427.5, 129, 76, 2.8, sec = self.dend[12]) h.pt3dadd(-428, 130, 76, 2.8, sec = self.dend[12]) h.pt3dadd(-429, 133, 76, 2.6, sec = self.dend[12]) h.pt3dadd(-430, 133.5, 76, 1.1, sec = self.dend[12]) h.pt3dadd(-429.5, 134.5, 74.5, 1.2, sec = self.dend[12]) h.pt3dadd(-430.5, 136, 71.5, 1.2, sec = self.dend[12]) h.pt3dadd(-433, 138, 76, 0.9, sec = self.dend[12]) h.pt3dadd(-432.5, 139, 73, 0.9, sec = self.dend[12]) h.pt3dadd(-432.5, 141, 74.5, 1.6, sec = self.dend[12]) h.pt3dadd(-432.5, 142.5, 76, 1.9, sec = self.dend[12]) h.pt3dadd(-432, 143, 76, 2.2, sec = self.dend[12]) h.pt3dadd(-431, 144, 76, 1.3, sec = self.dend[12]) h.pt3dadd(-431, 146.5, 76, 1.3, sec = self.dend[12]) h.pt3dadd(-431.5, 148.5, 76, 1.3, sec = self.dend[12]) h.pt3dadd(-431, 149.5, 76, 2.1, sec = self.dend[12]) h.pt3dadd(-432.5, 150.5, 76, 2.2, sec = self.dend[12]) h.pt3dadd(-434, 152.5, 77.5, 2.6, sec = self.dend[12]) h.pt3dadd(-434.5, 153, 77.5, 1.9, sec = self.dend[12]) h.pt3dadd(-436, 155.5, 77.5, 0.9, sec = self.dend[12]) h.pt3dadd(-436, 159, 77.5, 0.9, sec = self.dend[12]) h.pt3dadd(-436.5, 160, 77.5, 0.7, sec = self.dend[12]) h.pt3dadd(-436.5, 162, 77.5, 0.7, sec = self.dend[12]) h.pt3dadd(-436.5, 162.5, 83.5, 0.7, sec = self.dend[12]) h.pt3dadd(-437.5, 164, 83.5, 0.7, sec = self.dend[12]) h.pt3dadd(-437, 166, 83.5, 0.7, sec = self.dend[12]) h.pt3dadd(-439, 161, 83.5, 0.7, sec = self.dend[12]) h.pt3dadd(-438.5, 164.5, 83.5, 0.7, sec = self.dend[12]) h.pt3dadd(-439.5, 167, 83.5, 0.9, sec = self.dend[12]) h.pt3dadd(-440, 169, 83.5, 1, sec = self.dend[12]) h.pt3dadd(-441.5, 171, 83.5, 1, sec = self.dend[12]) h.pt3dadd(-441.5, 171.5, 83.5, 1, sec = self.dend[12]) h.pt3dadd(-441.5, 173.5, 83.5, 2.3, sec = self.dend[12]) h.pt3dadd(-443.5, 175, 86.5, 2.1, sec = self.dend[12]) h.pt3dadd(-444.5, 178.5, 88, 1.5, sec = self.dend[12]) h.pt3dadd(-445.5, 178.5, 88, 1, sec = self.dend[12]) h.pt3dadd(-447, 179.5, 86.5, 1.2, sec = self.dend[12]) h.pt3dadd(-449, 182.5, 88, 0.8, sec = self.dend[12]) h.pt3dadd(-448, 184, 88, 1.1, sec = self.dend[12]) h.pt3dadd(-449, 186.5, 83.5, 1.7, sec = self.dend[12]) h.pt3dadd(-449.5, 187.5, 86.5, 2.4, sec = self.dend[12]) h.pt3dadd(-449.5, 189.5, 86.5, 2.7, sec = self.dend[12]) h.pt3dadd(-451.5, 190.5, 86.5, 1.4, sec = self.dend[12]) h.pt3dadd(-452, 192.5, 89.5, 1.3, sec = self.dend[12]) h.pt3dadd(-454.5, 194, 89.5, 0.9, sec = self.dend[12]) h.pt3dadd(-455.5, 196.5, 88, 0.6, sec = self.dend[12]) h.pt3dadd(-457.5, 196.5, 88, 1.2, sec = self.dend[12]) h.pt3dadd(-458, 198, 89.5, 1.5, sec = self.dend[12]) h.pt3dadd(-458.5, 197, 91, 3.3, sec = self.dend[12]) h.pt3dadd(-462, 200, 89.5, 0.1, sec = self.dend[12]) h.pt3dadd(-462.5, 201.5, 88, 0.1, sec = self.dend[12]) h.pt3dadd(-462.5, 203.5, 91, 0.1, sec = self.dend[12]) h.pt3dadd(-463.5, 207.5, 95.5, 0.1, sec = self.dend[12]) h.pt3dadd(-465, 212.5, 97.5, 0.8, sec = self.dend[12]) h.pt3dadd(-466, 213, 97.5, 0.8, sec = self.dend[12]) h.pt3dadd(-466, 214.5, 95.5, 0.9, sec = self.dend[12]) h.pt3dadd(-466, 215.5, 95.5, 1.7, sec = self.dend[12]) h.pt3dadd(-467, 218, 93.5, 1.1, sec = self.dend[12]) h.pt3dadd(-467.5, 220, 93.5, 0.3, sec = self.dend[12]) h.pt3dadd(-468.5, 223.5, 99.5, 0.3, sec = self.dend[12]) h.pt3dadd(-469, 224.5, 95.5, 0.3, sec = self.dend[12]) h.pt3dadd(-470.5, 224.5, 95.5, 1.2, sec = self.dend[12]) h.pt3dadd(-471.5, 225.5, 95.5, 2.1, sec = self.dend[12]) h.pt3dadd(-472.5, 227.5, 101.5, 0.8, sec = self.dend[12]) h.pt3dadd(-472.5, 230.5, 97.5, 0.6, sec = self.dend[12]) h.pt3dadd(-472, 231, 95.5, 0.6, sec = self.dend[12]) h.pt3dadd(-472, 233.5, 99.5, 0.6, sec = self.dend[12]) h.pt3dadd(-471.5, 234, 97.5, 0.6, sec = self.dend[12]) h.pt3dadd(-471, 236, 97.5, 2.2, sec = self.dend[12]) h.pt3dadd(-470.5, 238, 99.5, 0.6, sec = self.dend[12]) h.pt3dadd(-470.5, 239, 99.5, 0.6, sec = self.dend[12]) h.pt3dadd(-469, 240.5, 97.5, 1.7, sec = self.dend[12]) h.pt3dadd(-469, 241.5, 97.5, 1.9, sec = self.dend[12]) h.pt3dadd(-470, 243, 99.5, 1.9, sec = self.dend[12]) h.pt3dadd(-471, 246, 99.5, 2, sec = self.dend[12]) h.pt3dadd(-471, 248, 97.5, 2, sec = self.dend[12]) h.pt3dadd(-470.5, 250, 95.5, 0.1, sec = self.dend[12]) h.pt3dadd(-470.5, 250, 107.5, 0.1, sec = self.dend[12]) h.pt3dadd(-470.5, 252.5, 103.5, 0.1, sec = self.dend[12]) h.pt3dadd(-470.5, 253.5, 103.5, 0.1, sec = self.dend[12]) h.pt3dadd(-470, 255, 101.5, 1.2, sec = self.dend[12]) h.pt3dadd(-468.5, 257, 105.5, 2.3, sec = self.dend[12]) h.pt3dadd(-468, 258.5, 105.5, 1.3, sec = self.dend[12]) h.pt3dadd(-467.5, 261.5, 101.5, 0.2, sec = self.dend[12]) h.pt3dadd(-468.5, 263, 103.5, 0.2, sec = self.dend[12]) h.pt3dadd(-469.5, 264, 99.5, 1.1, sec = self.dend[12]) h.pt3dadd(-470, 265, 101.5, 2, sec = self.dend[12]) h.pt3dadd(-471, 266.5, 103.5, 1.4, sec = self.dend[12]) h.pt3dadd(-471.5, 269, 103.5, 0.5, sec = self.dend[12]) h.pt3dadd(-472.5, 271.5, 103.5, 0.3, sec = self.dend[12]) h.pt3dadd(-473.5, 273, 103.5, 1.3, sec = self.dend[12]) h.pt3dadd(-476, 273.5, 109.5, 2.1, sec = self.dend[12]) h.pt3dadd(-477, 275, 109.5, 1.1, sec = self.dend[12]) h.pt3dadd(-477, 275.5, 109.5, 0.3, sec = self.dend[12]) h.pt3dadd(-478, 277.5, 109.5, 0.3, sec = self.dend[12]) h.pt3dadd(-478.5, 278, 109.5, 0.3, sec = self.dend[12]) h.pt3dadd(-479, 279, 111.5, 1.2, sec = self.dend[12]) h.pt3dadd(-482, 280, 117.5, 0.7, sec = self.dend[12]) h.pt3dadd(-483, 281, 125.5, 0.2, sec = self.dend[12]) h.pt3dadd(-485.5, 282.5, 125.5, 0.3, sec = self.dend[12]) h.pt3dadd(-488.5, 284, 125.5, 0.3, sec = self.dend[12]) h.pt3dadd(-490.5, 284, 127.5, 0.9, sec = self.dend[12]) h.pt3dadd(-492, 285, 129.5, 0.6, sec = self.dend[12]) h.pt3dadd(-497.5, 286.5, 133.5, 0.9, sec = self.dend[12]) h.pt3dadd(-499, 287.5, 131.5, 1.1, sec = self.dend[12]) h.pt3dadd(-501, 287.5, 133.5, 0.3, sec = self.dend[12]) h.pt3dadd(-503, 287.5, 137.5, 0.3, sec = self.dend[12]) h.pt3dadd(-504, 291.5, 141.5, 0.3, sec = self.dend[12]) h.pt3dclear(sec = self.dend[13]) h.pt3dadd(-420, 122.5, 70, 6, sec = self.dend[13]) h.pt3dadd(-422.5, 122, 68.5, 4.6, sec = self.dend[13]) h.pt3dadd(-426.5, 119.5, 68.5, 4.6, sec = self.dend[13]) h.pt3dadd(-428.5, 119, 67, 4.5, sec = self.dend[13]) h.pt3dadd(-433, 119.5, 68.5, 6.1, sec = self.dend[13]) h.pt3dadd(-435, 118.5, 68.5, 7.5, sec = self.dend[13]) h.pt3dadd(-437.5, 118.5, 68.5, 7.6, sec = self.dend[13]) h.pt3dclear(sec = self.dend[14]) h.pt3dadd(-437.5, 118.5, 68.5, 7.6, sec = self.dend[14]) h.pt3dadd(-441, 120, 73, 2.9, sec = self.dend[14]) h.pt3dadd(-443.5, 121.5, 73, 2.9, sec = self.dend[14]) h.pt3dadd(-447.5, 121.5, 73, 2.9, sec = self.dend[14]) h.pt3dadd(-450.5, 122.5, 71.5, 2.3, sec = self.dend[14]) h.pt3dadd(-454, 121, 71.5, 2.2, sec = self.dend[14]) h.pt3dadd(-456, 120, 74.5, 2.4, sec = self.dend[14]) h.pt3dadd(-458.5, 120.5, 74.5, 3.5, sec = self.dend[14]) h.pt3dadd(-461, 120.5, 76, 5.2, sec = self.dend[14]) h.pt3dadd(-464, 120.5, 76, 4.1, sec = self.dend[14]) h.pt3dadd(-467, 121, 80.5, 1.4, sec = self.dend[14]) h.pt3dadd(-470.5, 121, 80.5, 1.4, sec = self.dend[14]) h.pt3dadd(-473, 122, 82, 2.8, sec = self.dend[14]) h.pt3dadd(-476, 122, 82, 3.7, sec = self.dend[14]) h.pt3dadd(-479, 123, 82, 2.1, sec = self.dend[14]) h.pt3dadd(-479.5, 123, 82, 1.1, sec = self.dend[14]) h.pt3dadd(-481.5, 122.5, 83.5, 3, sec = self.dend[14]) h.pt3dadd(-482.5, 122, 85, 3.8, sec = self.dend[14]) h.pt3dadd(-487, 120, 83.5, 1.7, sec = self.dend[14]) h.pt3dadd(-492, 119.5, 83.5, 2.6, sec = self.dend[14]) h.pt3dadd(-494.5, 119, 85, 3.1, sec = self.dend[14]) h.pt3dadd(-497, 119.5, 85, 4, sec = self.dend[14]) h.pt3dadd(-498.5, 119.5, 86.5, 5.1, sec = self.dend[14]) h.pt3dadd(-500.5, 119.5, 86.5, 3.6, sec = self.dend[14]) h.pt3dadd(-503.5, 119, 86.5, 2.2, sec = self.dend[14]) h.pt3dadd(-506.5, 120, 86.5, 1.6, sec = self.dend[14]) h.pt3dadd(-509, 120, 86.5, 2.7, sec = self.dend[14]) h.pt3dadd(-512, 119, 86.5, 2.7, sec = self.dend[14]) h.pt3dadd(-515.5, 118.5, 86.5, 2.7, sec = self.dend[14]) h.pt3dadd(-519, 118.5, 86.5, 2.8, sec = self.dend[14]) h.pt3dadd(-519.5, 116.5, 85, 2.8, sec = self.dend[14]) h.pt3dadd(-516, 116, 85, 2.8, sec = self.dend[14]) h.pt3dadd(-516, 113, 85, 2.8, sec = self.dend[14]) h.pt3dadd(-518.5, 112.5, 85, 2.3, sec = self.dend[14]) h.pt3dadd(-520.5, 112, 85, 2.7, sec = self.dend[14]) h.pt3dadd(-523.5, 108, 88, 2.4, sec = self.dend[14]) h.pt3dadd(-527.5, 103.5, 84, 2.5, sec = self.dend[14]) h.pt3dadd(-530, 103.5, 84, 1.5, sec = self.dend[14]) h.pt3dadd(-532, 103.5, 84, 2.5, sec = self.dend[14]) h.pt3dadd(-534.5, 103.5, 84, 3.6, sec = self.dend[14]) h.pt3dadd(-535.5, 102.5, 84, 4, sec = self.dend[14]) h.pt3dadd(-539, 101.5, 84, 2.9, sec = self.dend[14]) h.pt3dadd(-539.5, 99.5, 84, 1.9, sec = self.dend[14]) h.pt3dadd(-541.5, 99.5, 84, 1.9, sec = self.dend[14]) h.pt3dadd(-543, 98.5, 84, 1.8, sec = self.dend[14]) h.pt3dadd(-544.5, 96.5, 84, 1.8, sec = self.dend[14]) h.pt3dadd(-544.5, 93.5, 98, 2.8, sec = self.dend[14]) h.pt3dadd(-544.5, 90, 98, 4.6, sec = self.dend[14]) h.pt3dadd(-544.5, 87, 98, 3.1, sec = self.dend[14]) h.pt3dadd(-545, 86.5, 98, 0.9, sec = self.dend[14]) h.pt3dadd(-547.5, 84.5, 98, 1, sec = self.dend[14]) h.pt3dadd(-549.5, 82.5, 102, 1.2, sec = self.dend[14]) h.pt3dadd(-552, 80, 102, 1.8, sec = self.dend[14]) h.pt3dadd(-555, 78, 102, 2.1, sec = self.dend[14]) h.pt3dadd(-556, 74.5, 98, 2.8, sec = self.dend[14]) h.pt3dadd(-559, 73.5, 98, 2.5, sec = self.dend[14]) h.pt3dadd(-563.5, 69, 98, 2.2, sec = self.dend[14]) h.pt3dadd(-567.5, 67.5, 100, 3.3, sec = self.dend[14]) h.pt3dadd(-572, 66, 100, 3.3, sec = self.dend[14]) h.pt3dclear(sec = self.dend[15]) h.pt3dadd(-572, 66, 100, 3.3, sec = self.dend[15]) h.pt3dadd(-568, 70, 100, 1.1, sec = self.dend[15]) h.pt3dadd(-565, 71, 100, 1.1, sec = self.dend[15]) h.pt3dadd(-559.5, 71, 104, 2.8, sec = self.dend[15]) h.pt3dadd(-557, 70.5, 102, 1.1, sec = self.dend[15]) h.pt3dadd(-555, 70.5, 100, 0.5, sec = self.dend[15]) h.pt3dadd(-554.5, 69, 100, 0.5, sec = self.dend[15]) h.pt3dadd(-553, 69, 104, 1.5, sec = self.dend[15]) h.pt3dadd(-552.5, 65.5, 104, 2.1, sec = self.dend[15]) h.pt3dadd(-551, 65, 104, 1.1, sec = self.dend[15]) h.pt3dadd(-550.5, 63.5, 108, 1.1, sec = self.dend[15]) h.pt3dadd(-549.5, 60.5, 104, 1.1, sec = self.dend[15]) h.pt3dadd(-548, 60.5, 104, 1.1, sec = self.dend[15]) h.pt3dadd(-545, 58.5, 106, 2.4, sec = self.dend[15]) h.pt3dadd(-544, 58, 104, 0.9, sec = self.dend[15]) h.pt3dadd(-542, 56, 104, 0.9, sec = self.dend[15]) h.pt3dadd(-540.5, 54, 94, 2.2, sec = self.dend[15]) h.pt3dadd(-537.5, 53.5, 92, 0.5, sec = self.dend[15]) h.pt3dadd(-535.5, 51.5, 92, 0.5, sec = self.dend[15]) h.pt3dadd(-534, 49, 92, 0.5, sec = self.dend[15]) h.pt3dadd(-532, 48, 92, 0.5, sec = self.dend[15]) h.pt3dadd(-530, 46, 94, 0.5, sec = self.dend[15]) h.pt3dadd(-528.5, 45, 90, 0.5, sec = self.dend[15]) h.pt3dadd(-526.5, 42, 88, 0.5, sec = self.dend[15]) h.pt3dclear(sec = self.dend[16]) h.pt3dadd(-572, 66, 100, 3.3, sec = self.dend[16]) h.pt3dadd(-576.5, 62.5, 96, 1.4, sec = self.dend[16]) h.pt3dadd(-580, 62, 96, 1.6, sec = self.dend[16]) h.pt3dadd(-583.5, 62, 96, 1, sec = self.dend[16]) h.pt3dadd(-585.5, 59, 94, 2, sec = self.dend[16]) h.pt3dadd(-588.5, 57, 94, 4.1, sec = self.dend[16]) h.pt3dadd(-592, 55, 92, 1.5, sec = self.dend[16]) h.pt3dadd(-595.5, 53, 92, 1.5, sec = self.dend[16]) h.pt3dadd(-596.5, 53, 92, 1.9, sec = self.dend[16]) h.pt3dadd(-599.5, 52.5, 100, 2, sec = self.dend[16]) h.pt3dadd(-601, 52.5, 98, 0.6, sec = self.dend[16]) h.pt3dadd(-603.5, 52.5, 98, 0.7, sec = self.dend[16]) h.pt3dadd(-604.5, 52.5, 98, 1.8, sec = self.dend[16]) h.pt3dadd(-605, 52.5, 98, 3.2, sec = self.dend[16]) h.pt3dadd(-608.5, 53.5, 98, 3.2, sec = self.dend[16]) h.pt3dadd(-612.5, 53.5, 98, 2.2, sec = self.dend[16]) h.pt3dadd(-616.5, 53, 96, 1.5, sec = self.dend[16]) h.pt3dadd(-619.5, 50.5, 96, 1.6, sec = self.dend[16]) h.pt3dadd(-622, 50.5, 96, 2.9, sec = self.dend[16]) h.pt3dadd(-625, 49, 96, 4, sec = self.dend[16]) h.pt3dadd(-629.5, 46, 96, 2.1, sec = self.dend[16]) h.pt3dadd(-633, 46, 96, 2, sec = self.dend[16]) h.pt3dadd(-637, 44.5, 96, 2.1, sec = self.dend[16]) h.pt3dadd(-641, 42.5, 92, 2.1, sec = self.dend[16]) h.pt3dadd(-644, 41.5, 102, 2.4, sec = self.dend[16]) h.pt3dadd(-645.5, 39.5, 102, 4.1, sec = self.dend[16]) h.pt3dadd(-647.5, 38, 102, 4.6, sec = self.dend[16]) h.pt3dadd(-651.5, 36.5, 102, 2.3, sec = self.dend[16]) h.pt3dadd(-655, 36, 102, 1.4, sec = self.dend[16]) h.pt3dadd(-657, 35.5, 102, 0.9, sec = self.dend[16]) h.pt3dadd(-659.5, 35, 102, 0.6, sec = self.dend[16]) h.pt3dadd(-661, 32.5, 102, 0.6, sec = self.dend[16]) h.pt3dadd(-663, 32, 102, 1, sec = self.dend[16]) h.pt3dadd(-665.5, 30.5, 102, 1.6, sec = self.dend[16]) h.pt3dadd(-669, 28.5, 102, 1.9, sec = self.dend[16]) h.pt3dadd(-671.5, 28.5, 104, 2.8, sec = self.dend[16]) h.pt3dadd(-673.5, 27, 104, 3.3, sec = self.dend[16]) h.pt3dadd(-675, 27, 104, 1.4, sec = self.dend[16]) h.pt3dadd(-677, 26.5, 104, 3.1, sec = self.dend[16]) h.pt3dclear(sec = self.dend[17]) h.pt3dadd(-677, 26.5, 104, 3.1, sec = self.dend[17]) h.pt3dadd(-680, 22.5, 106, 0.3, sec = self.dend[17]) h.pt3dadd(-681, 22, 104, 0.3, sec = self.dend[17]) h.pt3dadd(-683.5, 21, 104, 0.3, sec = self.dend[17]) h.pt3dadd(-686.5, 20, 106, 0.3, sec = self.dend[17]) h.pt3dadd(-688.5, 17.5, 110, 1.1, sec = self.dend[17]) h.pt3dclear(sec = self.dend[18]) h.pt3dadd(-677, 26.5, 104, 3.1, sec = self.dend[18]) h.pt3dadd(-680.5, 26, 104, 1, sec = self.dend[18]) h.pt3dadd(-682, 26, 104, 1, sec = self.dend[18]) h.pt3dadd(-687, 24, 114, 1, sec = self.dend[18]) h.pt3dadd(-690, 23.5, 120.5, 0.3, sec = self.dend[18]) h.pt3dadd(-692, 22.5, 120.5, 1.8, sec = self.dend[18]) h.pt3dadd(-693, 22.5, 121.5, 3.6, sec = self.dend[18]) h.pt3dadd(-695.5, 22.5, 121.5, 1.1, sec = self.dend[18]) h.pt3dadd(-696.5, 21.5, 120.5, 1.2, sec = self.dend[18]) h.pt3dadd(-698, 20, 121.5, 1.2, sec = self.dend[18]) h.pt3dadd(-698.5, 19, 117.5, 0.9, sec = self.dend[18]) h.pt3dadd(-698.5, 16, 119, 0.6, sec = self.dend[18]) h.pt3dclear(sec = self.dend[19]) h.pt3dadd(-698.5, 16, 119, 0.6, sec = self.dend[19]) h.pt3dadd(-703, 15.5, 119, 0.1, sec = self.dend[19]) h.pt3dadd(-706, 15.5, 119, 0.1, sec = self.dend[19]) h.pt3dadd(-710, 15.5, 119, 0.1, sec = self.dend[19]) h.pt3dadd(-714, 15.5, 119, 0.1, sec = self.dend[19]) h.pt3dadd(-716.5, 15, 119, 1.3, sec = self.dend[19]) h.pt3dadd(-717.5, 14.5, 120.5, 2.5, sec = self.dend[19]) h.pt3dadd(-720, 13, 120.5, 1.5, sec = self.dend[19]) h.pt3dadd(-721, 12.5, 120.5, 0.1, sec = self.dend[19]) h.pt3dadd(-724.5, 12, 120.5, 0.1, sec = self.dend[19]) h.pt3dadd(-727, 9.5, 120.5, 0.1, sec = self.dend[19]) h.pt3dadd(-729.5, 9.5, 120.5, 0.1, sec = self.dend[19]) h.pt3dadd(-732.5, 9.5, 124.5, 2.9, sec = self.dend[19]) h.pt3dclear(sec = self.dend[20]) h.pt3dadd(-732.5, 9.5, 124.5, 2.9, sec = self.dend[20]) h.pt3dadd(-734.5, 8, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-738.5, 4.5, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-739.5, 4, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-742.5, 3.5, 125.5, 1.2, sec = self.dend[20]) h.pt3dadd(-743.5, 1, 123, 0.1, sec = self.dend[20]) h.pt3dadd(-744, 1, 127, 1.1, sec = self.dend[20]) h.pt3dadd(-744, -1.5, 127, 1.4, sec = self.dend[20]) h.pt3dadd(-744.5, -2.5, 127, 0.1, sec = self.dend[20]) h.pt3dadd(-745.5, -4.5, 127, 0.1, sec = self.dend[20]) h.pt3dadd(-748, -5, 127, 1.4, sec = self.dend[20]) h.pt3dadd(-748.5, -6, 128, 0.1, sec = self.dend[20]) h.pt3dadd(-750.5, -9.5, 127, 0.1, sec = self.dend[20]) h.pt3dadd(-750.5, -9.5, 129.5, 0.9, sec = self.dend[20]) h.pt3dadd(-753, -10.5, 127, 0.1, sec = self.dend[20]) h.pt3dadd(-756.5, -10.5, 127, 0.1, sec = self.dend[20]) h.pt3dadd(-757.5, -12.5, 129.5, 1.3, sec = self.dend[20]) h.pt3dadd(-760.5, -12.5, 129.5, 0.1, sec = self.dend[20]) h.pt3dadd(-761.5, -13.5, 124.5, 0.1, sec = self.dend[20]) h.pt3dadd(-764, -14.5, 125.5, 1.1, sec = self.dend[20]) h.pt3dadd(-765.5, -16, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-766.5, -18, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-767.5, -18.5, 125.5, 1.1, sec = self.dend[20]) h.pt3dadd(-769.5, -21, 124.5, 0.1, sec = self.dend[20]) h.pt3dadd(-772, -21.5, 125.5, 0.1, sec = self.dend[20]) h.pt3dadd(-776, -25, 128, 1.7, sec = self.dend[20]) h.pt3dclear(sec = self.dend[21]) h.pt3dadd(-776, -25, 128, 1.7, sec = self.dend[21]) h.pt3dadd(-778, -23, 120.5, 0.1, sec = self.dend[21]) h.pt3dadd(-781.5, -25, 120.5, 0.1, sec = self.dend[21]) h.pt3dadd(-786.5, -24.5, 120.5, 0.1, sec = self.dend[21]) h.pt3dadd(-787.5, -24, 120.5, 0.1, sec = self.dend[21]) h.pt3dadd(-789.5, -24, 124.5, 1.9, sec = self.dend[21]) h.pt3dadd(-791, -24, 123, 2.6, sec = self.dend[21]) h.pt3dadd(-793, -25, 123, 1.3, sec = self.dend[21]) h.pt3dadd(-793, -28, 123, 0.1, sec = self.dend[21]) h.pt3dadd(-793, -30, 123, 0.1, sec = self.dend[21]) h.pt3dadd(-791, -30.5, 124.5, 1, sec = self.dend[21]) h.pt3dadd(-791, -31.5, 123, 1.5, sec = self.dend[21]) h.pt3dadd(-788.5, -34.5, 123, 1.1, sec = self.dend[21]) h.pt3dadd(-789, -36.5, 123, 0.1, sec = self.dend[21]) h.pt3dadd(-790.5, -37.5, 123, 0.1, sec = self.dend[21]) h.pt3dadd(-793.5, -39.5, 124.5, 0.1, sec = self.dend[21]) h.pt3dadd(-797, -39.5, 124.5, 0.1, sec = self.dend[21]) h.pt3dadd(-799, -42, 121.5, 0.1, sec = self.dend[21]) h.pt3dadd(-800.5, -43, 120.5, 0.1, sec = self.dend[21]) h.pt3dadd(-802.5, -44, 121.5, 0.1, sec = self.dend[21]) h.pt3dadd(-804, -46, 121.5, 1.7, sec = self.dend[21]) h.pt3dadd(-805.5, -47, 124.5, 3.4, sec = self.dend[21]) h.pt3dadd(-807.5, -51, 124.5, 2, sec = self.dend[21]) h.pt3dadd(-810, -53.5, 125.5, 0.7, sec = self.dend[21]) h.pt3dadd(-813.5, -53.5, 125.5, 0.7, sec = self.dend[21]) h.pt3dadd(-816.5, -53.5, 127, 0.7, sec = self.dend[21]) h.pt3dadd(-818.5, -53, 127, 0.7, sec = self.dend[21]) h.pt3dadd(-820, -52, 127, 0.7, sec = self.dend[21]) h.pt3dadd(-821, -52, 128, 2, sec = self.dend[21]) h.pt3dadd(-824, -48.5, 125.5, 0.3, sec = self.dend[21]) h.pt3dadd(-826.5, -49, 127, 0.3, sec = self.dend[21]) h.pt3dclear(sec = self.dend[22]) h.pt3dadd(-776, -25, 128, 1.7, sec = self.dend[22]) h.pt3dadd(-777, -27, 125.5, 0.1, sec = self.dend[22]) h.pt3dadd(-779, -29.5, 124.5, 1.1, sec = self.dend[22]) h.pt3dadd(-780.5, -31, 121.5, 0.1, sec = self.dend[22]) h.pt3dadd(-782, -33.5, 121.5, 0.1, sec = self.dend[22]) h.pt3dadd(-782, -34.5, 123, 0.1, sec = self.dend[22]) h.pt3dadd(-782, -36, 125.5, 1.9, sec = self.dend[22]) h.pt3dadd(-783, -37, 125.5, 0.9, sec = self.dend[22]) h.pt3dadd(-783.5, -38, 123, 0.1, sec = self.dend[22]) h.pt3dadd(-786, -40.5, 123, 0.1, sec = self.dend[22]) h.pt3dadd(-786, -43, 125.5, 1, sec = self.dend[22]) h.pt3dadd(-788, -44.5, 128, 0.1, sec = self.dend[22]) h.pt3dadd(-789, -44.5, 125.5, 0.1, sec = self.dend[22]) h.pt3dadd(-792, -44.5, 125.5, 1, sec = self.dend[22]) h.pt3dadd(-795, -46, 125.5, 0.1, sec = self.dend[22]) h.pt3dadd(-800, -46, 125.5, 0.1, sec = self.dend[22]) h.pt3dclear(sec = self.dend[23]) h.pt3dadd(-732.5, 9.5, 124.5, 2.9, sec = self.dend[23]) h.pt3dadd(-736.5, 10, 124.5, 0.1, sec = self.dend[23]) h.pt3dadd(-740.5, 9.5, 127, 0.1, sec = self.dend[23]) h.pt3dadd(-745, 5.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-748.5, 4.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-750.5, 4.5, 123, 1.4, sec = self.dend[23]) h.pt3dadd(-751.5, 3, 121.5, 1.4, sec = self.dend[23]) h.pt3dadd(-753, 2, 120.5, 1.1, sec = self.dend[23]) h.pt3dadd(-754, 1.5, 120.5, 0.1, sec = self.dend[23]) h.pt3dadd(-756.5, 1.5, 121.5, 0.1, sec = self.dend[23]) h.pt3dadd(-759, 0.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-761, -2.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-763, -2.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-765, -2.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-769, -5.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-770, -5.5, 123, 0.1, sec = self.dend[23]) h.pt3dadd(-772, -5.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-773.5, -5.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-776, -5.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-777.5, -5.5, 125.5, 0.1, sec = self.dend[23]) h.pt3dadd(-778.5, -7.5, 123, 0.1, sec = self.dend[23]) h.pt3dclear(sec = self.dend[24]) h.pt3dadd(-698.5, 16, 119, 0.6, sec = self.dend[24]) h.pt3dadd(-699.5, 13.5, 119, 0.6, sec = self.dend[24]) h.pt3dadd(-700.5, 12, 121.5, 1.9, sec = self.dend[24]) h.pt3dadd(-702, 10, 121.5, 2.8, sec = self.dend[24]) h.pt3dadd(-703.5, 9.5, 121.5, 2.8, sec = self.dend[24]) h.pt3dadd(-705, 9, 121.5, 3.6, sec = self.dend[24]) h.pt3dadd(-708, 7, 121.5, 1.5, sec = self.dend[24]) h.pt3dadd(-709, 5, 121.5, 1.2, sec = self.dend[24]) h.pt3dadd(-710.5, 5, 121.5, 0.7, sec = self.dend[24]) h.pt3dadd(-712, 5, 123, 0.7, sec = self.dend[24]) h.pt3dadd(-713, 5, 123, 1.1, sec = self.dend[24]) h.pt3dadd(-714, 5, 123, 1.4, sec = self.dend[24]) h.pt3dadd(-716.5, 5, 124.5, 2.5, sec = self.dend[24]) h.pt3dadd(-717.5, 5, 124.5, 3.4, sec = self.dend[24]) h.pt3dadd(-720, 5, 124.5, 1.3, sec = self.dend[24]) h.pt3dadd(-723, 5, 124.5, 1.3, sec = self.dend[24]) h.pt3dadd(-727.5, 5, 124.5, 1.5, sec = self.dend[24]) h.pt3dadd(-729, 5.5, 123, 2.1, sec = self.dend[24]) h.pt3dadd(-732, 5.5, 123, 2, sec = self.dend[24]) h.pt3dadd(-735, 5.5, 124.5, 1, sec = self.dend[24]) h.pt3dadd(-737.5, 7.5, 123, 1.1, sec = self.dend[24]) h.pt3dadd(-738.5, 7.5, 123, 3.3, sec = self.dend[24]) h.pt3dadd(-741, 7.5, 124.5, 3.8, sec = self.dend[24]) h.pt3dadd(-743, 9.5, 124.5, 2.8, sec = self.dend[24]) h.pt3dadd(-744.5, 10, 124.5, 1.4, sec = self.dend[24]) h.pt3dadd(-747, 10, 127, 0.3, sec = self.dend[24]) h.pt3dadd(-749, 12, 127, 1.1, sec = self.dend[24]) h.pt3dadd(-750.5, 14.5, 128, 2.1, sec = self.dend[24]) h.pt3dadd(-753, 15.5, 128, 1.7, sec = self.dend[24]) h.pt3dadd(-755, 15.5, 125.5, 0.8, sec = self.dend[24]) h.pt3dadd(-759, 18, 131, 0.9, sec = self.dend[24]) h.pt3dadd(-762.5, 19, 129.5, 1.1, sec = self.dend[24]) h.pt3dadd(-766, 21, 129.5, 1.1, sec = self.dend[24]) h.pt3dadd(-768, 21, 129.5, 1.1, sec = self.dend[24]) h.pt3dadd(-770, 20.5, 131, 2.6, sec = self.dend[24]) h.pt3dadd(-773, 19.5, 131, 2.9, sec = self.dend[24]) h.pt3dadd(-776, 19, 129.5, 2.3, sec = self.dend[24]) h.pt3dadd(-778.5, 19, 129.5, 1.3, sec = self.dend[24]) h.pt3dadd(-780.5, 18.5, 129.5, 0.7, sec = self.dend[24]) h.pt3dadd(-781.5, 17.5, 131, 0.8, sec = self.dend[24]) h.pt3dclear(sec = self.dend[25]) h.pt3dadd(-437.5, 118.5, 68.5, 7.6, sec = self.dend[25]) h.pt3dadd(-442, 114.5, 68.5, 2.6, sec = self.dend[25]) h.pt3dadd(-444.5, 112, 68.5, 2.7, sec = self.dend[25]) h.pt3dadd(-449, 112.5, 68.5, 2.6, sec = self.dend[25]) h.pt3dadd(-451.5, 110.5, 68.5, 2.8, sec = self.dend[25]) h.pt3dadd(-454.5, 107.5, 68.5, 2.5, sec = self.dend[25]) h.pt3dadd(-457, 108, 70, 3.3, sec = self.dend[25]) h.pt3dadd(-460.5, 107.5, 70, 3.6, sec = self.dend[25]) h.pt3dadd(-463, 106, 68.5, 3.2, sec = self.dend[25]) h.pt3dadd(-467.5, 106.5, 68.5, 3.3, sec = self.dend[25]) h.pt3dadd(-472, 104.5, 68.5, 4.1, sec = self.dend[25]) h.pt3dadd(-478.5, 103, 74.5, 5.1, sec = self.dend[25]) h.pt3dadd(-481.5, 102, 74.5, 4, sec = self.dend[25]) h.pt3dadd(-484, 101, 74.5, 2.2, sec = self.dend[25]) h.pt3dadd(-487.5, 101, 74.5, 2.6, sec = self.dend[25]) h.pt3dadd(-490.5, 101.5, 74.5, 3.5, sec = self.dend[25]) h.pt3dadd(-494.5, 102, 76, 2.7, sec = self.dend[25]) h.pt3dadd(-498.5, 101.5, 76, 2.2, sec = self.dend[25]) h.pt3dadd(-501.5, 100.5, 76, 3.8, sec = self.dend[25]) h.pt3dadd(-505.5, 101.5, 76, 4.6, sec = self.dend[25]) h.pt3dadd(-509.5, 100, 76, 5.2, sec = self.dend[25]) h.pt3dadd(-516.5, 97, 76, 3.8, sec = self.dend[25]) h.pt3dadd(-519.5, 98, 76, 2.3, sec = self.dend[25]) h.pt3dadd(-523, 97.5, 76, 1.8, sec = self.dend[25]) h.pt3dadd(-525.5, 98, 76, 2.4, sec = self.dend[25]) h.pt3dadd(-528, 100.5, 76, 1.9, sec = self.dend[25]) h.pt3dadd(-530.5, 99.5, 76, 1.9, sec = self.dend[25]) h.pt3dadd(-534.5, 101, 76, 3.8, sec = self.dend[25]) h.pt3dadd(-538, 100.5, 76, 3.8, sec = self.dend[25]) h.pt3dadd(-539, 98, 76, 2.8, sec = self.dend[25]) h.pt3dadd(-544, 98, 76, 2.8, sec = self.dend[25]) h.pt3dadd(-549, 95.5, 76, 3.5, sec = self.dend[25]) h.pt3dadd(-552.5, 96, 74.5, 3.8, sec = self.dend[25]) h.pt3dadd(-556, 95, 79, 3.4, sec = self.dend[25]) h.pt3dadd(-560, 92, 77.5, 2.3, sec = self.dend[25]) h.pt3dadd(-563, 93, 77.5, 2.5, sec = self.dend[25]) h.pt3dadd(-565.5, 93, 76, 4.6, sec = self.dend[25]) h.pt3dadd(-569, 90, 76, 3.6, sec = self.dend[25]) h.pt3dadd(-571.5, 90, 76, 4.1, sec = self.dend[25]) h.pt3dadd(-575.5, 88, 77.5, 4.1, sec = self.dend[25]) h.pt3dadd(-579.5, 86.5, 77.5, 2.5, sec = self.dend[25]) h.pt3dadd(-580.5, 86.5, 77.5, 2, sec = self.dend[25]) h.pt3dadd(-582.5, 87, 76, 1.6, sec = self.dend[25]) h.pt3dadd(-584, 87, 76, 1.9, sec = self.dend[25]) h.pt3dadd(-586.5, 87, 76, 3.3, sec = self.dend[25]) h.pt3dadd(-589.5, 83.5, 76, 3.3, sec = self.dend[25]) h.pt3dadd(-595, 83.5, 82, 4.6, sec = self.dend[25]) h.pt3dadd(-597, 80.5, 82, 3.6, sec = self.dend[25]) h.pt3dadd(-601.5, 80.5, 82, 3.2, sec = self.dend[25]) h.pt3dadd(-603.5, 81, 82, 3.2, sec = self.dend[25]) h.pt3dadd(-607.5, 81, 82, 3.3, sec = self.dend[25]) h.pt3dadd(-609, 80, 82, 2.8, sec = self.dend[25]) h.pt3dadd(-612.5, 80, 82, 2.8, sec = self.dend[25]) h.pt3dadd(-616, 81, 83.5, 2.8, sec = self.dend[25]) h.pt3dadd(-618.5, 82, 83.5, 4, sec = self.dend[25]) h.pt3dadd(-625, 81, 83.5, 5.2, sec = self.dend[25]) h.pt3dadd(-628, 81, 83.5, 4.3, sec = self.dend[25]) h.pt3dadd(-630.5, 80.5, 83.5, 2.6, sec = self.dend[25]) h.pt3dadd(-632.5, 80.5, 83.5, 3, sec = self.dend[25]) h.pt3dadd(-634, 80.5, 83.5, 2.9, sec = self.dend[25]) h.pt3dadd(-636, 80.5, 83.5, 1.4, sec = self.dend[25]) h.pt3dadd(-638.5, 80.5, 83.5, 1.7, sec = self.dend[25]) h.pt3dadd(-638, 79.5, 83.5, 1.7, sec = self.dend[25]) h.pt3dadd(-642.5, 80, 83.5, 2.5, sec = self.dend[25]) h.pt3dadd(-646.5, 80, 85.5, 2.9, sec = self.dend[25]) h.pt3dadd(-650.5, 80, 85.5, 2.9, sec = self.dend[25]) h.pt3dadd(-654, 80, 85.5, 2, sec = self.dend[25]) h.pt3dadd(-657.5, 80, 85.5, 1.3, sec = self.dend[25]) h.pt3dadd(-659, 82, 87.5, 1.7, sec = self.dend[25]) h.pt3dadd(-662.5, 82, 89.5, 4.6, sec = self.dend[25]) h.pt3dclear(sec = self.dend[26]) h.pt3dadd(-662.5, 82, 89.5, 4.6, sec = self.dend[26]) h.pt3dadd(-662, 78, 93.5, 0.9, sec = self.dend[26]) h.pt3dadd(-664, 76, 95.5, 0.8, sec = self.dend[26]) h.pt3dadd(-665, 72.5, 97.5, 1.2, sec = self.dend[26]) h.pt3dadd(-665.5, 70, 97.5, 1.2, sec = self.dend[26]) h.pt3dadd(-665.5, 69, 97.5, 0.9, sec = self.dend[26]) h.pt3dadd(-665.5, 66, 97.5, 0.8, sec = self.dend[26]) h.pt3dadd(-665.5, 64.5, 99.5, 2, sec = self.dend[26]) h.pt3dadd(-666.5, 62.5, 105.5, 3.6, sec = self.dend[26]) h.pt3dadd(-666, 59, 105.5, 2.3, sec = self.dend[26]) h.pt3dadd(-666.5, 57.5, 105.5, 0.9, sec = self.dend[26]) h.pt3dadd(-666.5, 53.5, 107.5, 0.9, sec = self.dend[26]) h.pt3dadd(-668.5, 52, 107.5, 0.9, sec = self.dend[26]) h.pt3dadd(-668.5, 49, 107.5, 0.9, sec = self.dend[26]) h.pt3dadd(-670.5, 48, 107.5, 0.9, sec = self.dend[26]) h.pt3dadd(-672.5, 46.5, 113.5, 0.7, sec = self.dend[26]) h.pt3dadd(-674, 45, 113.5, 0.8, sec = self.dend[26]) h.pt3dadd(-677.5, 43, 117.5, 1.7, sec = self.dend[26]) h.pt3dadd(-682, 40.5, 115.5, 1.1, sec = self.dend[26]) h.pt3dadd(-683.5, 39, 117.5, 0.6, sec = self.dend[26]) h.pt3dadd(-687, 37, 119.5, 0.6, sec = self.dend[26]) h.pt3dadd(-690, 34.5, 121.5, 2.1, sec = self.dend[26]) h.pt3dadd(-692.5, 34.5, 121.5, 2.7, sec = self.dend[26]) h.pt3dadd(-694.5, 34, 121.5, 1.3, sec = self.dend[26]) h.pt3dadd(-697.5, 32.5, 97.5, 1.1, sec = self.dend[26]) h.pt3dadd(-700, 31.5, 99.5, 1.1, sec = self.dend[26]) h.pt3dadd(-702, 29.5, 103.5, 2.6, sec = self.dend[26]) h.pt3dclear(sec = self.dend[27]) h.pt3dadd(-702, 29.5, 103.5, 2.6, sec = self.dend[27]) h.pt3dadd(-705, 24, 105.5, 0.1, sec = self.dend[27]) h.pt3dadd(-707.5, 22.5, 103.5, 0.1, sec = self.dend[27]) h.pt3dadd(-709, 21.5, 97.5, 2.4, sec = self.dend[27]) h.pt3dadd(-712, 21, 99.5, 0.2, sec = self.dend[27]) h.pt3dadd(-715.5, 21, 99.5, 0.2, sec = self.dend[27]) h.pt3dadd(-717, 21, 101.5, 0.7, sec = self.dend[27]) h.pt3dadd(-719.5, 21, 103.5, 0.7, sec = self.dend[27]) h.pt3dadd(-722.5, 21, 93.5, 0.3, sec = self.dend[27]) h.pt3dadd(-725, 21.5, 95.5, 0.3, sec = self.dend[27]) h.pt3dadd(-728, 21.5, 95.5, 0.3, sec = self.dend[27]) h.pt3dadd(-730.5, 21.5, 95.5, 0.3, sec = self.dend[27]) h.pt3dadd(-731.5, 21.5, 95.5, 0.5, sec = self.dend[27]) h.pt3dadd(-734.5, 21, 95.5, 0.5, sec = self.dend[27]) h.pt3dadd(-737, 20.5, 95.5, 0.5, sec = self.dend[27]) h.pt3dadd(-739, 20.5, 95.5, 0.5, sec = self.dend[27]) h.pt3dadd(-742.5, 20.5, 95.5, 0.6, sec = self.dend[27]) h.pt3dadd(-744.5, 20.5, 95.5, 0.6, sec = self.dend[27]) h.pt3dadd(-748, 20.5, 97.5, 0.2, sec = self.dend[27]) h.pt3dadd(-749, 20.5, 97.5, 0.2, sec = self.dend[27]) h.pt3dadd(-753.5, 20, 99.5, 0.6, sec = self.dend[27]) h.pt3dadd(-756.5, 20, 99.5, 0.6, sec = self.dend[27]) h.pt3dadd(-758.5, 18.5, 93.5, 0.6, sec = self.dend[27]) h.pt3dadd(-760, 17, 95.5, 1.1, sec = self.dend[27]) h.pt3dadd(-762, 17, 91.5, 1.3, sec = self.dend[27]) h.pt3dadd(-764, 15, 93.5, 0.3, sec = self.dend[27]) h.pt3dadd(-766, 15, 95.5, 0.3, sec = self.dend[27]) h.pt3dadd(-768, 15, 95.5, 0.3, sec = self.dend[27]) h.pt3dadd(-771, 12, 97.5, 1.2, sec = self.dend[27]) h.pt3dadd(-773.5, 11, 95.5, 0.1, sec = self.dend[27]) h.pt3dclear(sec = self.dend[28]) h.pt3dadd(-702, 29.5, 103.5, 2.6, sec = self.dend[28]) h.pt3dadd(-702, 26.5, 101.5, 0.9, sec = self.dend[28]) h.pt3dadd(-702.5, 24, 101.5, 0.7, sec = self.dend[28]) h.pt3dadd(-703, 22, 101.5, 0.8, sec = self.dend[28]) h.pt3dadd(-705.5, 20.5, 101.5, 0.7, sec = self.dend[28]) h.pt3dadd(-706, 19.5, 103.5, 1.1, sec = self.dend[28]) h.pt3dadd(-706.5, 18, 109.5, 1.1, sec = self.dend[28]) h.pt3dadd(-707.5, 15.5, 109.5, 1.1, sec = self.dend[28]) h.pt3dadd(-709.5, 13, 109.5, 1.1, sec = self.dend[28]) h.pt3dadd(-709.5, 12, 109.5, 1.8, sec = self.dend[28]) h.pt3dadd(-709.5, 9.5, 111.5, 2.8, sec = self.dend[28]) h.pt3dadd(-711.5, 7, 111.5, 1.1, sec = self.dend[28]) h.pt3dadd(-713, 6, 111.5, 0.3, sec = self.dend[28]) h.pt3dadd(-716, 3, 111.5, 0.3, sec = self.dend[28]) h.pt3dadd(-717.5, 1, 113.5, 1.2, sec = self.dend[28]) h.pt3dadd(-722, -2.5, 113.5, 1.2, sec = self.dend[28]) h.pt3dadd(-724, -3, 113.5, 0.4, sec = self.dend[28]) h.pt3dadd(-726.5, -7.5, 117.5, 0.3, sec = self.dend[28]) h.pt3dadd(-727.5, -8.5, 125.5, 2.1, sec = self.dend[28]) h.pt3dadd(-729.5, -11.5, 125.5, 2.5, sec = self.dend[28]) h.pt3dadd(-730.5, -12.5, 113.5, 1.4, sec = self.dend[28]) h.pt3dadd(-733.5, -15.5, 117.5, 0.7, sec = self.dend[28]) h.pt3dadd(-736, -18.5, 119.5, 0.7, sec = self.dend[28]) h.pt3dadd(-737.5, -19.5, 121.5, 2.7, sec = self.dend[28]) h.pt3dadd(-738, -22, 123.5, 3.4, sec = self.dend[28]) h.pt3dadd(-740.5, -23.5, 123.5, 0.9, sec = self.dend[28]) h.pt3dadd(-743, -26.5, 123.5, 0.6, sec = self.dend[28]) h.pt3dadd(-746.5, -25.5, 121.5, 2.5, sec = self.dend[28]) h.pt3dadd(-746.5, -29, 123.5, 0.1, sec = self.dend[28]) h.pt3dadd(-750.5, -29, 125.5, 0.1, sec = self.dend[28]) h.pt3dadd(-752.5, -30, 127.5, 3.4, sec = self.dend[28]) h.pt3dadd(-755, -30, 125.5, 0.7, sec = self.dend[28]) h.pt3dadd(-757.5, -30, 125.5, 0.7, sec = self.dend[28]) h.pt3dadd(-757, -32, 127.5, 0.7, sec = self.dend[28]) h.pt3dclear(sec = self.dend[29]) h.pt3dadd(-662.5, 82, 89.5, 4.6, sec = self.dend[29]) h.pt3dadd(-666, 83.5, 93.5, 1.8, sec = self.dend[29]) h.pt3dadd(-668.5, 85.5, 93.5, 1.8, sec = self.dend[29]) h.pt3dadd(-672, 85.5, 93.5, 3.3, sec = self.dend[29]) h.pt3dadd(-673.5, 86, 93.5, 4.1, sec = self.dend[29]) h.pt3dadd(-676.5, 86, 93.5, 3.3, sec = self.dend[29]) h.pt3dadd(-678.5, 87, 93.5, 2, sec = self.dend[29]) h.pt3dadd(-680.5, 87.5, 93.5, 0.9, sec = self.dend[29]) h.pt3dadd(-684, 87.5, 93.5, 0.9, sec = self.dend[29]) h.pt3dadd(-685.5, 88, 93.5, 0.9, sec = self.dend[29]) h.pt3dadd(-688, 88, 93.5, 0.9, sec = self.dend[29]) h.pt3dadd(-691, 88, 95.5, 2.5, sec = self.dend[29]) h.pt3dadd(-694, 89, 97.5, 3.9, sec = self.dend[29]) h.pt3dadd(-695.5, 89, 97.5, 4.3, sec = self.dend[29]) h.pt3dadd(-698, 89.5, 97.5, 3, sec = self.dend[29]) h.pt3dadd(-701, 90.5, 93.5, 1.4, sec = self.dend[29]) h.pt3dadd(-702.5, 90.5, 103.5, 1.5, sec = self.dend[29]) h.pt3dadd(-704.5, 90.5, 103.5, 1.6, sec = self.dend[29]) h.pt3dadd(-706.5, 91.5, 103.5, 1.6, sec = self.dend[29]) h.pt3dadd(-708.5, 93.5, 103.5, 1.6, sec = self.dend[29]) h.pt3dadd(-711.5, 92.5, 113.5, 2.5, sec = self.dend[29]) h.pt3dadd(-715, 92.5, 111.5, 1.8, sec = self.dend[29]) h.pt3dadd(-717, 93, 111.5, 1.6, sec = self.dend[29]) h.pt3dadd(-719.5, 94.5, 111.5, 1.5, sec = self.dend[29]) h.pt3dadd(-720.5, 96.5, 109.5, 2.9, sec = self.dend[29]) h.pt3dadd(-723.5, 99, 115.5, 2.5, sec = self.dend[29]) h.pt3dadd(-726, 99, 116.5, 3.5, sec = self.dend[29]) h.pt3dadd(-727, 99, 116.5, 4.4, sec = self.dend[29]) h.pt3dadd(-730, 99, 119.5, 2.7, sec = self.dend[29]) h.pt3dadd(-731, 99, 119.5, 1.3, sec = self.dend[29]) h.pt3dadd(-732, 99, 119.5, 1.3, sec = self.dend[29]) h.pt3dadd(-734, 98.5, 119.5, 2, sec = self.dend[29]) h.pt3dadd(-736, 97.5, 119.5, 3.3, sec = self.dend[29]) h.pt3dadd(-740, 96, 120.5, 4.4, sec = self.dend[29]) h.pt3dclear(sec = self.dend[30]) h.pt3dadd(-740, 96, 120.5, 4.4, sec = self.dend[30]) h.pt3dadd(-742.5, 96.5, 122, 0.4, sec = self.dend[30]) h.pt3dadd(-743.5, 96.5, 120.5, 0.4, sec = self.dend[30]) h.pt3dadd(-744, 98, 122, 1.3, sec = self.dend[30]) h.pt3dadd(-745.5, 98, 122, 1.6, sec = self.dend[30]) h.pt3dadd(-748, 99, 123.5, 0.8, sec = self.dend[30]) h.pt3dadd(-750.5, 99, 123.5, 0.5, sec = self.dend[30]) h.pt3dadd(-755.5, 100.5, 123.5, 0.6, sec = self.dend[30]) h.pt3dadd(-756.5, 100.5, 122, 2.2, sec = self.dend[30]) h.pt3dadd(-758.5, 100.5, 123.5, 3.6, sec = self.dend[30]) h.pt3dadd(-761, 101.5, 124.5, 1.9, sec = self.dend[30]) h.pt3dadd(-764.5, 102, 124.5, 0.7, sec = self.dend[30]) h.pt3dadd(-766, 103, 124.5, 0.7, sec = self.dend[30]) h.pt3dadd(-769, 105, 126, 0.9, sec = self.dend[30]) h.pt3dadd(-772, 106.5, 127, 0.9, sec = self.dend[30]) h.pt3dadd(-773.5, 106, 123.5, 1.7, sec = self.dend[30]) h.pt3dadd(-774.5, 106.5, 123.5, 2, sec = self.dend[30]) h.pt3dadd(-776.5, 106.5, 123.5, 0.6, sec = self.dend[30]) h.pt3dadd(-778, 108.5, 120.5, 0.6, sec = self.dend[30]) h.pt3dadd(-779.5, 109, 122, 2.1, sec = self.dend[30]) h.pt3dadd(-780.5, 110, 123.5, 3.7, sec = self.dend[30]) h.pt3dadd(-782.5, 110, 122, 1.3, sec = self.dend[30]) h.pt3dadd(-784, 110, 123.5, 0.9, sec = self.dend[30]) h.pt3dadd(-786.5, 110, 123.5, 0.7, sec = self.dend[30]) h.pt3dadd(-788, 110.5, 123.5, 1.4, sec = self.dend[30]) h.pt3dadd(-789, 110.5, 123.5, 2, sec = self.dend[30]) h.pt3dadd(-790.5, 112.5, 124.5, 0.7, sec = self.dend[30]) h.pt3dadd(-792, 112.5, 126, 0.3, sec = self.dend[30]) h.pt3dadd(-795, 112.5, 126, 0.3, sec = self.dend[30]) h.pt3dadd(-797, 113, 126, 1.7, sec = self.dend[30]) h.pt3dadd(-799, 113, 127, 2.6, sec = self.dend[30]) h.pt3dadd(-801, 114, 124.5, 1.1, sec = self.dend[30]) h.pt3dadd(-802.5, 114, 124.5, 0.6, sec = self.dend[30]) h.pt3dadd(-806.5, 113.5, 124.5, 0.6, sec = self.dend[30]) h.pt3dadd(-808, 113.5, 124.5, 0.6, sec = self.dend[30]) h.pt3dadd(-810.5, 113.5, 124.5, 2.1, sec = self.dend[30]) h.pt3dadd(-813, 113.5, 126, 2.3, sec = self.dend[30]) h.pt3dadd(-815, 113.5, 126, 1.4, sec = self.dend[30]) h.pt3dadd(-818.5, 114.5, 126, 0.6, sec = self.dend[30]) h.pt3dadd(-821.5, 114.5, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-825.5, 116, 126, 1.1, sec = self.dend[30]) h.pt3dadd(-828.5, 116, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-832.5, 116, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-834.5, 116.5, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-837, 118, 126, 2.1, sec = self.dend[30]) h.pt3dadd(-840.5, 118, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-847, 119, 126, 0.7, sec = self.dend[30]) h.pt3dadd(-850.5, 122.5, 127, 0.7, sec = self.dend[30]) h.pt3dadd(-853.5, 123.5, 127, 1.4, sec = self.dend[30]) h.pt3dadd(-855, 126, 127, 1.8, sec = self.dend[30]) h.pt3dadd(-856.5, 128, 128.5, 1.1, sec = self.dend[30]) h.pt3dadd(-858.5, 131, 128.5, 0.3, sec = self.dend[30]) h.pt3dadd(-859, 133, 128.5, 0.3, sec = self.dend[30]) h.pt3dadd(-860.5, 136, 130, 0.9, sec = self.dend[30]) h.pt3dadd(-862.5, 136.5, 130, 1, sec = self.dend[30]) h.pt3dadd(-866, 138, 130, 0.5, sec = self.dend[30]) h.pt3dadd(-866.5, 139, 131, 1.9, sec = self.dend[30]) h.pt3dadd(-869.5, 139, 132.5, 2.3, sec = self.dend[30]) h.pt3dadd(-871, 141, 130, 0.5, sec = self.dend[30]) h.pt3dadd(-875, 143, 131, 0.5, sec = self.dend[30]) h.pt3dadd(-879.5, 143.5, 131, 0.5, sec = self.dend[30]) h.pt3dadd(-883, 144.5, 134, 0.5, sec = self.dend[30]) h.pt3dclear(sec = self.dend[31]) h.pt3dadd(-740, 96, 120.5, 4.4, sec = self.dend[31]) h.pt3dadd(-743, 92.5, 119.5, 1.2, sec = self.dend[31]) h.pt3dadd(-744.5, 92.5, 119.5, 1.2, sec = self.dend[31]) h.pt3dadd(-747, 92.5, 119.5, 1.2, sec = self.dend[31]) h.pt3dadd(-750, 92.5, 123.5, 1.8, sec = self.dend[31]) h.pt3dadd(-751.5, 92.5, 123.5, 3.3, sec = self.dend[31]) h.pt3dadd(-754, 90.5, 124.5, 2, sec = self.dend[31]) h.pt3dadd(-755.5, 90.5, 124.5, 0.9, sec = self.dend[31]) h.pt3dadd(-758, 90, 124.5, 0.9, sec = self.dend[31]) h.pt3dadd(-759.5, 90, 124.5, 0.9, sec = self.dend[31]) h.pt3dadd(-760.5, 91, 126, 0.9, sec = self.dend[31]) h.pt3dadd(-762, 91, 126, 1.4, sec = self.dend[31]) h.pt3dadd(-763.5, 91, 127, 1.9, sec = self.dend[31]) h.pt3dadd(-766, 91, 127, 3.2, sec = self.dend[31]) h.pt3dadd(-769, 90, 127, 1.7, sec = self.dend[31]) h.pt3dadd(-770, 88.5, 127, 1.7, sec = self.dend[31]) h.pt3dadd(-771.5, 89, 127, 1.7, sec = self.dend[31]) h.pt3dadd(-774.5, 89, 127, 2, sec = self.dend[31]) h.pt3dadd(-777, 88, 127, 2.8, sec = self.dend[31]) h.pt3dadd(-778, 85.5, 127, 3.5, sec = self.dend[31]) h.pt3dadd(-781.5, 84.5, 128.5, 2.1, sec = self.dend[31]) h.pt3dadd(-784, 82.5, 127, 1.6, sec = self.dend[31]) h.pt3dadd(-786.5, 82, 127, 1.8, sec = self.dend[31]) h.pt3dadd(-788.5, 82, 127, 1.6, sec = self.dend[31]) h.pt3dadd(-790.5, 81.5, 127, 2.4, sec = self.dend[31]) h.pt3dadd(-793, 80, 127, 1.1, sec = self.dend[31]) h.pt3dadd(-794, 80, 127, 0.7, sec = self.dend[31]) h.pt3dadd(-796, 79.5, 127, 1.4, sec = self.dend[31]) h.pt3dadd(-797.5, 77.5, 128.5, 2.6, sec = self.dend[31]) h.pt3dadd(-799.5, 77, 128.5, 3.1, sec = self.dend[31]) h.pt3dadd(-802, 74.5, 128.5, 2.3, sec = self.dend[31]) h.pt3dadd(-804.5, 74, 128.5, 1.4, sec = self.dend[31]) h.pt3dadd(-806.5, 73, 130, 1, sec = self.dend[31]) h.pt3dadd(-812.5, 69.5, 131, 0.7, sec = self.dend[31]) h.pt3dadd(-813, 67, 132.5, 1.2, sec = self.dend[31]) h.pt3dadd(-815, 67, 132.5, 2.4, sec = self.dend[31]) h.pt3dadd(-816.5, 66.5, 132.5, 1.3, sec = self.dend[31]) h.pt3dadd(-818, 66.5, 132.5, 0.9, sec = self.dend[31]) h.pt3dadd(-819.5, 64.5, 132.5, 0.9, sec = self.dend[31]) h.pt3dadd(-820.5, 64, 132.5, 1.6, sec = self.dend[31]) h.pt3dadd(-822.5, 63.5, 132.5, 1.7, sec = self.dend[31]) h.pt3dadd(-825, 61, 132.5, 0.7, sec = self.dend[31]) h.pt3dadd(-826.5, 61, 132.5, 0.7, sec = self.dend[31]) h.pt3dadd(-828.5, 59.5, 132.5, 2.1, sec = self.dend[31]) h.pt3dadd(-830, 59.5, 132.5, 3.2, sec = self.dend[31]) h.pt3dadd(-831.5, 58, 132.5, 2, sec = self.dend[31]) h.pt3dadd(-834, 56.5, 132.5, 1.1, sec = self.dend[31]) h.pt3dadd(-835.5, 56.5, 132.5, 0.6, sec = self.dend[31]) h.pt3dadd(-838, 54.5, 132.5, 0.6, sec = self.dend[31]) h.pt3dadd(-842, 52.5, 132.5, 0.6, sec = self.dend[31]) h.pt3dadd(-844.5, 52, 132.5, 1.7, sec = self.dend[31]) h.pt3dadd(-846.5, 50.5, 135, 3.6, sec = self.dend[31]) h.pt3dadd(-849.5, 49, 135, 2.2, sec = self.dend[31]) h.pt3dadd(-852.5, 47.5, 132.5, 0.5, sec = self.dend[31]) h.pt3dadd(-855.5, 46.5, 132.5, 0.5, sec = self.dend[31]) h.pt3dadd(-859, 46, 132.5, 0.5, sec = self.dend[31]) h.pt3dadd(-861, 45.5, 134, 2.4, sec = self.dend[31]) h.pt3dadd(-863, 45, 135, 3.2, sec = self.dend[31]) h.pt3dadd(-866, 44, 135, 2.2, sec = self.dend[31]) h.pt3dadd(-869.5, 44, 135, 1.6, sec = self.dend[31]) h.pt3dadd(-871.5, 43, 135, 0.9, sec = self.dend[31]) h.pt3dadd(-875, 43, 136.5, 1, sec = self.dend[31]) h.pt3dadd(-878.5, 43, 136.5, 1.2, sec = self.dend[31]) h.pt3dadd(-881, 43, 136.5, 1.8, sec = self.dend[31]) h.pt3dadd(-884.5, 43, 136.5, 0.7, sec = self.dend[31]) h.pt3dadd(-889, 41.5, 136.5, 1, sec = self.dend[31]) h.pt3dadd(-891, 42, 136.5, 0.8, sec = self.dend[31]) h.pt3dadd(-895, 42, 136.5, 0.8, sec = self.dend[31]) h.pt3dadd(-897.5, 41.5, 136.5, 0.9, sec = self.dend[31]) h.pt3dadd(-901, 40, 136.5, 0.9, sec = self.dend[31]) h.pt3dadd(-903.5, 38.5, 136.5, 1.1, sec = self.dend[31]) h.pt3dadd(-906, 37, 136.5, 1.4, sec = self.dend[31]) h.pt3dadd(-908.5, 35.5, 136.5, 0.6, sec = self.dend[31]) h.pt3dadd(-911, 33.5, 136.5, 0.6, sec = self.dend[31]) h.pt3dadd(-913.5, 34, 135, 1.5, sec = self.dend[31]) h.pt3dadd(-915.5, 34, 135, 2.2, sec = self.dend[31]) h.pt3dadd(-917.5, 34, 135, 1.7, sec = self.dend[31]) h.pt3dadd(-920.5, 33.5, 135, 1.2, sec = self.dend[31]) h.pt3dadd(-923.5, 32.5, 135, 1.5, sec = self.dend[31]) h.pt3dadd(-926.5, 32, 135, 1.6, sec = self.dend[31]) h.pt3dadd(-929, 31.5, 135, 1.9, sec = self.dend[31]) h.pt3dadd(-931.5, 31.5, 135, 1.9, sec = self.dend[31]) h.pt3dadd(-937, 31, 136.5, 1.5, sec = self.dend[31]) h.pt3dadd(-940.5, 31, 136.5, 1.5, sec = self.dend[31]) h.pt3dadd(-943.5, 31, 136.5, 1.8, sec = self.dend[31]) h.pt3dadd(-947, 33, 143, 1.8, sec = self.dend[31]) h.pt3dclear(sec = self.dend[32]) h.pt3dadd(-6, 18.5, -1, 9.3, sec = self.dend[32]) h.pt3dadd(-13, 22, -1, 8.4, sec = self.dend[32]) h.pt3dadd(-17, 24.5, -1, 7.5, sec = self.dend[32]) h.pt3dadd(-22, 25.5, 2, 9.3, sec = self.dend[32]) h.pt3dadd(-26.5, 27.5, 2, 8.2, sec = self.dend[32]) h.pt3dadd(-32.5, 29, 3.5, 9.6, sec = self.dend[32]) h.pt3dadd(-34, 33, 6, 6.6, sec = self.dend[32]) h.pt3dadd(-36.5, 32.5, 6, 6.2, sec = self.dend[32]) h.pt3dadd(-39.5, 27.5, 5, 6.8, sec = self.dend[32]) h.pt3dadd(-42.5, 31.5, 5, 6.8, sec = self.dend[32]) h.pt3dadd(-46.5, 31.5, 13.5, 6.8, sec = self.dend[32]) h.pt3dadd(-50.5, 30.5, 13.5, 6.8, sec = self.dend[32]) h.pt3dadd(-54.5, 28.5, 15, 8.9, sec = self.dend[32]) h.pt3dclear(sec = self.dend[33]) h.pt3dadd(-54.5, 28.5, 15, 8.9, sec = self.dend[33]) h.pt3dadd(-52, 22, 13.5, 3.4, sec = self.dend[33]) h.pt3dadd(-50, 22, 13.5, 3.4, sec = self.dend[33]) h.pt3dadd(-46.5, 22, 13.5, 3.6, sec = self.dend[33]) h.pt3dadd(-44.5, 21, 20.5, 3.6, sec = self.dend[33]) h.pt3dadd(-41.5, 19, 22, 3.5, sec = self.dend[33]) h.pt3dclear(sec = self.dend[34]) h.pt3dadd(-54.5, 28.5, 15, 8.9, sec = self.dend[34]) h.pt3dadd(-57.5, 27.5, 15, 9.7, sec = self.dend[34]) h.pt3dadd(-61, 24, 16, 8.3, sec = self.dend[34]) h.pt3dadd(-64, 23, 16, 7.3, sec = self.dend[34]) h.pt3dadd(-67.5, 22, 16, 6.3, sec = self.dend[34]) h.pt3dadd(-71.5, 20, 16, 7.2, sec = self.dend[34]) h.pt3dadd(-75.5, 20, 16, 8.6, sec = self.dend[34]) h.pt3dadd(-83, 18, 23.5, 8.2, sec = self.dend[34]) h.pt3dadd(-89, 18.5, 27, 7.4, sec = self.dend[34]) h.pt3dadd(-94.5, 17.5, 30.5, 7.8, sec = self.dend[34]) h.pt3dadd(-100.5, 16.5, 30.5, 7.8, sec = self.dend[34]) h.pt3dadd(-106.5, 16.5, 30.5, 7.8, sec = self.dend[34]) h.pt3dadd(-110.5, 16.5, 32.5, 7.8, sec = self.dend[34]) h.pt3dadd(-116, 15.5, 30.5, 7.8, sec = self.dend[34]) h.pt3dadd(-121.5, 12.5, 34, 7.3, sec = self.dend[34]) h.pt3dadd(-125.5, 11, 36, 7.9, sec = self.dend[34]) h.pt3dadd(-131, 10.5, 36, 7.9, sec = self.dend[34]) h.pt3dadd(-138, 8.5, 36, 7.4, sec = self.dend[34]) h.pt3dadd(-143, 8, 36, 7, sec = self.dend[34]) h.pt3dadd(-149.5, 7, 37.5, 7.4, sec = self.dend[34]) h.pt3dadd(-154.5, 5, 37.5, 8, sec = self.dend[34]) h.pt3dadd(-159.5, 1.5, 41.5, 8.1, sec = self.dend[34]) h.pt3dadd(-165, -2, 43, 5.1, sec = self.dend[34]) h.pt3dadd(-169.5, -4.5, 40, 5.1, sec = self.dend[34]) h.pt3dadd(-175, -6, 40, 6.1, sec = self.dend[34]) h.pt3dadd(-179.5, -9.5, 43, 7, sec = self.dend[34]) h.pt3dadd(-184.5, -11, 43, 7, sec = self.dend[34]) h.pt3dadd(-188, -12.5, 41.5, 7, sec = self.dend[34]) h.pt3dadd(-190.5, -14.5, 41.5, 7.3, sec = self.dend[34]) h.pt3dclear(sec = self.dend[35]) h.pt3dadd(-190.5, -14.5, 41.5, 7.3, sec = self.dend[35]) h.pt3dadd(-192, -21, 46, 2.7, sec = self.dend[35]) h.pt3dadd(-192, -25.5, 46, 2.7, sec = self.dend[35]) h.pt3dadd(-193.5, -26.5, 46, 2.9, sec = self.dend[35]) h.pt3dadd(-193.5, -29, 44.5, 2.9, sec = self.dend[35]) h.pt3dadd(-195, -31.5, 46, 4, sec = self.dend[35]) h.pt3dclear(sec = self.dend[36]) h.pt3dadd(-195, -31.5, 46, 4, sec = self.dend[36]) h.pt3dadd(-192, -31.5, 46, 0.1, sec = self.dend[36]) h.pt3dadd(-192.5, -34, 47.5, 0.1, sec = self.dend[36]) h.pt3dadd(-196.5, -35.5, 47.5, 0.1, sec = self.dend[36]) h.pt3dadd(-198, -39, 47.5, 0.1, sec = self.dend[36]) h.pt3dadd(-200, -43.5, 47.5, 0.1, sec = self.dend[36]) h.pt3dadd(-200, -44.5, 49, 0.1, sec = self.dend[36]) h.pt3dadd(-200, -46.5, 50.5, 0.1, sec = self.dend[36]) h.pt3dadd(-201.5, -49, 52, 0.1, sec = self.dend[36]) h.pt3dclear(sec = self.dend[37]) h.pt3dadd(-195, -31.5, 46, 4, sec = self.dend[37]) h.pt3dadd(-198.5, -35, 46, 2.7, sec = self.dend[37]) h.pt3dadd(-201, -38.5, 49, 1.9, sec = self.dend[37]) h.pt3dadd(-202, -39, 49, 2.8, sec = self.dend[37]) h.pt3dadd(-203.5, -42, 50.5, 4, sec = self.dend[37]) h.pt3dadd(-206.5, -38.5, 55, 4, sec = self.dend[37]) h.pt3dadd(-208, -38, 55, 3.6, sec = self.dend[37]) h.pt3dadd(-211, -38.5, 56.5, 2.2, sec = self.dend[37]) h.pt3dadd(-211, -40, 55, 2, sec = self.dend[37]) h.pt3dadd(-211, -42, 59.5, 3.1, sec = self.dend[37]) h.pt3dadd(-211, -44, 59.5, 3.2, sec = self.dend[37]) h.pt3dadd(-215.5, -44, 61, 2.8, sec = self.dend[37]) h.pt3dadd(-216.5, -43.5, 59.5, 3.3, sec = self.dend[37]) h.pt3dadd(-218.5, -43.5, 59.5, 2.3, sec = self.dend[37]) h.pt3dadd(-221.5, -43.5, 59.5, 2.3, sec = self.dend[37]) h.pt3dadd(-225, -43.5, 59.5, 2.3, sec = self.dend[37]) h.pt3dadd(-228.5, -45.5, 58, 2.8, sec = self.dend[37]) h.pt3dadd(-232, -47, 58, 3.6, sec = self.dend[37]) h.pt3dadd(-235, -47, 58, 3.7, sec = self.dend[37]) h.pt3dadd(-239, -48.5, 58, 3.6, sec = self.dend[37]) h.pt3dadd(-243, -48.5, 56, 2.3, sec = self.dend[37]) h.pt3dadd(-244.5, -48, 58, 1.1, sec = self.dend[37]) h.pt3dadd(-247, -48, 54, 2, sec = self.dend[37]) h.pt3dclear(sec = self.dend[38]) h.pt3dadd(-247, -48, 54, 2, sec = self.dend[38]) h.pt3dadd(-250.5, -49.5, 52, 1, sec = self.dend[38]) h.pt3dadd(-251, -51, 54, 3, sec = self.dend[38]) h.pt3dadd(-253.5, -53.5, 54, 4.1, sec = self.dend[38]) h.pt3dadd(-256.5, -55.5, 52, 1.6, sec = self.dend[38]) h.pt3dadd(-259, -57, 52, 1.4, sec = self.dend[38]) h.pt3dadd(-261, -59.5, 52, 1.6, sec = self.dend[38]) h.pt3dadd(-264, -60, 52, 1.6, sec = self.dend[38]) h.pt3dadd(-267.5, -60, 52, 2, sec = self.dend[38]) h.pt3dadd(-269, -62, 52, 1.5, sec = self.dend[38]) h.pt3dadd(-271.5, -62, 52, 1.2, sec = self.dend[38]) h.pt3dadd(-272, -62, 52, 2.2, sec = self.dend[38]) h.pt3dadd(-273.5, -62.5, 54, 4, sec = self.dend[38]) h.pt3dadd(-276, -65.5, 52, 1.6, sec = self.dend[38]) h.pt3dadd(-278, -65.5, 52, 1.3, sec = self.dend[38]) h.pt3dadd(-279, -66.5, 60, 1.3, sec = self.dend[38]) h.pt3dadd(-281, -68.5, 60, 2.3, sec = self.dend[38]) h.pt3dadd(-284, -69.5, 60, 0.7, sec = self.dend[38]) h.pt3dadd(-286, -72, 60, 1.3, sec = self.dend[38]) h.pt3dadd(-288, -74.5, 60, 1.3, sec = self.dend[38]) h.pt3dadd(-291.5, -78.5, 62.5, 0.8, sec = self.dend[38]) h.pt3dadd(-291.5, -80, 62.5, 0.5, sec = self.dend[38]) h.pt3dadd(-292, -81, 62.5, 1.2, sec = self.dend[38]) h.pt3dadd(-293, -81, 62.5, 2, sec = self.dend[38]) h.pt3dadd(-295.5, -82, 62.5, 2.8, sec = self.dend[38]) h.pt3dadd(-298.5, -84.5, 62.5, 1.8, sec = self.dend[38]) h.pt3dadd(-301, -86, 62.5, 0.9, sec = self.dend[38]) h.pt3dadd(-301, -88.5, 62.5, 0.9, sec = self.dend[38]) h.pt3dadd(-301, -89, 62.5, 1.5, sec = self.dend[38]) h.pt3dadd(-302, -90.5, 62.5, 2.9, sec = self.dend[38]) h.pt3dadd(-303.5, -92.5, 62.5, 2.9, sec = self.dend[38]) h.pt3dadd(-305, -96.5, 62.5, 1.8, sec = self.dend[38]) h.pt3dadd(-305.5, -97.5, 62.5, 0.9, sec = self.dend[38]) h.pt3dadd(-306, -100, 62.5, 0.9, sec = self.dend[38]) h.pt3dadd(-307, -100, 61.5, 1.6, sec = self.dend[38]) h.pt3dadd(-308.5, -100.5, 70.5, 1.2, sec = self.dend[38]) h.pt3dadd(-309, -100.5, 69, 1.2, sec = self.dend[38]) h.pt3dadd(-309.5, -103, 68, 2.1, sec = self.dend[38]) h.pt3dadd(-309.5, -104.5, 66.5, 1.3, sec = self.dend[38]) h.pt3dadd(-310, -105, 66.5, 0.5, sec = self.dend[38]) h.pt3dadd(-311.5, -106, 66.5, 0.5, sec = self.dend[38]) h.pt3dadd(-312.5, -106, 66.5, 0.5, sec = self.dend[38]) h.pt3dadd(-313, -107, 66.5, 1.6, sec = self.dend[38]) h.pt3dadd(-313, -108.5, 66.5, 2.9, sec = self.dend[38]) h.pt3dadd(-313.5, -111, 65.5, 3.3, sec = self.dend[38]) h.pt3dadd(-315.5, -112.5, 66.5, 3.3, sec = self.dend[38]) h.pt3dadd(-316, -114, 66.5, 1.9, sec = self.dend[38]) h.pt3dadd(-317, -115.5, 66.5, 1.1, sec = self.dend[38]) h.pt3dadd(-318, -116, 66.5, 1.1, sec = self.dend[38]) h.pt3dadd(-319, -118.5, 68, 2.2, sec = self.dend[38]) h.pt3dadd(-320, -120, 68, 2.2, sec = self.dend[38]) h.pt3dadd(-319, -121, 68, 4.4, sec = self.dend[38]) h.pt3dadd(-321, -123, 85, 2.3, sec = self.dend[38]) h.pt3dadd(-322, -124.5, 85, 2.3, sec = self.dend[38]) h.pt3dadd(-322, -126, 78.5, 5, sec = self.dend[38]) h.pt3dadd(-323, -128, 80, 3.1, sec = self.dend[38]) h.pt3dadd(-325.5, -124.5, 80, 2.4, sec = self.dend[38]) h.pt3dadd(-327.5, -124, 80, 2.1, sec = self.dend[38]) h.pt3dclear(sec = self.dend[39]) h.pt3dadd(-247, -48, 54, 2, sec = self.dend[39]) h.pt3dadd(-250, -48, 54, 1.1, sec = self.dend[39]) h.pt3dadd(-253.5, -48, 54, 1.4, sec = self.dend[39]) h.pt3dadd(-257, -48, 54, 1.7, sec = self.dend[39]) h.pt3dadd(-259.5, -48, 54, 1.2, sec = self.dend[39]) h.pt3dadd(-263, -48, 54, 1.2, sec = self.dend[39]) h.pt3dadd(-265, -48, 54, 1.5, sec = self.dend[39]) h.pt3dadd(-267, -49.5, 52, 2.1, sec = self.dend[39]) h.pt3dadd(-270, -51.5, 50, 2.7, sec = self.dend[39]) h.pt3dadd(-273.5, -55, 50, 2.3, sec = self.dend[39]) h.pt3dadd(-274.5, -56, 50, 1.4, sec = self.dend[39]) h.pt3dadd(-276, -57, 50, 1.1, sec = self.dend[39]) h.pt3dadd(-276.5, -59, 50, 2.1, sec = self.dend[39]) h.pt3dadd(-280, -60.5, 50, 2.1, sec = self.dend[39]) h.pt3dadd(-281.5, -63, 50, 1.7, sec = self.dend[39]) h.pt3dadd(-284, -66, 50, 2.9, sec = self.dend[39]) h.pt3dadd(-287.5, -68, 50, 2.9, sec = self.dend[39]) h.pt3dadd(-290.5, -69, 54, 1.6, sec = self.dend[39]) h.pt3dadd(-291, -70.5, 54, 1.4, sec = self.dend[39]) h.pt3dadd(-294.5, -70.5, 54, 1.4, sec = self.dend[39]) h.pt3dadd(-299, -71.5, 56, 1.4, sec = self.dend[39]) h.pt3dadd(-301.5, -71.5, 56, 1.4, sec = self.dend[39]) h.pt3dadd(-306, -71.5, 58, 1.6, sec = self.dend[39]) h.pt3dadd(-308.5, -72, 58, 1.6, sec = self.dend[39]) h.pt3dadd(-312.5, -75, 54, 1.2, sec = self.dend[39]) h.pt3dadd(-315, -77.5, 62, 2.7, sec = self.dend[39]) h.pt3dadd(-317, -80.5, 76, 3.3, sec = self.dend[39]) h.pt3dadd(-319.5, -81.5, 79, 0.9, sec = self.dend[39]) h.pt3dadd(-322, -83.5, 79, 1.6, sec = self.dend[39]) h.pt3dadd(-322.5, -84, 79, 2.6, sec = self.dend[39]) h.pt3dadd(-326, -85.5, 79, 1.2, sec = self.dend[39]) h.pt3dadd(-326, -87.5, 80, 1.2, sec = self.dend[39]) h.pt3dadd(-326.5, -88, 80, 1.2, sec = self.dend[39]) h.pt3dadd(-328.5, -88.5, 80, 2.9, sec = self.dend[39]) h.pt3dadd(-331, -89, 80, 3.1, sec = self.dend[39]) h.pt3dadd(-333.5, -90.5, 80, 2.1, sec = self.dend[39]) h.pt3dadd(-334.5, -92.5, 80, 2.1, sec = self.dend[39]) h.pt3dadd(-333, -94.5, 84, 2.9, sec = self.dend[39]) h.pt3dadd(-333, -96, 84, 2.6, sec = self.dend[39]) h.pt3dadd(-335, -96.5, 84, 2, sec = self.dend[39]) h.pt3dadd(-337, -97, 85.5, 1.8, sec = self.dend[39]) h.pt3dadd(-337.5, -100, 84, 1.8, sec = self.dend[39]) h.pt3dadd(-339.5, -103, 84, 3.3, sec = self.dend[39]) h.pt3dadd(-341.5, -104.5, 84, 2.6, sec = self.dend[39]) h.pt3dadd(-343.5, -107.5, 84, 1.7, sec = self.dend[39]) h.pt3dadd(-345.5, -109, 81.5, 2.4, sec = self.dend[39]) h.pt3dadd(-346, -111.5, 92, 2.2, sec = self.dend[39]) h.pt3dadd(-346, -116, 90.5, 2.8, sec = self.dend[39]) h.pt3dadd(-346, -117.5, 92, 3.3, sec = self.dend[39]) h.pt3dadd(-347.5, -119.5, 92, 2.3, sec = self.dend[39]) h.pt3dadd(-347.5, -123.5, 92, 1.8, sec = self.dend[39]) h.pt3dadd(-348.5, -125, 93.5, 2.3, sec = self.dend[39]) h.pt3dadd(-349, -128, 93.5, 3.9, sec = self.dend[39]) h.pt3dclear(sec = self.dend[40]) h.pt3dadd(-349, -128, 93.5, 3.9, sec = self.dend[40]) h.pt3dadd(-353.5, -127.5, 94.5, 1.7, sec = self.dend[40]) h.pt3dadd(-357, -127, 93.5, 1.6, sec = self.dend[40]) h.pt3dclear(sec = self.dend[41]) h.pt3dadd(-349, -128, 93.5, 3.9, sec = self.dend[41]) h.pt3dadd(-349, -131.5, 93.5, 2.8, sec = self.dend[41]) h.pt3dadd(-349, -133, 93.5, 1.4, sec = self.dend[41]) h.pt3dadd(-349, -134, 93.5, 0.9, sec = self.dend[41]) h.pt3dadd(-349, -138, 94.5, 2.3, sec = self.dend[41]) h.pt3dadd(-349, -141, 94.5, 2.3, sec = self.dend[41]) h.pt3dadd(-348.5, -142.5, 94.5, 2, sec = self.dend[41]) h.pt3dadd(-348, -143, 94.5, 1.1, sec = self.dend[41]) h.pt3dadd(-347, -145, 92, 1.3, sec = self.dend[41]) h.pt3dadd(-345.5, -145.5, 92, 2.8, sec = self.dend[41]) h.pt3dadd(-343.5, -147.5, 94.5, 3.2, sec = self.dend[41]) h.pt3dadd(-341, -150, 92, 3.5, sec = self.dend[41]) h.pt3dadd(-340.5, -152, 92, 3.1, sec = self.dend[41]) h.pt3dadd(-340.5, -154, 92, 2.9, sec = self.dend[41]) h.pt3dadd(-340.5, -155, 92, 1.7, sec = self.dend[41]) h.pt3dadd(-340.5, -158, 92, 2.2, sec = self.dend[41]) h.pt3dadd(-340.5, -160, 92, 2.2, sec = self.dend[41]) h.pt3dadd(-341, -161.5, 93.5, 2.9, sec = self.dend[41]) h.pt3dadd(-340, -162.5, 93.5, 3.3, sec = self.dend[41]) h.pt3dadd(-340.5, -166, 93.5, 2.5, sec = self.dend[41]) h.pt3dadd(-341, -166, 93.5, 1.3, sec = self.dend[41]) h.pt3dadd(-341, -168.5, 93.5, 1.4, sec = self.dend[41]) h.pt3dadd(-341, -169, 93.5, 1.5, sec = self.dend[41]) h.pt3dadd(-340, -170.5, 93.5, 1.5, sec = self.dend[41]) h.pt3dadd(-340.5, -172, 92, 1.5, sec = self.dend[41]) h.pt3dadd(-339, -173, 94.5, 1.7, sec = self.dend[41]) h.pt3dadd(-337.5, -175.5, 94.5, 1.2, sec = self.dend[41]) h.pt3dadd(-337.5, -178.5, 96, 2.5, sec = self.dend[41]) h.pt3dadd(-336.5, -180, 96, 1.5, sec = self.dend[41]) h.pt3dadd(-336, -183.5, 96, 1.7, sec = self.dend[41]) h.pt3dadd(-334.5, -186.5, 96, 1.7, sec = self.dend[41]) h.pt3dadd(-334.5, -189, 96, 1.7, sec = self.dend[41]) h.pt3dadd(-337, -192.5, 98.5, 1.7, sec = self.dend[41]) h.pt3dadd(-338, -196.5, 94.5, 2.4, sec = self.dend[41]) h.pt3dadd(-338, -200, 94.5, 2.7, sec = self.dend[41]) h.pt3dadd(-335.5, -203, 96, 1.9, sec = self.dend[41]) h.pt3dadd(-335, -204, 96, 1.4, sec = self.dend[41]) h.pt3dadd(-334, -206.5, 96, 0.7, sec = self.dend[41]) h.pt3dadd(-332, -209.5, 96, 0.8, sec = self.dend[41]) h.pt3dadd(-332, -211, 96, 1.3, sec = self.dend[41]) h.pt3dadd(-333, -214, 97.5, 2.4, sec = self.dend[41]) h.pt3dadd(-333, -216, 97.5, 1.7, sec = self.dend[41]) h.pt3dadd(-333, -218.5, 97.5, 1.4, sec = self.dend[41]) h.pt3dadd(-333, -222, 97.5, 1.9, sec = self.dend[41]) h.pt3dadd(-332, -224, 97.5, 1.6, sec = self.dend[41]) h.pt3dadd(-332, -227, 97.5, 2.4, sec = self.dend[41]) h.pt3dadd(-332, -230.5, 97.5, 2.4, sec = self.dend[41]) h.pt3dadd(-332, -234.5, 97.5, 2.3, sec = self.dend[41]) h.pt3dadd(-332, -238, 97.5, 2.3, sec = self.dend[41]) h.pt3dadd(-333, -240, 97.5, 2.1, sec = self.dend[41]) h.pt3dadd(-333.5, -243.5, 94.5, 1.3, sec = self.dend[41]) h.pt3dadd(-333, -246.5, 96, 1.6, sec = self.dend[41]) h.pt3dadd(-332.5, -251, 97.5, 1.6, sec = self.dend[41]) h.pt3dadd(-333, -252.5, 98.5, 1.6, sec = self.dend[41]) h.pt3dadd(-332, -256, 100, 1.1, sec = self.dend[41]) h.pt3dadd(-331, -261, 101, 1.5, sec = self.dend[41]) h.pt3dadd(-330.5, -265, 101, 2.4, sec = self.dend[41]) h.pt3dadd(-327.5, -269.5, 102.5, 3.2, sec = self.dend[41]) h.pt3dadd(-327.5, -271.5, 102.5, 2.5, sec = self.dend[41]) h.pt3dadd(-329, -274.5, 102.5, 2.5, sec = self.dend[41]) h.pt3dadd(-331, -277, 104, 2.5, sec = self.dend[41]) h.pt3dadd(-331.5, -279.5, 104, 1.3, sec = self.dend[41]) h.pt3dadd(-331.5, -283, 98.5, 1.3, sec = self.dend[41]) h.pt3dadd(-331.5, -287.5, 98.5, 1.4, sec = self.dend[41]) h.pt3dadd(-332.5, -290.5, 100, 1.4, sec = self.dend[41]) h.pt3dadd(-333.5, -294.5, 101, 1.4, sec = self.dend[41]) h.pt3dadd(-333.5, -297, 101, 1.4, sec = self.dend[41]) h.pt3dadd(-334.5, -300, 101, 0.9, sec = self.dend[41]) h.pt3dadd(-336, -300, 101, 0.9, sec = self.dend[41]) h.pt3dadd(-336, -302, 101, 1.1, sec = self.dend[41]) h.pt3dadd(-337, -301.5, 102.5, 1.3, sec = self.dend[41]) h.pt3dclear(sec = self.dend[42]) h.pt3dadd(-337, -301.5, 102.5, 1.3, sec = self.dend[42]) h.pt3dadd(-338.5, -301.5, 85.5, 0.7, sec = self.dend[42]) h.pt3dadd(-342, -305.5, 84, 0.7, sec = self.dend[42]) h.pt3dadd(-345.5, -310, 86.5, 0.7, sec = self.dend[42]) h.pt3dadd(-345.5, -313, 86.5, 0.9, sec = self.dend[42]) h.pt3dadd(-343.5, -317.5, 86.5, 0.6, sec = self.dend[42]) h.pt3dadd(-336.5, -316.5, 89.5, 0.6, sec = self.dend[42]) h.pt3dadd(-336, -322, 89.5, 0.6, sec = self.dend[42]) h.pt3dadd(-335, -322.5, 109, 1.8, sec = self.dend[42]) h.pt3dadd(-333, -323, 97.5, 0.1, sec = self.dend[42]) h.pt3dadd(-330, -322.5, 97.5, 0.1, sec = self.dend[42]) h.pt3dadd(-328, -322.5, 102.5, 1.4, sec = self.dend[42]) h.pt3dadd(-323, -322.5, 97.5, 0.2, sec = self.dend[42]) h.pt3dadd(-320.5, -322.5, 97.5, 0.2, sec = self.dend[42]) h.pt3dadd(-317.5, -326.5, 97.5, 0.2, sec = self.dend[42]) h.pt3dadd(-315.5, -328, 97.5, 2.3, sec = self.dend[42]) h.pt3dadd(-317, -331.5, 94.5, 0.6, sec = self.dend[42]) h.pt3dadd(-321.5, -333, 94.5, 0.6, sec = self.dend[42]) h.pt3dadd(-324.5, -333, 98.5, 0.6, sec = self.dend[42]) h.pt3dclear(sec = self.dend[43]) h.pt3dadd(-337, -301.5, 102.5, 1.3, sec = self.dend[43]) h.pt3dadd(-337.5, -304, 102.5, 1.1, sec = self.dend[43]) h.pt3dadd(-339, -305.5, 102.5, 1.1, sec = self.dend[43]) h.pt3dadd(-341, -308, 104, 1.1, sec = self.dend[43]) h.pt3dadd(-341.5, -310.5, 104, 1.1, sec = self.dend[43]) h.pt3dadd(-339, -312, 106.5, 1.6, sec = self.dend[43]) h.pt3dadd(-339, -313.5, 106.5, 0.9, sec = self.dend[43]) h.pt3dadd(-339, -316.5, 105, 0.9, sec = self.dend[43]) h.pt3dadd(-341, -319.5, 102.5, 0.9, sec = self.dend[43]) h.pt3dclear(sec = self.dend[44]) h.pt3dadd(-190.5, -14.5, 41.5, 7.3, sec = self.dend[44]) h.pt3dadd(-195.5, -15.5, 41.5, 5.2, sec = self.dend[44]) h.pt3dadd(-200, -18, 41.5, 5.5, sec = self.dend[44]) h.pt3dadd(-203.5, -18.5, 41.5, 6, sec = self.dend[44]) h.pt3dadd(-209.5, -20.5, 47.5, 5.6, sec = self.dend[44]) h.pt3dadd(-214, -20.5, 47.5, 6.1, sec = self.dend[44]) h.pt3dadd(-218, -21.5, 47.5, 5.5, sec = self.dend[44]) h.pt3dadd(-221, -21.5, 47.5, 4.6, sec = self.dend[44]) h.pt3dadd(-224, -24.5, 47.5, 6.5, sec = self.dend[44]) h.pt3dadd(-226.5, -25, 47.5, 6.8, sec = self.dend[44]) h.pt3dclear(sec = self.dend[45]) h.pt3dadd(-226.5, -25, 47.5, 6.8, sec = self.dend[45]) h.pt3dadd(-232.5, -21.5, 46, 1.9, sec = self.dend[45]) h.pt3dadd(-236, -20, 46, 2.3, sec = self.dend[45]) h.pt3dadd(-239, -19.5, 46, 2.4, sec = self.dend[45]) h.pt3dadd(-240.5, -19.5, 46, 3.3, sec = self.dend[45]) h.pt3dadd(-242.5, -19.5, 46, 3.8, sec = self.dend[45]) h.pt3dadd(-245.5, -19.5, 46, 2, sec = self.dend[45]) h.pt3dadd(-249, -18, 47.5, 2, sec = self.dend[45]) h.pt3dadd(-253, -16.5, 47.5, 1.8, sec = self.dend[45]) h.pt3dadd(-257, -15, 47.5, 1.8, sec = self.dend[45]) h.pt3dadd(-260, -15, 47.5, 1.8, sec = self.dend[45]) h.pt3dadd(-262.5, -13.5, 47.5, 1.7, sec = self.dend[45]) h.pt3dadd(-265, -12, 47.5, 1.9, sec = self.dend[45]) h.pt3dadd(-267.5, -12.5, 52, 3.1, sec = self.dend[45]) h.pt3dadd(-270.5, -12.5, 52, 4.6, sec = self.dend[45]) h.pt3dadd(-273.5, -12.5, 50.5, 2.7, sec = self.dend[45]) h.pt3dadd(-275, -12.5, 50.5, 2.1, sec = self.dend[45]) h.pt3dadd(-277.5, -12.5, 53.5, 3.2, sec = self.dend[45]) h.pt3dadd(-280, -12.5, 53.5, 4, sec = self.dend[45]) h.pt3dadd(-284, -12.5, 53.5, 3.7, sec = self.dend[45]) h.pt3dadd(-289, -11, 56.5, 2.8, sec = self.dend[45]) h.pt3dadd(-292.5, -10.5, 56.5, 2.1, sec = self.dend[45]) h.pt3dadd(-295, -8.5, 56.5, 1.7, sec = self.dend[45]) h.pt3dadd(-297.5, -8.5, 56.5, 1.8, sec = self.dend[45]) h.pt3dadd(-301.5, -8, 56.5, 1.3, sec = self.dend[45]) h.pt3dadd(-303, -8, 56.5, 1.2, sec = self.dend[45]) h.pt3dadd(-304.5, -8.5, 56.5, 1.8, sec = self.dend[45]) h.pt3dadd(-306, -9, 53.5, 2.5, sec = self.dend[45]) h.pt3dadd(-312, -9.5, 53.5, 0.3, sec = self.dend[45]) h.pt3dadd(-314, -10, 53.5, 1.3, sec = self.dend[45]) h.pt3dadd(-316, -9.5, 55, 2.8, sec = self.dend[45]) h.pt3dadd(-317.5, -9.5, 55, 3.8, sec = self.dend[45]) h.pt3dadd(-321.5, -9.5, 55, 1.6, sec = self.dend[45]) h.pt3dadd(-324.5, -6.5, 55, 1.3, sec = self.dend[45]) h.pt3dadd(-327, -6.5, 55, 1.3, sec = self.dend[45]) h.pt3dadd(-329, -6.5, 55, 2, sec = self.dend[45]) h.pt3dadd(-331, -5.5, 56.5, 3.6, sec = self.dend[45]) h.pt3dadd(-333, -4.5, 58, 4.6, sec = self.dend[45]) h.pt3dadd(-335.5, -4, 58, 3.2, sec = self.dend[45]) h.pt3dadd(-338, -3, 58, 1.7, sec = self.dend[45]) h.pt3dadd(-340.5, -3, 58, 1.7, sec = self.dend[45]) h.pt3dadd(-343, -3, 58, 1.2, sec = self.dend[45]) h.pt3dadd(-345.5, -2, 58, 1.2, sec = self.dend[45]) h.pt3dadd(-348, -1, 58, 1.4, sec = self.dend[45]) h.pt3dadd(-351, 1.5, 58, 2.2, sec = self.dend[45]) h.pt3dadd(-352.5, 1.5, 58, 3.7, sec = self.dend[45]) h.pt3dadd(-355, 2, 58, 5.3, sec = self.dend[45]) h.pt3dadd(-358.5, 4.5, 56.5, 2.8, sec = self.dend[45]) h.pt3dadd(-361, 5, 56.5, 2.1, sec = self.dend[45]) h.pt3dadd(-363.5, 7, 58, 1.2, sec = self.dend[45]) h.pt3dadd(-367, 9.5, 58, 1.2, sec = self.dend[45]) h.pt3dadd(-367.5, 10.5, 59.5, 1.2, sec = self.dend[45]) h.pt3dadd(-370, 12, 56.5, 2.4, sec = self.dend[45]) h.pt3dadd(-372, 11.5, 56.5, 2.7, sec = self.dend[45]) h.pt3dadd(-375.5, 12.5, 56.5, 2, sec = self.dend[45]) h.pt3dadd(-378.5, 15, 59.5, 2, sec = self.dend[45]) h.pt3dadd(-383, 15, 59.5, 1.3, sec = self.dend[45]) h.pt3dadd(-388, 15, 59.5, 1.6, sec = self.dend[45]) h.pt3dadd(-393.5, 15, 59.5, 1.6, sec = self.dend[45]) h.pt3dadd(-399, 15, 59.5, 1.8, sec = self.dend[45]) h.pt3dadd(-402.5, 15, 59.5, 1.8, sec = self.dend[45]) h.pt3dadd(-406, 14, 59.5, 1.8, sec = self.dend[45]) h.pt3dadd(-411.5, 14, 58, 1.8, sec = self.dend[45]) h.pt3dadd(-414.5, 14, 58, 1.8, sec = self.dend[45]) h.pt3dadd(-421.5, 14, 58, 1.8, sec = self.dend[45]) h.pt3dadd(-428, 11, 58, 1.8, sec = self.dend[45]) h.pt3dadd(-432.5, 10.5, 58, 1.8, sec = self.dend[45]) h.pt3dadd(-435.5, 7.5, 58, 1.1, sec = self.dend[45]) h.pt3dadd(-437.5, 7.5, 59.5, 1.8, sec = self.dend[45]) h.pt3dadd(-441.5, 7, 61, 2.4, sec = self.dend[45]) h.pt3dadd(-444, 6.5, 61, 1.7, sec = self.dend[45]) h.pt3dadd(-448.5, 6.5, 61, 1.3, sec = self.dend[45]) h.pt3dadd(-452.5, 6.5, 61, 1.3, sec = self.dend[45]) h.pt3dadd(-456.5, 6.5, 61, 1.4, sec = self.dend[45]) h.pt3dadd(-461, 7, 61, 1.4, sec = self.dend[45]) h.pt3dadd(-467, 7, 61, 1.4, sec = self.dend[45]) h.pt3dadd(-469, 7, 61, 1.2, sec = self.dend[45]) h.pt3dadd(-473, 7, 61, 1.2, sec = self.dend[45]) h.pt3dadd(-475.5, 7, 61, 2.1, sec = self.dend[45]) h.pt3dadd(-477, 7.5, 61, 1.2, sec = self.dend[45]) h.pt3dadd(-479, 8, 61, 1.7, sec = self.dend[45]) h.pt3dadd(-480.5, 8, 61, 2.1, sec = self.dend[45]) h.pt3dadd(-483, 8.5, 58, 3.2, sec = self.dend[45]) h.pt3dadd(-485.5, 9.5, 59.5, 1.9, sec = self.dend[45]) h.pt3dadd(-488, 10, 58, 1, sec = self.dend[45]) h.pt3dadd(-490, 12.5, 59.5, 1, sec = self.dend[45]) h.pt3dadd(-492.5, 12.5, 59.5, 2.2, sec = self.dend[45]) h.pt3dadd(-494.5, 12.5, 59.5, 2.8, sec = self.dend[45]) h.pt3dadd(-496.5, 13, 59.5, 2.1, sec = self.dend[45]) h.pt3dadd(-499.5, 14.5, 59.5, 1.7, sec = self.dend[45]) h.pt3dadd(-500.5, 14.5, 59.5, 0.6, sec = self.dend[45]) h.pt3dadd(-504.5, 15.5, 59.5, 0.9, sec = self.dend[45]) h.pt3dadd(-505.5, 15.5, 59.5, 2.5, sec = self.dend[45]) h.pt3dadd(-510, 15.5, 59.5, 3.8, sec = self.dend[45]) h.pt3dadd(-513.5, 15, 59.5, 2.1, sec = self.dend[45]) h.pt3dadd(-517.5, 14, 59.5, 1.2, sec = self.dend[45]) h.pt3dadd(-520, 12, 59.5, 1, sec = self.dend[45]) h.pt3dadd(-522, 11, 59.5, 1.2, sec = self.dend[45]) h.pt3dadd(-525, 9.5, 59.5, 1.2, sec = self.dend[45]) h.pt3dadd(-528, 9.5, 59.5, 0.6, sec = self.dend[45]) h.pt3dadd(-532.5, 7, 58, 0.8, sec = self.dend[45]) h.pt3dadd(-533.5, 6.5, 59.5, 2, sec = self.dend[45]) h.pt3dadd(-537.5, 4.5, 61, 2.9, sec = self.dend[45]) h.pt3dadd(-541, 3.5, 61, 1.9, sec = self.dend[45]) h.pt3dadd(-543, 3, 62.5, 0.7, sec = self.dend[45]) h.pt3dadd(-545, 2.5, 62.5, 0.7, sec = self.dend[45]) h.pt3dadd(-547, 2.5, 62.5, 1.9, sec = self.dend[45]) h.pt3dadd(-549.5, 2.5, 64, 2.8, sec = self.dend[45]) h.pt3dadd(-553, 2, 64, 1.5, sec = self.dend[45]) h.pt3dadd(-554, 2, 64, 0.7, sec = self.dend[45]) h.pt3dadd(-559.5, 0, 67, 0.9, sec = self.dend[45]) h.pt3dadd(-563.5, 0, 68.5, 0.9, sec = self.dend[45]) h.pt3dadd(-564.5, 0.5, 68.5, 0.9, sec = self.dend[45]) h.pt3dadd(-567, 0.5, 68.5, 1.8, sec = self.dend[45]) h.pt3dadd(-569.5, 0.5, 68.5, 4.4, sec = self.dend[45]) h.pt3dadd(-573.5, 0, 67, 1.5, sec = self.dend[45]) h.pt3dadd(-575, 0, 65.5, 0.7, sec = self.dend[45]) h.pt3dadd(-578.5, 0, 65.5, 0.7, sec = self.dend[45]) h.pt3dadd(-576, 2, 68.5, 0.7, sec = self.dend[45]) h.pt3dadd(-578.5, 2.5, 67, 0.7, sec = self.dend[45]) h.pt3dadd(-580, 5, 73, 0.7, sec = self.dend[45]) h.pt3dadd(-583, 4, 53.5, 0.3, sec = self.dend[45]) h.pt3dadd(-585.5, 4, 55, 0.3, sec = self.dend[45]) h.pt3dadd(-585.5, 5, 59.5, 2.3, sec = self.dend[45]) h.pt3dadd(-586, 5, 59.5, 2.8, sec = self.dend[45]) h.pt3dadd(-588.5, 5, 59.5, 1.6, sec = self.dend[45]) h.pt3dadd(-590, 5, 59.5, 0.3, sec = self.dend[45]) h.pt3dadd(-593, 5.5, 59.5, 0.3, sec = self.dend[45]) h.pt3dadd(-597.5, 7.5, 59.5, 0.3, sec = self.dend[45]) h.pt3dadd(-598.5, 9, 59.5, 1.7, sec = self.dend[45]) h.pt3dadd(-599.5, 9, 61, 2.2, sec = self.dend[45]) h.pt3dadd(-601, 8.5, 61, 1.1, sec = self.dend[45]) h.pt3dadd(-602, 9.5, 62.5, 0.5, sec = self.dend[45]) h.pt3dadd(-606.5, 10.5, 56.5, 0.5, sec = self.dend[45]) h.pt3dadd(-609, 11.5, 56.5, 0.5, sec = self.dend[45]) h.pt3dadd(-611.5, 13.5, 56.5, 0.5, sec = self.dend[45]) h.pt3dadd(-612.5, 13.5, 53.5, 1.5, sec = self.dend[45]) h.pt3dadd(-612.5, 14.5, 59.5, 2.6, sec = self.dend[45]) h.pt3dadd(-615, 14.5, 59.5, 1.2, sec = self.dend[45]) h.pt3dadd(-617, 14.5, 56.5, 0.4, sec = self.dend[45]) h.pt3dadd(-619, 16, 55, 0.6, sec = self.dend[45]) h.pt3dadd(-621, 18, 58, 1.4, sec = self.dend[45]) h.pt3dadd(-624, 18, 61, 0.4, sec = self.dend[45]) h.pt3dadd(-627, 19, 55, 0.4, sec = self.dend[45]) h.pt3dadd(-631.5, 18.5, 55, 0.4, sec = self.dend[45]) h.pt3dadd(-631, 18.5, 58, 2.4, sec = self.dend[45]) h.pt3dadd(-632, 18.5, 59.5, 2.5, sec = self.dend[45]) h.pt3dadd(-633.5, 18.5, 52, 1.4, sec = self.dend[45]) h.pt3dadd(-635, 18.5, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-638, 18.5, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-639, 18.5, 58, 1.5, sec = self.dend[45]) h.pt3dadd(-640.5, 18.5, 52, 1.9, sec = self.dend[45]) h.pt3dadd(-641.5, 18.5, 52, 0.9, sec = self.dend[45]) h.pt3dadd(-643.5, 19, 52, 0.2, sec = self.dend[45]) h.pt3dadd(-646, 21, 58, 0.2, sec = self.dend[45]) h.pt3dadd(-647.5, 20.5, 56.5, 0.9, sec = self.dend[45]) h.pt3dadd(-649.5, 20.5, 56.5, 0.3, sec = self.dend[45]) h.pt3dadd(-651, 21, 56.5, 0.3, sec = self.dend[45]) h.pt3dadd(-653, 21, 53.5, 1.8, sec = self.dend[45]) h.pt3dadd(-653.5, 21.5, 55, 2.7, sec = self.dend[45]) h.pt3dadd(-655, 21.5, 56.5, 1.5, sec = self.dend[45]) h.pt3dadd(-658, 22.5, 56.5, 0.4, sec = self.dend[45]) h.pt3dadd(-659, 25.5, 58, 0.4, sec = self.dend[45]) h.pt3dadd(-661, 25.5, 58, 1.2, sec = self.dend[45]) h.pt3dadd(-663, 25.5, 56.5, 0.3, sec = self.dend[45]) h.pt3dadd(-668, 25.5, 55, 0.2, sec = self.dend[45]) h.pt3dadd(-670, 27, 49, 1.1, sec = self.dend[45]) h.pt3dadd(-671, 27, 49, 1.4, sec = self.dend[45]) h.pt3dadd(-673, 27, 49, 0.7, sec = self.dend[45]) h.pt3dadd(-674, 27, 49, 0.2, sec = self.dend[45]) h.pt3dadd(-676, 27, 49, 0.2, sec = self.dend[45]) h.pt3dadd(-678, 27, 49, 1.1, sec = self.dend[45]) h.pt3dadd(-679, 28, 49, 1.2, sec = self.dend[45]) h.pt3dadd(-679.5, 28, 49, 0.5, sec = self.dend[45]) h.pt3dadd(-681.5, 29.5, 50.5, 0.4, sec = self.dend[45]) h.pt3dadd(-683.5, 30.5, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-685.5, 31.5, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-686.5, 31.5, 52, 1.1, sec = self.dend[45]) h.pt3dadd(-688, 31, 52, 1.1, sec = self.dend[45]) h.pt3dadd(-689, 31, 52, 0.7, sec = self.dend[45]) h.pt3dadd(-692.5, 31, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-692.5, 32.5, 52, 0.4, sec = self.dend[45]) h.pt3dadd(-694, 32.5, 52, 1.3, sec = self.dend[45]) h.pt3dadd(-695.5, 32.5, 52, 1.3, sec = self.dend[45]) h.pt3dadd(-697, 32.5, 50.5, 0.5, sec = self.dend[45]) h.pt3dadd(-698, 32.5, 50.5, 0.5, sec = self.dend[45]) h.pt3dadd(-700.5, 32.5, 49, 1.2, sec = self.dend[45]) h.pt3dadd(-702, 32.5, 50.5, 0.9, sec = self.dend[45]) h.pt3dadd(-702.5, 32.5, 52, 0.6, sec = self.dend[45]) h.pt3dadd(-704.5, 34, 53.5, 0.6, sec = self.dend[45]) h.pt3dadd(-705.5, 34.5, 55, 0.8, sec = self.dend[45]) h.pt3dadd(-708, 36, 55, 0.1, sec = self.dend[45]) h.pt3dadd(-710, 36, 55, 0.1, sec = self.dend[45]) h.pt3dadd(-710.5, 38.5, 56.5, 1.1, sec = self.dend[45]) h.pt3dadd(-713, 38.5, 56.5, 0.1, sec = self.dend[45]) h.pt3dadd(-715, 38.5, 56.5, 0.1, sec = self.dend[45]) h.pt3dadd(-718, 40, 59.5, 1.3, sec = self.dend[45]) h.pt3dadd(-719, 40, 59.5, 0.1, sec = self.dend[45]) h.pt3dadd(-721, 40, 59.5, 0.1, sec = self.dend[45]) h.pt3dadd(-724, 41.5, 59.5, 1.5, sec = self.dend[45]) h.pt3dadd(-727, 41.5, 55, 0.1, sec = self.dend[45]) h.pt3dclear(sec = self.dend[46]) h.pt3dadd(-226.5, -25, 47.5, 6.8, sec = self.dend[46]) h.pt3dadd(-229, -30.5, 47.5, 3.6, sec = self.dend[46]) h.pt3dadd(-232, -31.5, 47.5, 3.4, sec = self.dend[46]) h.pt3dadd(-235, -33, 46, 3.6, sec = self.dend[46]) h.pt3dadd(-237.5, -33, 46, 4.3, sec = self.dend[46]) h.pt3dadd(-241, -33, 52, 5, sec = self.dend[46]) h.pt3dadd(-244, -33, 52, 5, sec = self.dend[46]) h.pt3dadd(-247, -33, 52, 4.9, sec = self.dend[46]) h.pt3dadd(-250, -33, 58, 4.4, sec = self.dend[46]) h.pt3dadd(-252.5, -33.5, 49, 5.2, sec = self.dend[46]) h.pt3dadd(-255.5, -33.5, 49, 5.5, sec = self.dend[46]) h.pt3dadd(-258.5, -34, 50.5, 4.9, sec = self.dend[46]) h.pt3dadd(-262, -36, 50.5, 4.1, sec = self.dend[46]) h.pt3dadd(-266, -36.5, 50.5, 4.1, sec = self.dend[46]) h.pt3dadd(-269.5, -38.5, 50.5, 5, sec = self.dend[46]) h.pt3dadd(-272, -38.5, 50.5, 5.4, sec = self.dend[46]) h.pt3dadd(-274, -40, 50.5, 5, sec = self.dend[46]) h.pt3dadd(-276.5, -40.5, 52, 6, sec = self.dend[46]) h.pt3dadd(-278, -41, 52, 6, sec = self.dend[46]) h.pt3dadd(-280.5, -41, 52, 4.3, sec = self.dend[46]) h.pt3dadd(-284, -41.5, 52, 4.5, sec = self.dend[46]) h.pt3dadd(-288.5, -44.5, 55, 4.3, sec = self.dend[46]) h.pt3dadd(-292, -44.5, 53.5, 4, sec = self.dend[46]) h.pt3dadd(-295.5, -44, 55, 4.2, sec = self.dend[46]) h.pt3dadd(-299, -45, 55, 4.6, sec = self.dend[46]) h.pt3dadd(-303, -46, 55, 4.7, sec = self.dend[46]) h.pt3dadd(-307.5, -47, 53.5, 4.8, sec = self.dend[46]) h.pt3dadd(-311, -48.5, 53.5, 4.6, sec = self.dend[46]) h.pt3dadd(-315, -49, 53.5, 4.6, sec = self.dend[46]) h.pt3dadd(-320, -50.5, 53.5, 4.6, sec = self.dend[46]) h.pt3dadd(-323.5, -50.5, 53.5, 5.1, sec = self.dend[46]) h.pt3dadd(-326.5, -50.5, 53.5, 4.4, sec = self.dend[46]) h.pt3dadd(-330.5, -50.5, 53.5, 4.6, sec = self.dend[46]) h.pt3dadd(-334, -50.5, 53.5, 5.5, sec = self.dend[46]) h.pt3dadd(-339, -50.5, 56.5, 5.5, sec = self.dend[46]) h.pt3dadd(-345.5, -50.5, 56.5, 3.8, sec = self.dend[46]) h.pt3dadd(-350, -50, 58.5, 3.8, sec = self.dend[46]) h.pt3dadd(-354.5, -49, 54.5, 3.8, sec = self.dend[46]) h.pt3dadd(-358.5, -46.5, 56.5, 4.3, sec = self.dend[46]) h.pt3dadd(-363, -46.5, 56.5, 4.1, sec = self.dend[46]) h.pt3dadd(-366.5, -45, 58.5, 3.7, sec = self.dend[46]) h.pt3dadd(-368.5, -44.5, 58.5, 3, sec = self.dend[46]) h.pt3dadd(-370.5, -44.5, 58.5, 4.3, sec = self.dend[46]) h.pt3dadd(-374.5, -44, 60.5, 5.3, sec = self.dend[46]) h.pt3dadd(-378.5, -44, 62.5, 6.1, sec = self.dend[46]) h.pt3dadd(-381.5, -44, 62.5, 3.8, sec = self.dend[46]) h.pt3dadd(-384.5, -44, 62.5, 2.9, sec = self.dend[46]) h.pt3dadd(-386.5, -42.5, 64.5, 3.4, sec = self.dend[46]) h.pt3dadd(-389, -40, 64.5, 3.8, sec = self.dend[46]) h.pt3dadd(-390.5, -38.5, 64.5, 4.7, sec = self.dend[46]) h.pt3dadd(-393.5, -38.5, 66.5, 4.5, sec = self.dend[46]) h.pt3dadd(-398, -36, 70.5, 4.3, sec = self.dend[46]) h.pt3dadd(-400, -35.5, 72.5, 2.4, sec = self.dend[46]) h.pt3dadd(-403.5, -35.5, 74.5, 2.4, sec = self.dend[46]) h.pt3dadd(-403.5, -34, 76.5, 2.4, sec = self.dend[46]) h.pt3dadd(-407, -33, 78.5, 3.4, sec = self.dend[46]) h.pt3dadd(-411, -31.5, 78.5, 3.6, sec = self.dend[46]) h.pt3dadd(-414.5, -29, 78.5, 4.3, sec = self.dend[46]) h.pt3dadd(-419, -28, 80.5, 5.3, sec = self.dend[46]) h.pt3dadd(-423, -28, 82.5, 5.7, sec = self.dend[46]) h.pt3dadd(-429, -28.5, 89.5, 3.8, sec = self.dend[46]) h.pt3dadd(-433, -28.5, 89.5, 3.8, sec = self.dend[46]) h.pt3dadd(-436, -26.5, 90.5, 2.3, sec = self.dend[46]) h.pt3dadd(-438.5, -26.5, 90.5, 2.3, sec = self.dend[46]) h.pt3dadd(-447.5, -27.5, 93, 4.1, sec = self.dend[46]) h.pt3dadd(-451.5, -27.5, 93, 3.7, sec = self.dend[46]) h.pt3dadd(-454.5, -26.5, 94.5, 2.8, sec = self.dend[46]) h.pt3dadd(-458, -26.5, 94.5, 2.2, sec = self.dend[46]) h.pt3dadd(-459.5, -27, 94.5, 4.5, sec = self.dend[46]) h.pt3dadd(-461.5, -27.5, 96, 4.4, sec = self.dend[46]) h.pt3dadd(-465, -29, 97, 2.9, sec = self.dend[46]) h.pt3dadd(-467.5, -30, 93, 2.5, sec = self.dend[46]) h.pt3dadd(-470, -30, 93, 2.8, sec = self.dend[46]) h.pt3dadd(-473, -29.5, 96, 3.8, sec = self.dend[46]) h.pt3dadd(-478, -29.5, 97, 4.5, sec = self.dend[46]) h.pt3dadd(-483, -29.5, 97, 4.6, sec = self.dend[46]) h.pt3dadd(-487, -31, 98.5, 4.6, sec = self.dend[46]) h.pt3dadd(-491.5, -31, 98.5, 4.6, sec = self.dend[46]) h.pt3dadd(-495, -31.5, 98.5, 4.6, sec = self.dend[46]) h.pt3dadd(-498, -34, 98.5, 4.6, sec = self.dend[46]) h.pt3dadd(-500, -34, 98.5, 5.2, sec = self.dend[46]) h.pt3dadd(-502.5, -34, 100, 5, sec = self.dend[46]) h.pt3dadd(-506, -35.5, 100, 4.3, sec = self.dend[46]) h.pt3dadd(-508, -38.5, 100, 4.4, sec = self.dend[46]) h.pt3dadd(-511, -42, 100, 4.5, sec = self.dend[46]) h.pt3dclear(sec = self.dend[47]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[47]) h.pt3dadd(0, 14.5, -3, 7.4, sec = self.dend[47]) h.pt3dadd(-6, 13.5, -5, 6, sec = self.dend[47]) h.pt3dadd(-11.5, 12, -6.5, 5.7, sec = self.dend[47]) h.pt3dadd(-16.5, 11.5, -6.5, 5.7, sec = self.dend[47]) h.pt3dadd(-21.5, 10.5, -6.5, 5.3, sec = self.dend[47]) h.pt3dadd(-29.5, 10.5, -6.5, 5.4, sec = self.dend[47]) h.pt3dadd(-35.5, 10.5, -7.5, 5.4, sec = self.dend[47]) h.pt3dadd(-45, 7.5, -8.5, 5.4, sec = self.dend[47]) h.pt3dadd(-52.5, 6.5, -6.5, 5, sec = self.dend[47]) h.pt3dadd(-59.5, 2, -5.5, 4.9, sec = self.dend[47]) h.pt3dadd(-63, 0, -5.5, 4.6, sec = self.dend[47]) h.pt3dadd(-73.5, 0, -5.5, 4, sec = self.dend[47]) h.pt3dadd(-77.5, 0, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-81.5, 0, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-85.5, 0, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-94, 0.5, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-99, 2, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-104.5, 4, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-108.5, 5, -4.5, 4, sec = self.dend[47]) h.pt3dadd(-114.5, 5, -3.5, 4, sec = self.dend[47]) h.pt3dadd(-119, 7, -3.5, 4, sec = self.dend[47]) h.pt3dadd(-124.5, 8, -3.5, 3.8, sec = self.dend[47]) h.pt3dadd(-129, 9, -5.5, 3.1, sec = self.dend[47]) h.pt3dadd(-133.5, 8.5, -5.5, 2.5, sec = self.dend[47]) h.pt3dadd(-136.5, 6.5, -5.5, 2.8, sec = self.dend[47]) h.pt3dadd(-139, 4.5, -9, 3.4, sec = self.dend[47]) h.pt3dadd(-141.5, 4, -8, 3.4, sec = self.dend[47]) h.pt3dadd(-144, 1.5, -8, 4.3, sec = self.dend[47]) h.pt3dadd(-146.5, 1, -10, 2.8, sec = self.dend[47]) h.pt3dadd(-149, 1, -10, 2.4, sec = self.dend[47]) h.pt3dadd(-151, 1, -10, 2.2, sec = self.dend[47]) h.pt3dadd(-153, 1, -10, 3, sec = self.dend[47]) h.pt3dadd(-154, 1, -10, 3, sec = self.dend[47]) h.pt3dadd(-156, -1, -10, 3, sec = self.dend[47]) h.pt3dadd(-159.5, -1.5, -11.5, 3, sec = self.dend[47]) h.pt3dadd(-162, -3, -12.5, 3.4, sec = self.dend[47]) h.pt3dadd(-164.5, -3, -12.5, 2.9, sec = self.dend[47]) h.pt3dadd(-167.5, -3, -12.5, 1.7, sec = self.dend[47]) h.pt3dadd(-168.5, -4.5, -12.5, 1.6, sec = self.dend[47]) h.pt3dadd(-169.5, -6.5, -12.5, 1.9, sec = self.dend[47]) h.pt3dadd(-169.5, -8, -12.5, 1.9, sec = self.dend[47]) h.pt3dadd(-170.5, -10, -11.5, 1.6, sec = self.dend[47]) h.pt3dadd(-172, -12, -11.5, 1.9, sec = self.dend[47]) h.pt3dadd(-174, -14.5, -11.5, 2.6, sec = self.dend[47]) h.pt3dadd(-176.5, -15.5, -12.5, 2.9, sec = self.dend[47]) h.pt3dadd(-177.5, -18.5, -12.5, 3.2, sec = self.dend[47]) h.pt3dadd(-179.5, -21, -12.5, 3.8, sec = self.dend[47]) h.pt3dadd(-182, -21.5, -12.5, 4.7, sec = self.dend[47]) h.pt3dadd(-187.5, -22.5, -15, 2.1, sec = self.dend[47]) h.pt3dadd(-189, -22.5, -13.5, 1.7, sec = self.dend[47]) h.pt3dadd(-191, -22.5, -13.5, 2.1, sec = self.dend[47]) h.pt3dadd(-196, -24, -13.5, 1.6, sec = self.dend[47]) h.pt3dadd(-198.5, -31, -13.5, 1.8, sec = self.dend[47]) h.pt3dadd(-199.5, -35.5, -9.5, 1.8, sec = self.dend[47]) h.pt3dadd(-201.5, -38.5, -10, 2.2, sec = self.dend[47]) h.pt3dadd(-201.5, -40.5, -10, 2.9, sec = self.dend[47]) h.pt3dclear(sec = self.dend[48]) h.pt3dadd(-201.5, -40.5, -10, 2.9, sec = self.dend[48]) h.pt3dadd(-205.5, -41.5, -5.5, 0.4, sec = self.dend[48]) h.pt3dadd(-211.5, -41.5, -5.5, 0.5, sec = self.dend[48]) h.pt3dadd(-216, -41.5, -5.5, 0.6, sec = self.dend[48]) h.pt3dadd(-223.5, -45.5, -5.5, 0.6, sec = self.dend[48]) h.pt3dadd(-226.5, -47, -5.5, 0.6, sec = self.dend[48]) h.pt3dadd(-231, -49.5, -5, 0.6, sec = self.dend[48]) h.pt3dadd(-233.5, -51.5, -5, 0.6, sec = self.dend[48]) h.pt3dadd(-236, -52.5, -5, 0.6, sec = self.dend[48]) h.pt3dadd(-238.5, -52.5, -5, 0.6, sec = self.dend[48]) h.pt3dadd(-240.5, -54.5, -5, 0.6, sec = self.dend[48]) h.pt3dadd(-243, -57, -5.5, 0.6, sec = self.dend[48]) h.pt3dadd(-245.5, -57, -5.5, 0.6, sec = self.dend[48]) h.pt3dadd(-247, -58, -5.5, 3.6, sec = self.dend[48]) h.pt3dadd(-251, -58.5, -5.5, 2, sec = self.dend[48]) h.pt3dadd(-254.5, -58.5, -5, 1.2, sec = self.dend[48]) h.pt3dadd(-259, -58.5, -7, 1.2, sec = self.dend[48]) h.pt3dadd(-261, -60, -5.5, 0.7, sec = self.dend[48]) h.pt3dadd(-264.5, -64, -5.5, 0.7, sec = self.dend[48]) h.pt3dadd(-266, -64, -7, 2.5, sec = self.dend[48]) h.pt3dadd(-266.5, -64, -5.5, 4.6, sec = self.dend[48]) h.pt3dadd(-271, -64, -7, 2.1, sec = self.dend[48]) h.pt3dadd(-274.5, -64, -7, 0.9, sec = self.dend[48]) h.pt3dadd(-276.5, -65, -7, 0.7, sec = self.dend[48]) h.pt3dadd(-278, -65, -5.5, 2.5, sec = self.dend[48]) h.pt3dadd(-281, -65, -8, 2.8, sec = self.dend[48]) h.pt3dadd(-283, -66.5, -8, 2.7, sec = self.dend[48]) h.pt3dadd(-286, -66.5, -8, 1.5, sec = self.dend[48]) h.pt3dadd(-288.5, -67, -9, 0.8, sec = self.dend[48]) h.pt3dadd(-290.5, -67.5, -9, 0.8, sec = self.dend[48]) h.pt3dadd(-291.5, -68.5, -8, 1.9, sec = self.dend[48]) h.pt3dadd(-293.5, -70, -9, 1.9, sec = self.dend[48]) h.pt3dadd(-295, -71, -9.5, 0.3, sec = self.dend[48]) h.pt3dadd(-297.5, -71.5, -8, 0.3, sec = self.dend[48]) h.pt3dadd(-301.5, -74.5, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-303, -76, -9, 1.7, sec = self.dend[48]) h.pt3dadd(-305.5, -77.5, -9, 2.4, sec = self.dend[48]) h.pt3dadd(-307.5, -78, -2.5, 3.1, sec = self.dend[48]) h.pt3dadd(-310, -79.5, -2.5, 2.1, sec = self.dend[48]) h.pt3dadd(-311, -80.5, -9, 1.5, sec = self.dend[48]) h.pt3dadd(-312.5, -81, -9, 1.2, sec = self.dend[48]) h.pt3dadd(-315, -82.5, -9, 1.2, sec = self.dend[48]) h.pt3dadd(-317, -83.5, -9, 1.7, sec = self.dend[48]) h.pt3dadd(-319.5, -84.5, -9, 2, sec = self.dend[48]) h.pt3dadd(-322, -86.5, -9, 1.4, sec = self.dend[48]) h.pt3dadd(-323.5, -88, -9, 0.9, sec = self.dend[48]) h.pt3dadd(-325.5, -88.5, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-326, -90, -9, 1.3, sec = self.dend[48]) h.pt3dadd(-328, -92, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-328.5, -93.5, -9, 0.6, sec = self.dend[48]) h.pt3dadd(-330.5, -94, -9, 1.6, sec = self.dend[48]) h.pt3dadd(-332.5, -93.5, -9, 2.4, sec = self.dend[48]) h.pt3dadd(-334.5, -93.5, -9, 3.2, sec = self.dend[48]) h.pt3dadd(-337, -93.5, -9, 2.1, sec = self.dend[48]) h.pt3dadd(-340.5, -93.5, -9, 1.4, sec = self.dend[48]) h.pt3dadd(-342.5, -93.5, -9, 0.9, sec = self.dend[48]) h.pt3dadd(-344.5, -94, -9, 1.5, sec = self.dend[48]) h.pt3dadd(-346.5, -94, -9, 2.5, sec = self.dend[48]) h.pt3dadd(-348, -94.5, -9, 2.4, sec = self.dend[48]) h.pt3dadd(-351, -95, -9, 1.8, sec = self.dend[48]) h.pt3dadd(-352, -96.5, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-353.5, -97, -9, 1.9, sec = self.dend[48]) h.pt3dadd(-355, -97.5, -9, 2.1, sec = self.dend[48]) h.pt3dadd(-355.5, -98.5, -9, 2.8, sec = self.dend[48]) h.pt3dadd(-358.5, -99.5, -9, 1.7, sec = self.dend[48]) h.pt3dadd(-360.5, -99.5, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-362.5, -100.5, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-364.5, -101.5, -9, 1.6, sec = self.dend[48]) h.pt3dadd(-366, -103, -9, 2.5, sec = self.dend[48]) h.pt3dadd(-367.5, -103, -9, 3.1, sec = self.dend[48]) h.pt3dadd(-369.5, -103, -9, 2.4, sec = self.dend[48]) h.pt3dadd(-371.5, -103, -9, 1.5, sec = self.dend[48]) h.pt3dadd(-372, -104, -9, 0.5, sec = self.dend[48]) h.pt3dadd(-374, -105.5, -9, 0.5, sec = self.dend[48]) h.pt3dadd(-375, -105.5, -9, 1, sec = self.dend[48]) h.pt3dadd(-376.5, -107, -9, 1.3, sec = self.dend[48]) h.pt3dadd(-378.5, -108, -9, 0.9, sec = self.dend[48]) h.pt3dadd(-379.5, -110, -9, 1.2, sec = self.dend[48]) h.pt3dadd(-381, -110, -9, 0.9, sec = self.dend[48]) h.pt3dadd(-383, -112.5, -9, 2.5, sec = self.dend[48]) h.pt3dadd(-386, -114, -9, 3.4, sec = self.dend[48]) h.pt3dadd(-388, -116, -9, 2.5, sec = self.dend[48]) h.pt3dadd(-390, -118, -9, 1.6, sec = self.dend[48]) h.pt3dadd(-392, -118.5, -9, 0.1, sec = self.dend[48]) h.pt3dadd(-394, -119.5, -9, 0.1, sec = self.dend[48]) h.pt3dadd(-397.5, -119.5, -9, 0.1, sec = self.dend[48]) h.pt3dadd(-399.5, -121.5, -9, 1.4, sec = self.dend[48]) h.pt3dadd(-400.5, -122.5, -9, 2.5, sec = self.dend[48]) h.pt3dadd(-402.5, -124, -9, 1.3, sec = self.dend[48]) h.pt3dadd(-403.5, -124.5, -9, 0.7, sec = self.dend[48]) h.pt3dadd(-406, -124.5, -9, 0.7, sec = self.dend[48]) h.pt3dadd(-408, -126.5, -9, 1.7, sec = self.dend[48]) h.pt3dadd(-411.5, -127.5, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-413.5, -128.5, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-417, -128.5, -9, 3.3, sec = self.dend[48]) h.pt3dadd(-418.5, -130, -15, 4, sec = self.dend[48]) h.pt3dadd(-422, -130, -9, 2.3, sec = self.dend[48]) h.pt3dadd(-424.5, -130, -15, 0.9, sec = self.dend[48]) h.pt3dadd(-428, -130, -9, 0.9, sec = self.dend[48]) h.pt3dadd(-429.5, -130.5, -9, 1.9, sec = self.dend[48]) h.pt3dadd(-432.5, -130.5, -9, 2.3, sec = self.dend[48]) h.pt3dadd(-435.5, -130.5, -9, 1.2, sec = self.dend[48]) h.pt3dadd(-437.5, -131.5, -15, 0.5, sec = self.dend[48]) h.pt3dadd(-440, -131.5, -15, 0.5, sec = self.dend[48]) h.pt3dadd(-441.5, -132.5, -9, 1.7, sec = self.dend[48]) h.pt3dadd(-442.5, -134, -15, 2.7, sec = self.dend[48]) h.pt3dadd(-444.5, -135.5, -15, 2, sec = self.dend[48]) h.pt3dadd(-445.5, -136, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-447, -138.5, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-448, -138.5, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-449.5, -140.5, -15, 2.4, sec = self.dend[48]) h.pt3dadd(-451.5, -142, -15, 3.3, sec = self.dend[48]) h.pt3dadd(-451, -143.5, -15, 1.6, sec = self.dend[48]) h.pt3dadd(-452, -146, -15, 0.6, sec = self.dend[48]) h.pt3dadd(-451.5, -149, -15, 0.6, sec = self.dend[48]) h.pt3dadd(-451.5, -151.5, -9, 0.6, sec = self.dend[48]) h.pt3dadd(-451.5, -153, -15, 1.7, sec = self.dend[48]) h.pt3dadd(-451.5, -154, -15, 2.2, sec = self.dend[48]) h.pt3dadd(-451.5, -155.5, -15, 2.7, sec = self.dend[48]) h.pt3dadd(-451.5, -157.5, -15, 1.8, sec = self.dend[48]) h.pt3dadd(-452.5, -158.5, -15, 1.1, sec = self.dend[48]) h.pt3dadd(-453, -159.5, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-454, -160.5, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-455, -162.5, -15, 1.9, sec = self.dend[48]) h.pt3dadd(-455.5, -165, -21.5, 3.2, sec = self.dend[48]) h.pt3dadd(-456, -166, -21.5, 1.8, sec = self.dend[48]) h.pt3dadd(-456.5, -167.5, -21.5, 1, sec = self.dend[48]) h.pt3dadd(-457.5, -169, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-457.5, -171, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-458.5, -172.5, -15, 0.7, sec = self.dend[48]) h.pt3dadd(-460, -174, -15, 1.1, sec = self.dend[48]) h.pt3dadd(-461, -175, -15, 1.5, sec = self.dend[48]) h.pt3dadd(-462.5, -175, -15, 1.5, sec = self.dend[48]) h.pt3dadd(-462.5, -176.5, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-464, -180, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-464, -181, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-465.5, -182, -21.5, 3.8, sec = self.dend[48]) h.pt3dadd(-468, -182, -21.5, 2, sec = self.dend[48]) h.pt3dadd(-470, -183.5, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-471.5, -185, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-474, -186, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-476, -188, -21.5, 2.1, sec = self.dend[48]) h.pt3dadd(-476.5, -189, -21.5, 2.9, sec = self.dend[48]) h.pt3dadd(-480, -192.5, -21.5, 0.6, sec = self.dend[48]) h.pt3dadd(-479, -194, -21.5, 0.6, sec = self.dend[48]) h.pt3dadd(-479, -195.5, -21.5, 0.6, sec = self.dend[48]) h.pt3dadd(-479.5, -196.5, -21.5, 2.3, sec = self.dend[48]) h.pt3dadd(-481, -199, -21.5, 2.3, sec = self.dend[48]) h.pt3dadd(-482.5, -199, -21.5, 1.9, sec = self.dend[48]) h.pt3dadd(-483.5, -201, -27.5, 1.2, sec = self.dend[48]) h.pt3dadd(-485, -202, -27.5, 0.1, sec = self.dend[48]) h.pt3dadd(-485.5, -204.5, -21.5, 0.5, sec = self.dend[48]) h.pt3dadd(-489, -202, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-491, -202.5, -21.5, 0.9, sec = self.dend[48]) h.pt3dadd(-492.5, -202.5, -27.5, 1, sec = self.dend[48]) h.pt3dadd(-494.5, -202.5, -21.5, 0.9, sec = self.dend[48]) h.pt3dadd(-496.5, -204, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-497.5, -204, -21.5, 1.3, sec = self.dend[48]) h.pt3dadd(-499.5, -204, -21.5, 1.5, sec = self.dend[48]) h.pt3dadd(-501.5, -204.5, -27.5, 1, sec = self.dend[48]) h.pt3dadd(-503.5, -204.5, -27.5, 0.7, sec = self.dend[48]) h.pt3dadd(-506, -206.5, -21.5, 2.6, sec = self.dend[48]) h.pt3dadd(-507, -206.5, -21.5, 0.7, sec = self.dend[48]) h.pt3dadd(-509.5, -207.5, -27.5, 0.2, sec = self.dend[48]) h.pt3dadd(-511.5, -207.5, -27.5, 0.2, sec = self.dend[48]) h.pt3dadd(-513, -207.5, -21.5, 1.5, sec = self.dend[48]) h.pt3dadd(-514.5, -207.5, -21.5, 1.4, sec = self.dend[48]) h.pt3dadd(-516.5, -207.5, -21.5, 0.5, sec = self.dend[48]) h.pt3dadd(-518.5, -207, -21.5, 0.5, sec = self.dend[48]) h.pt3dadd(-520, -206, -21.5, 1.3, sec = self.dend[48]) h.pt3dadd(-522, -206, -15, 1.6, sec = self.dend[48]) h.pt3dadd(-524.5, -206.5, -15, 0.1, sec = self.dend[48]) h.pt3dadd(-524, -206.5, -21.5, 0.1, sec = self.dend[48]) h.pt3dadd(-526.5, -208, -15, 1, sec = self.dend[48]) h.pt3dadd(-527.5, -208, -15, 1, sec = self.dend[48]) h.pt3dadd(-529, -208.5, -15, 0.3, sec = self.dend[48]) h.pt3dadd(-530.5, -209, -21.5, 1.1, sec = self.dend[48]) h.pt3dadd(-534, -209, -15, 0.1, sec = self.dend[48]) h.pt3dadd(-535.5, -209, -15, 0.1, sec = self.dend[48]) h.pt3dadd(-537, -210, -15, 0.1, sec = self.dend[48]) h.pt3dadd(-538.5, -210, -9, 1.4, sec = self.dend[48]) h.pt3dadd(-540, -211.5, -9, 2.7, sec = self.dend[48]) h.pt3dadd(-541, -212.5, -9, 1.1, sec = self.dend[48]) h.pt3dadd(-541, -214, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-543.5, -214, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-546, -214, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-547, -215.5, -9, 1.3, sec = self.dend[48]) h.pt3dadd(-546.5, -216.5, -2.5, 2.3, sec = self.dend[48]) h.pt3dadd(-546.5, -217.5, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-546.5, -219, -2.5, 0.2, sec = self.dend[48]) h.pt3dadd(-546.5, -220.5, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-546.5, -222, -9, 0.3, sec = self.dend[48]) h.pt3dadd(-546.5, -223, -2.5, 1.2, sec = self.dend[48]) h.pt3dadd(-547, -224.5, -2.5, 1.4, sec = self.dend[48]) h.pt3dadd(-548.5, -226, -2.5, 0.8, sec = self.dend[48]) h.pt3dadd(-549, -226.5, -2.5, 0.6, sec = self.dend[48]) h.pt3dadd(-551.5, -226.5, -2.5, 0.6, sec = self.dend[48]) h.pt3dadd(-552, -227, -2.5, 1.7, sec = self.dend[48]) h.pt3dadd(-554.5, -227.5, -2.5, 2.1, sec = self.dend[48]) h.pt3dadd(-555.5, -229, -2.5, 1.3, sec = self.dend[48]) h.pt3dadd(-557.5, -228.5, -2.5, 0.6, sec = self.dend[48]) h.pt3dadd(-559, -228.5, -2.5, 0.8, sec = self.dend[48]) h.pt3dadd(-562, -228.5, -9, 1.2, sec = self.dend[48]) h.pt3dadd(-566, -228.5, -2.5, 1.1, sec = self.dend[48]) h.pt3dadd(-568.5, -228.5, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-571, -228.5, -2.5, 1.7, sec = self.dend[48]) h.pt3dadd(-575.5, -228.5, -2.5, 0.7, sec = self.dend[48]) h.pt3dadd(-578.5, -230, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-581, -230, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-585, -230.5, -15, 0.9, sec = self.dend[48]) h.pt3dadd(-589, -232, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-592.5, -234, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-595.5, -234, -2.5, 0.9, sec = self.dend[48]) h.pt3dadd(-597.5, -235, -2.5, 1.2, sec = self.dend[48]) h.pt3dadd(-600, -235, -2.5, 1.2, sec = self.dend[48]) h.pt3dadd(-602, -235, -2.5, 0.5, sec = self.dend[48]) h.pt3dadd(-606, -235.5, -2.5, 0.5, sec = self.dend[48]) h.pt3dadd(-606.5, -237, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-608, -238.5, -9, 0.1, sec = self.dend[48]) h.pt3dadd(-609, -239.5, -2.5, 1.3, sec = self.dend[48]) h.pt3dadd(-612, -242, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-612.5, -242, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-614, -243, -2.5, 1.7, sec = self.dend[48]) h.pt3dadd(-616, -243, -2.5, 1.8, sec = self.dend[48]) h.pt3dadd(-620.5, -248, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-622.5, -250, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-624.5, -253, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-624.5, -255.5, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-624.5, -257, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-624.5, -259, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-625, -260.5, -2.5, 1, sec = self.dend[48]) h.pt3dadd(-626.5, -263, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-628, -264, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-630, -264.5, -2.5, 1.4, sec = self.dend[48]) h.pt3dadd(-631, -266, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-633, -267, -2.5, 0.1, sec = self.dend[48]) h.pt3dadd(-636, -268, -2.5, 0.1, sec = self.dend[48]) h.pt3dclear(sec = self.dend[49]) h.pt3dadd(-201.5, -40.5, -10, 2.9, sec = self.dend[49]) h.pt3dadd(-201, -45.5, -10, 0.6, sec = self.dend[49]) h.pt3dadd(-201, -49.5, -11, 0.6, sec = self.dend[49]) h.pt3dadd(-201, -52, -11, 0.6, sec = self.dend[49]) h.pt3dadd(-203, -55, -10, 0.6, sec = self.dend[49]) h.pt3dadd(-204, -57, -10, 0.6, sec = self.dend[49]) h.pt3dadd(-204, -59, -9.5, 1.4, sec = self.dend[49]) h.pt3dadd(-204.5, -61, -9.5, 2, sec = self.dend[49]) h.pt3dadd(-205, -63, -9.5, 2, sec = self.dend[49]) h.pt3dadd(-205.5, -65, -9.5, 0.5, sec = self.dend[49]) h.pt3dadd(-208, -67, -9.5, 0.9, sec = self.dend[49]) h.pt3dadd(-209, -70.5, -9.5, 0.8, sec = self.dend[49]) h.pt3dadd(-210.5, -72, -9.5, 1.1, sec = self.dend[49]) h.pt3dadd(-213, -75, -9.5, 1.3, sec = self.dend[49]) h.pt3dadd(-213.5, -76, -9.5, 1.3, sec = self.dend[49]) h.pt3dadd(-215.5, -78, -9.5, 1.5, sec = self.dend[49]) h.pt3dadd(-216.5, -80, -9.5, 1.6, sec = self.dend[49]) h.pt3dadd(-216.5, -81.5, -9.5, 2.5, sec = self.dend[49]) h.pt3dadd(-218, -82.5, -9.5, 2.3, sec = self.dend[49]) h.pt3dadd(-220, -83.5, -9.5, 1.5, sec = self.dend[49]) h.pt3dadd(-220.5, -85, -9.5, 1.1, sec = self.dend[49]) h.pt3dadd(-223, -89.5, -9.5, 1, sec = self.dend[49]) h.pt3dadd(-223, -91, -9.5, 1, sec = self.dend[49]) h.pt3dadd(-224, -92.5, -9.5, 1.2, sec = self.dend[49]) h.pt3dadd(-224, -95, -11.5, 2.5, sec = self.dend[49]) h.pt3dadd(-226.5, -96.5, -11.5, 1.5, sec = self.dend[49]) h.pt3dadd(-227, -98.5, -11.5, 0.1, sec = self.dend[49]) h.pt3dadd(-229, -99.5, -11.5, 0.1, sec = self.dend[49]) h.pt3dadd(-229.5, -101.5, -11.5, 1.6, sec = self.dend[49]) h.pt3dadd(-232, -102.5, -10, 2.9, sec = self.dend[49]) h.pt3dadd(-235.5, -103.5, -10, 0.7, sec = self.dend[49]) h.pt3dadd(-236.5, -104.5, -10, 0.1, sec = self.dend[49]) h.pt3dadd(-238.5, -106.5, -11, 0.1, sec = self.dend[49]) h.pt3dadd(-241.5, -110, -11.5, 0.1, sec = self.dend[49]) h.pt3dadd(-244, -111.5, -11, 0.1, sec = self.dend[49]) h.pt3dadd(-245.5, -114, -11, 0.1, sec = self.dend[49]) h.pt3dadd(-248, -115, -7.5, 3.1, sec = self.dend[49]) h.pt3dadd(-251, -116.5, -9, 3.1, sec = self.dend[49]) h.pt3dadd(-254.5, -119, -9, 2.5, sec = self.dend[49]) h.pt3dadd(-257, -121, -8, 0.9, sec = self.dend[49]) h.pt3dadd(-259, -124, -8, 0.5, sec = self.dend[49]) h.pt3dadd(-258, -126.5, -9, 2.2, sec = self.dend[49]) h.pt3dadd(-259, -128, -9, 3.8, sec = self.dend[49]) h.pt3dadd(-260, -131.5, -9, 2.4, sec = self.dend[49]) h.pt3dadd(-260, -132, -9, 1.2, sec = self.dend[49]) h.pt3dadd(-261.5, -134.5, -11, 1.3, sec = self.dend[49]) h.pt3dadd(-261.5, -136, -11, 2.6, sec = self.dend[49]) h.pt3dadd(-261.5, -139.5, -10, 3.3, sec = self.dend[49]) h.pt3dadd(-264, -140.5, -11, 0.7, sec = self.dend[49]) h.pt3dadd(-267, -142.5, -11, 0.8, sec = self.dend[49]) h.pt3dadd(-269, -143.5, -12.5, 0.9, sec = self.dend[49]) h.pt3dadd(-270, -146, -13, 0.9, sec = self.dend[49]) h.pt3dadd(-271, -148, -13, 1.4, sec = self.dend[49]) h.pt3dadd(-271.5, -149.5, -13, 1.4, sec = self.dend[49]) h.pt3dadd(-273, -151, -19, 2.4, sec = self.dend[49]) h.pt3dadd(-273.5, -152.5, -19, 2.4, sec = self.dend[49]) h.pt3dadd(-274, -153.5, -19, 1.4, sec = self.dend[49]) h.pt3dadd(-273, -155, -19, 1.4, sec = self.dend[49]) h.pt3dadd(-273, -156.5, -19, 0.9, sec = self.dend[49]) h.pt3dadd(-273.5, -158.5, -19, 1.4, sec = self.dend[49]) h.pt3dadd(-274, -159.5, -19, 1.9, sec = self.dend[49]) h.pt3dadd(-274, -161.5, -19, 2.9, sec = self.dend[49]) h.pt3dadd(-275, -164.5, -19, 3.2, sec = self.dend[49]) h.pt3dadd(-275, -166.5, -19, 3.4, sec = self.dend[49]) h.pt3dadd(-275, -168.5, -19, 2.4, sec = self.dend[49]) h.pt3dadd(-275.5, -169.5, -19, 1.6, sec = self.dend[49]) h.pt3dadd(-274.5, -171, -19, 1.2, sec = self.dend[49]) h.pt3dadd(-275, -172.5, -19, 1, sec = self.dend[49]) h.pt3dadd(-275, -174.5, -19, 1.6, sec = self.dend[49]) h.pt3dadd(-275, -176, -19, 1.6, sec = self.dend[49]) h.pt3dadd(-275, -176.5, -19, 1.1, sec = self.dend[49]) h.pt3dadd(-275, -179, -19, 1.3, sec = self.dend[49]) h.pt3dadd(-274.5, -181, -19, 1.2, sec = self.dend[49]) h.pt3dadd(-274, -182, -19, 1.1, sec = self.dend[49]) h.pt3dadd(-274, -182.5, -19, 2.7, sec = self.dend[49]) h.pt3dadd(-273.5, -186.5, -19, 2.9, sec = self.dend[49]) h.pt3dadd(-274, -187, -25.5, 1.5, sec = self.dend[49]) h.pt3dadd(-274, -188, -25.5, 1.4, sec = self.dend[49]) h.pt3dadd(-274.5, -190.5, -25.5, 1.6, sec = self.dend[49]) h.pt3dadd(-274.5, -191.5, -25.5, 1.1, sec = self.dend[49]) h.pt3dadd(-273.5, -195, -25.5, 1.3, sec = self.dend[49]) h.pt3dadd(-273, -196.5, -25.5, 3.3, sec = self.dend[49]) h.pt3dadd(-273.5, -198.5, -25.5, 3.3, sec = self.dend[49]) h.pt3dadd(-275.5, -199, -25.5, 2, sec = self.dend[49]) h.pt3dadd(-276, -199.5, -25.5, 1.9, sec = self.dend[49]) h.pt3dadd(-278, -200.5, -31.5, 1.9, sec = self.dend[49]) h.pt3dadd(-278, -202, -31.5, 1.6, sec = self.dend[49]) h.pt3dadd(-276.5, -204.5, -38, 1.4, sec = self.dend[49]) h.pt3dadd(-274, -207, -40, 1.9, sec = self.dend[49]) h.pt3dadd(-273.5, -207.5, -40, 1.6, sec = self.dend[49]) h.pt3dadd(-273, -209.5, -38, 1.2, sec = self.dend[49]) h.pt3dadd(-271.5, -209, -40, 0.7, sec = self.dend[49]) h.pt3dadd(-271, -211.5, -42, 1.2, sec = self.dend[49]) h.pt3dadd(-271, -212, -40, 1.6, sec = self.dend[49]) h.pt3dadd(-273, -213, -40, 2.8, sec = self.dend[49]) h.pt3dadd(-273.5, -215.5, -43.5, 1.4, sec = self.dend[49]) h.pt3dadd(-272, -217, -43.5, 0.6, sec = self.dend[49]) h.pt3dadd(-270, -217, -43.5, 0.9, sec = self.dend[49]) h.pt3dadd(-271.5, -219, -43.5, 0.9, sec = self.dend[49]) h.pt3dadd(-272.5, -219.5, -47.5, 1.5, sec = self.dend[49]) h.pt3dadd(-275, -221, -47.5, 1.9, sec = self.dend[49]) h.pt3dadd(-276, -221.5, -51.5, 3.1, sec = self.dend[49]) h.pt3dadd(-278.5, -223.5, -53.5, 1.9, sec = self.dend[49]) h.pt3dadd(-279, -226, -55, 1, sec = self.dend[49]) h.pt3dadd(-281.5, -227.5, -57, 1, sec = self.dend[49]) h.pt3dadd(-281.5, -230, -55, 1, sec = self.dend[49]) h.pt3dadd(-281.5, -232, -55, 1.1, sec = self.dend[49]) h.pt3dadd(-279.5, -232, -55, 2.2, sec = self.dend[49]) h.pt3dadd(-279, -233, -55, 1.7, sec = self.dend[49]) h.pt3dadd(-277, -235.5, -57, 1.1, sec = self.dend[49]) h.pt3dadd(-275, -237, -55, 0.6, sec = self.dend[49]) h.pt3dadd(-273.5, -240, -55, 0.7, sec = self.dend[49]) h.pt3dadd(-272, -243.5, -52, 0.9, sec = self.dend[49]) h.pt3dadd(-272.5, -245, -49, 0.9, sec = self.dend[49]) h.pt3dadd(-272, -246, -49, 0.7, sec = self.dend[49]) h.pt3dadd(-271.5, -247, -49, 0.8, sec = self.dend[49]) h.pt3dadd(-271, -248.5, -49, 1.8, sec = self.dend[49]) h.pt3dadd(-271, -251, -52, 2.8, sec = self.dend[49]) h.pt3dadd(-270.5, -253, -55, 1.4, sec = self.dend[49]) h.pt3dadd(-270.5, -254, -58, 0.6, sec = self.dend[49]) h.pt3dadd(-271.5, -255.5, -58, 0.3, sec = self.dend[49]) h.pt3dadd(-271, -258.5, -58, 0.6, sec = self.dend[49]) h.pt3dadd(-271, -259, -58, 1.8, sec = self.dend[49]) h.pt3dadd(-271, -262, -58, 2.8, sec = self.dend[49]) h.pt3dadd(-270.5, -262.5, -58, 2.3, sec = self.dend[49]) h.pt3dadd(-269.5, -263, -61, 1.1, sec = self.dend[49]) h.pt3dadd(-269, -264.5, -61, 0.9, sec = self.dend[49]) h.pt3dadd(-268, -266.5, -64, 0.7, sec = self.dend[49]) h.pt3dadd(-268, -267.5, -64, 0.4, sec = self.dend[49]) h.pt3dadd(-267, -269, -64, 0.4, sec = self.dend[49]) h.pt3dadd(-267, -270.5, -64, 0.4, sec = self.dend[49]) h.pt3dadd(-267, -272.5, -64, 0.4, sec = self.dend[49]) h.pt3dadd(-266.5, -272.5, -61, 0.9, sec = self.dend[49]) h.pt3dadd(-266.5, -273.5, -61, 0.9, sec = self.dend[49]) h.pt3dadd(-266, -275, -70, 0.3, sec = self.dend[49]) h.pt3dadd(-264.5, -276.5, -67, 1.9, sec = self.dend[49]) h.pt3dadd(-264, -278.5, -67, 3.6, sec = self.dend[49]) h.pt3dadd(-264, -282, -67, 1.2, sec = self.dend[49]) h.pt3dadd(-264.5, -283.5, -67, 0.9, sec = self.dend[49]) h.pt3dadd(-265.5, -285.5, -67, 0.9, sec = self.dend[49]) h.pt3dadd(-265.5, -286, -67, 0.9, sec = self.dend[49]) h.pt3dadd(-265.5, -287.5, -67, 2, sec = self.dend[49]) h.pt3dadd(-265, -288.5, -64, 2.6, sec = self.dend[49]) h.pt3dadd(-264, -290.5, -67, 1.1, sec = self.dend[49]) h.pt3dadd(-262.5, -292, -67, 1.1, sec = self.dend[49]) h.pt3dadd(-262, -292.5, -70, 0.5, sec = self.dend[49]) h.pt3dadd(-261, -293, -70, 0.5, sec = self.dend[49]) h.pt3dadd(-260, -294.5, -70, 0.5, sec = self.dend[49]) h.pt3dadd(-259, -295, -70, 1, sec = self.dend[49]) h.pt3dadd(-257, -295.5, -70, 0.9, sec = self.dend[49]) h.pt3dadd(-254.5, -296, -70, 0.6, sec = self.dend[49]) h.pt3dadd(-254.5, -297.5, -70, 0.1, sec = self.dend[49]) h.pt3dadd(-253, -299, -70, 0.1, sec = self.dend[49]) h.pt3dadd(-253, -301, -70, 0.1, sec = self.dend[49]) h.pt3dadd(-254, -301.5, -75, 0.1, sec = self.dend[49]) h.pt3dadd(-254, -303.5, -75, 0.1, sec = self.dend[49]) h.pt3dadd(-253.5, -304.5, -75, 0.5, sec = self.dend[49]) h.pt3dadd(-252.5, -305.5, -77, 2.2, sec = self.dend[49]) h.pt3dadd(-252.5, -308, -77, 1.1, sec = self.dend[49]) h.pt3dadd(-253.5, -309, -79.5, 1.5, sec = self.dend[49]) h.pt3dadd(-254.5, -312, -84.5, 0.7, sec = self.dend[49]) h.pt3dadd(-255.5, -312.5, -82, 1.4, sec = self.dend[49]) h.pt3dadd(-255.5, -313.5, -84.5, 2.4, sec = self.dend[49]) h.pt3dadd(-256.5, -315.5, -82, 0.5, sec = self.dend[49]) h.pt3dadd(-256.5, -317, -89, 0.5, sec = self.dend[49]) h.pt3dadd(-256.5, -319, -86.5, 1.4, sec = self.dend[49]) h.pt3dadd(-256.5, -320.5, -89, 2.1, sec = self.dend[49]) h.pt3dadd(-255.5, -321.5, -89, 1.1, sec = self.dend[49]) h.pt3dadd(-253.5, -323.5, -86.5, 0.1, sec = self.dend[49]) h.pt3dclear(sec = self.dend[50]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[50]) h.pt3dadd(76, 59, -6.5, 10.6, sec = self.dend[50]) h.pt3dadd(80.5, 63.5, -10, 10.1, sec = self.dend[50]) h.pt3dadd(86.5, 67, -9.5, 10.1, sec = self.dend[50]) h.pt3dadd(91, 69, -8.5, 9.6, sec = self.dend[50]) h.pt3dadd(93, 72, -8.5, 9.5, sec = self.dend[50]) h.pt3dadd(98, 74, -8.5, 9.5, sec = self.dend[50]) h.pt3dadd(104, 75.5, -8.5, 9.4, sec = self.dend[50]) h.pt3dadd(110.5, 78.5, -8.5, 8.6, sec = self.dend[50]) h.pt3dadd(117, 79, -8.5, 8, sec = self.dend[50]) h.pt3dadd(123.5, 82, -8.5, 8, sec = self.dend[50]) h.pt3dadd(129, 82.5, -8.5, 8, sec = self.dend[50]) h.pt3dadd(135, 84, -8.5, 8, sec = self.dend[50]) h.pt3dadd(141, 85.5, -8.5, 7.1, sec = self.dend[50]) h.pt3dadd(148, 88, -8.5, 6.8, sec = self.dend[50]) h.pt3dadd(152.5, 90, -14, 6.7, sec = self.dend[50]) h.pt3dadd(157, 92, -16.5, 7, sec = self.dend[50]) h.pt3dadd(160.5, 93.5, -15, 7.3, sec = self.dend[50]) h.pt3dadd(163.5, 96, -15, 7.2, sec = self.dend[50]) h.pt3dadd(166.5, 97.5, -15, 7.2, sec = self.dend[50]) h.pt3dadd(170, 99.5, -17.5, 7.2, sec = self.dend[50]) h.pt3dadd(173, 100.5, -17.5, 7.2, sec = self.dend[50]) h.pt3dadd(175.5, 103, -17.5, 7.2, sec = self.dend[50]) h.pt3dadd(178.5, 104, -17.5, 6.3, sec = self.dend[50]) h.pt3dadd(180, 106.5, -17.5, 5.9, sec = self.dend[50]) h.pt3dadd(184, 107, -17.5, 5.6, sec = self.dend[50]) h.pt3dadd(186, 107.5, -17.5, 4.9, sec = self.dend[50]) h.pt3dadd(188.5, 109, -17.5, 5.3, sec = self.dend[50]) h.pt3dadd(192.5, 110.5, -17.5, 7.3, sec = self.dend[50]) h.pt3dadd(196, 113, -18.5, 7.7, sec = self.dend[50]) h.pt3dadd(198, 114, -18.5, 8, sec = self.dend[50]) h.pt3dadd(201, 114.5, -18.5, 8.1, sec = self.dend[50]) h.pt3dadd(206, 117.5, -21, 8.3, sec = self.dend[50]) h.pt3dadd(211.5, 121.5, -21, 9, sec = self.dend[50]) h.pt3dadd(214, 123.5, -22, 7.2, sec = self.dend[50]) h.pt3dadd(216, 125, -21, 6.7, sec = self.dend[50]) h.pt3dadd(218.5, 127.5, -21, 5.7, sec = self.dend[50]) h.pt3dadd(221.5, 130, -20, 6, sec = self.dend[50]) h.pt3dadd(224.5, 133, -23, 6, sec = self.dend[50]) h.pt3dadd(227, 134.5, -24.5, 6.3, sec = self.dend[50]) h.pt3dadd(230, 136, -24.5, 7.3, sec = self.dend[50]) h.pt3dadd(237, 139, -23, 8.8, sec = self.dend[50]) h.pt3dadd(238.5, 139.5, -23, 9, sec = self.dend[50]) h.pt3dadd(241, 140.5, -23, 9.4, sec = self.dend[50]) h.pt3dadd(245, 141.5, -23, 9.7, sec = self.dend[50]) h.pt3dadd(251, 142, -24.5, 4.6, sec = self.dend[50]) h.pt3dadd(254, 143, -24.5, 4.9, sec = self.dend[50]) h.pt3dadd(255.5, 145.5, -25.5, 7.2, sec = self.dend[50]) h.pt3dadd(260, 145.5, -25.5, 6.7, sec = self.dend[50]) h.pt3dadd(262.5, 146.5, -25.5, 5.6, sec = self.dend[50]) h.pt3dadd(265.5, 146.5, -25.5, 6, sec = self.dend[50]) h.pt3dadd(269, 146.5, -25.5, 6.3, sec = self.dend[50]) h.pt3dadd(268.5, 144.5, -27, 6.3, sec = self.dend[50]) h.pt3dadd(271, 144, -27.5, 4.7, sec = self.dend[50]) h.pt3dadd(274, 144, -27.5, 5.2, sec = self.dend[50]) h.pt3dadd(273.5, 146, -25.5, 7.3, sec = self.dend[50]) h.pt3dadd(276.5, 147, -26.5, 7.3, sec = self.dend[50]) h.pt3dadd(279.5, 148, -27, 7.3, sec = self.dend[50]) h.pt3dadd(282.5, 148, -27, 7.3, sec = self.dend[50]) h.pt3dadd(285, 148.5, -27, 7.1, sec = self.dend[50]) h.pt3dadd(287.5, 151, -29, 6.6, sec = self.dend[50]) h.pt3dadd(289, 151, -29, 6.6, sec = self.dend[50]) h.pt3dadd(292, 152.5, -28.5, 6.6, sec = self.dend[50]) h.pt3dadd(292, 155, -27.5, 7.1, sec = self.dend[50]) h.pt3dadd(297, 159.5, -27.5, 6.7, sec = self.dend[50]) h.pt3dadd(299, 160.5, -27.5, 7.8, sec = self.dend[50]) h.pt3dadd(300, 162, -27.5, 8.4, sec = self.dend[50]) h.pt3dadd(304.5, 163.5, -33.5, 9.9, sec = self.dend[50]) h.pt3dadd(305.5, 165, -33.5, 11.2, sec = self.dend[50]) h.pt3dclear(sec = self.dend[51]) h.pt3dadd(305.5, 165, -33.5, 11.2, sec = self.dend[51]) h.pt3dadd(309.5, 169.5, -27.5, 7.9, sec = self.dend[51]) h.pt3dadd(311, 172, -33.5, 7.1, sec = self.dend[51]) h.pt3dadd(311.5, 173.5, -33.5, 6.1, sec = self.dend[51]) h.pt3dadd(312.5, 173.5, -33.5, 5.7, sec = self.dend[51]) h.pt3dadd(314.5, 175, -33.5, 4.6, sec = self.dend[51]) h.pt3dadd(316.5, 178, -33.5, 4.3, sec = self.dend[51]) h.pt3dadd(319, 180, -33.5, 4.3, sec = self.dend[51]) h.pt3dadd(321, 183.5, -40, 4.7, sec = self.dend[51]) h.pt3dadd(324, 187.5, -40, 4.7, sec = self.dend[51]) h.pt3dadd(324.5, 188, -40, 4.7, sec = self.dend[51]) h.pt3dadd(326, 191.5, -40, 4.7, sec = self.dend[51]) h.pt3dadd(327.5, 193.5, -46, 3.7, sec = self.dend[51]) h.pt3dadd(328.5, 194, -46, 3.5, sec = self.dend[51]) h.pt3dadd(330.5, 195.5, -46, 4.7, sec = self.dend[51]) h.pt3dadd(332, 196, -46, 5.3, sec = self.dend[51]) h.pt3dadd(334, 198.5, -46, 4.3, sec = self.dend[51]) h.pt3dadd(335.5, 200, -46, 3.6, sec = self.dend[51]) h.pt3dadd(337.5, 201.5, -46, 4.4, sec = self.dend[51]) h.pt3dadd(339, 201.5, -46, 4, sec = self.dend[51]) h.pt3dadd(341, 202.5, -46, 5, sec = self.dend[51]) h.pt3dadd(342.5, 204, -46, 5.2, sec = self.dend[51]) h.pt3dadd(345.5, 204.5, -46, 4.6, sec = self.dend[51]) h.pt3dadd(346.5, 205.5, -46, 4.8, sec = self.dend[51]) h.pt3dadd(350, 207.5, -52.5, 5.3, sec = self.dend[51]) h.pt3dadd(353, 208.5, -52.5, 5.2, sec = self.dend[51]) h.pt3dadd(355.5, 209.5, -52.5, 4.7, sec = self.dend[51]) h.pt3dadd(357.5, 211.5, -52.5, 5.7, sec = self.dend[51]) h.pt3dadd(359.5, 212.5, -52.5, 5.5, sec = self.dend[51]) h.pt3dadd(362.5, 212.5, -52.5, 5.5, sec = self.dend[51]) h.pt3dadd(364, 214.5, -52.5, 5.5, sec = self.dend[51]) h.pt3dadd(366.5, 214.5, -52.5, 4.7, sec = self.dend[51]) h.pt3dadd(369, 216, -52.5, 4.6, sec = self.dend[51]) h.pt3dadd(371.5, 216, -52.5, 5.3, sec = self.dend[51]) h.pt3dadd(372.5, 216, -52.5, 6.2, sec = self.dend[51]) h.pt3dadd(375.5, 217, -52.5, 6, sec = self.dend[51]) h.pt3dadd(378, 218, -52.5, 5, sec = self.dend[51]) h.pt3dadd(381.5, 219.5, -52.5, 5, sec = self.dend[51]) h.pt3dadd(385, 221, -52.5, 5, sec = self.dend[51]) h.pt3dadd(388, 222.5, -52.5, 5, sec = self.dend[51]) h.pt3dadd(389.5, 223, -52.5, 5.2, sec = self.dend[51]) h.pt3dadd(392, 223, -52.5, 5.3, sec = self.dend[51]) h.pt3dadd(395, 223.5, -52.5, 6, sec = self.dend[51]) h.pt3dadd(398.5, 223.5, -58.5, 6.3, sec = self.dend[51]) h.pt3dadd(403.5, 227.5, -58.5, 4, sec = self.dend[51]) h.pt3dadd(407, 229, -58.5, 4, sec = self.dend[51]) h.pt3dadd(409.5, 229.5, -58.5, 4, sec = self.dend[51]) h.pt3dadd(415, 230.5, -58.5, 4, sec = self.dend[51]) h.pt3dadd(420, 232, -60.5, 4, sec = self.dend[51]) h.pt3dadd(421.5, 233, -58.5, 3.6, sec = self.dend[51]) h.pt3dadd(425.5, 233, -60.5, 2.9, sec = self.dend[51]) h.pt3dadd(430.5, 236, -62.5, 2.9, sec = self.dend[51]) h.pt3dadd(433.5, 237, -62.5, 2.9, sec = self.dend[51]) h.pt3dadd(437, 239, -62.5, 2.9, sec = self.dend[51]) h.pt3dadd(443, 242, -68, 3.3, sec = self.dend[51]) h.pt3dadd(444, 243, -56.5, 3.1, sec = self.dend[51]) h.pt3dadd(446.5, 243.5, -54.5, 3.9, sec = self.dend[51]) h.pt3dadd(450.5, 246.5, -56.5, 2.7, sec = self.dend[51]) h.pt3dadd(453, 247, -56.5, 2.3, sec = self.dend[51]) h.pt3dadd(457, 247, -56.5, 2.7, sec = self.dend[51]) h.pt3dadd(460, 249, -56.5, 2.4, sec = self.dend[51]) h.pt3dadd(463.5, 249, -56.5, 2.2, sec = self.dend[51]) h.pt3dadd(466, 251, -58.5, 2, sec = self.dend[51]) h.pt3dadd(469, 252, -58.5, 2, sec = self.dend[51]) h.pt3dadd(471.5, 253.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(476, 255.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(479.5, 256, -58.5, 2, sec = self.dend[51]) h.pt3dadd(482.5, 257.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(486.5, 260.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(488, 262.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(491, 264, -58.5, 2, sec = self.dend[51]) h.pt3dadd(492, 265.5, -58.5, 2, sec = self.dend[51]) h.pt3dadd(496, 265.5, -58.5, 3.7, sec = self.dend[51]) h.pt3dclear(sec = self.dend[52]) h.pt3dadd(496, 265.5, -58.5, 3.7, sec = self.dend[52]) h.pt3dadd(500.5, 263.5, -50.5, 0.5, sec = self.dend[52]) h.pt3dadd(505, 263.5, -50.5, 0.5, sec = self.dend[52]) h.pt3dadd(510, 262, -50.5, 0.5, sec = self.dend[52]) h.pt3dadd(515, 259.5, -50.5, 0.5, sec = self.dend[52]) h.pt3dadd(523, 257.5, -50.5, 0.5, sec = self.dend[52]) h.pt3dadd(531.5, 257.5, -54.5, 0.5, sec = self.dend[52]) h.pt3dadd(539.5, 257.5, -54.5, 0.5, sec = self.dend[52]) h.pt3dadd(547, 257.5, -56.5, 0.5, sec = self.dend[52]) h.pt3dadd(550.5, 257.5, -56.5, 0.5, sec = self.dend[52]) h.pt3dadd(554, 257.5, -56.5, 0.5, sec = self.dend[52]) h.pt3dadd(559.5, 257.5, -56.5, 0.5, sec = self.dend[52]) h.pt3dadd(566, 257.5, -56.5, 0.5, sec = self.dend[52]) h.pt3dadd(570, 255.5, -54.5, 0.5, sec = self.dend[52]) h.pt3dadd(574.5, 255.5, -54.5, 0.5, sec = self.dend[52]) h.pt3dadd(577.5, 254.5, -58.5, 0.6, sec = self.dend[52]) h.pt3dadd(581.5, 252, -54.5, 0.6, sec = self.dend[52]) h.pt3dadd(584, 252, -54.5, 0.6, sec = self.dend[52]) h.pt3dadd(584.5, 250.5, -54.5, 1.2, sec = self.dend[52]) h.pt3dadd(585.5, 249.5, -54.5, 1.7, sec = self.dend[52]) h.pt3dadd(588, 249, -54.5, 1.2, sec = self.dend[52]) h.pt3dadd(590.5, 249, -58.5, 0.4, sec = self.dend[52]) h.pt3dadd(593, 248, -58.5, 0.4, sec = self.dend[52]) h.pt3dadd(595, 248, -62.5, 0.4, sec = self.dend[52]) h.pt3dadd(598, 248, -62.5, 1.3, sec = self.dend[52]) h.pt3dadd(599.5, 248, -62.5, 1.8, sec = self.dend[52]) h.pt3dadd(601, 248, -62.5, 0.3, sec = self.dend[52]) h.pt3dadd(603.5, 248, -62.5, 0.3, sec = self.dend[52]) h.pt3dadd(607.5, 247.5, -62.5, 1.4, sec = self.dend[52]) h.pt3dadd(611, 247.5, -62.5, 0.3, sec = self.dend[52]) h.pt3dadd(617.5, 247.5, -62.5, 0.3, sec = self.dend[52]) h.pt3dadd(623.5, 247.5, -60.5, 0.3, sec = self.dend[52]) h.pt3dadd(623.5, 248, -60.5, 0.3, sec = self.dend[52]) h.pt3dadd(628.5, 250, -60.5, 0.3, sec = self.dend[52]) h.pt3dadd(630.5, 250, -63.5, 0.8, sec = self.dend[52]) h.pt3dadd(631.5, 250, -57.5, 1.3, sec = self.dend[52]) h.pt3dadd(632.5, 249, -66.5, 0.3, sec = self.dend[52]) h.pt3dadd(635.5, 248.5, -60.5, 0.1, sec = self.dend[52]) h.pt3dadd(636, 248.5, -63.5, 0.1, sec = self.dend[52]) h.pt3dadd(638, 247, -69.5, 1.1, sec = self.dend[52]) h.pt3dadd(639, 247, -69.5, 1.5, sec = self.dend[52]) h.pt3dadd(642, 245.5, -72.5, 1.3, sec = self.dend[52]) h.pt3dadd(645.5, 245, -66.5, 0.1, sec = self.dend[52]) h.pt3dadd(651.5, 245, -69.5, 0.1, sec = self.dend[52]) h.pt3dadd(654, 245, -69.5, 0.1, sec = self.dend[52]) h.pt3dadd(656.5, 245, -66.5, 1, sec = self.dend[52]) h.pt3dadd(658, 245, -66.5, 0.7, sec = self.dend[52]) h.pt3dadd(660, 245, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(663, 245, -69.5, 0.1, sec = self.dend[52]) h.pt3dadd(664.5, 246.5, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(666.5, 247, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(668.5, 246, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(670, 246.5, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(671.5, 246.5, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(675, 246.5, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(677, 246.5, -72.5, 1.2, sec = self.dend[52]) h.pt3dadd(679, 245.5, -75.5, 0.1, sec = self.dend[52]) h.pt3dadd(682, 245.5, -75.5, 0.1, sec = self.dend[52]) h.pt3dadd(683, 245.5, -69.5, 1, sec = self.dend[52]) h.pt3dadd(685, 244.5, -75.5, 0.1, sec = self.dend[52]) h.pt3dadd(686.5, 244.5, -75.5, 0.1, sec = self.dend[52]) h.pt3dadd(687, 244.5, -75.5, 0.9, sec = self.dend[52]) h.pt3dadd(687.5, 244, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(691, 244, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(692.5, 244, -69.5, 1.1, sec = self.dend[52]) h.pt3dadd(693, 246.5, -69.5, 0.1, sec = self.dend[52]) h.pt3dadd(696, 246.5, -69.5, 0.1, sec = self.dend[52]) h.pt3dadd(697.5, 246.5, -69.5, 0.9, sec = self.dend[52]) h.pt3dadd(698.5, 246.5, -72.5, 0.1, sec = self.dend[52]) h.pt3dadd(700.5, 248, -78, 0.1, sec = self.dend[52]) h.pt3dadd(703.5, 246, -78, 0.1, sec = self.dend[52]) h.pt3dadd(705.5, 246, -81, 1.5, sec = self.dend[52]) h.pt3dadd(710, 247, -78, 0.1, sec = self.dend[52]) h.pt3dadd(715, 247, -81, 0.1, sec = self.dend[52]) h.pt3dadd(718.5, 248, -81, 0.1, sec = self.dend[52]) h.pt3dadd(720.5, 248, -84, 0.1, sec = self.dend[52]) h.pt3dadd(723, 249.5, -84, 1.6, sec = self.dend[52]) h.pt3dadd(726.5, 251.5, -81, 0.1, sec = self.dend[52]) h.pt3dadd(729, 252.5, -84, 0.1, sec = self.dend[52]) h.pt3dadd(731, 253, -81, 1.6, sec = self.dend[52]) h.pt3dadd(736.5, 253, -84, 0.1, sec = self.dend[52]) h.pt3dadd(739.5, 251.5, -90, 0.1, sec = self.dend[52]) h.pt3dclear(sec = self.dend[53]) h.pt3dadd(496, 265.5, -58.5, 3.7, sec = self.dend[53]) h.pt3dadd(498.5, 269, -58.5, 2.4, sec = self.dend[53]) h.pt3dadd(503, 269.5, -58.5, 2.1, sec = self.dend[53]) h.pt3dadd(505.5, 271, -58.5, 2, sec = self.dend[53]) h.pt3dadd(508, 273, -58.5, 2, sec = self.dend[53]) h.pt3dadd(513, 275, -58.5, 3.7, sec = self.dend[53]) h.pt3dclear(sec = self.dend[54]) h.pt3dadd(513, 275, -58.5, 3.7, sec = self.dend[54]) h.pt3dadd(521, 276.5, -52.5, 1.3, sec = self.dend[54]) h.pt3dadd(526.5, 278.5, -52.5, 1.3, sec = self.dend[54]) h.pt3dadd(535, 282, -56.5, 1.3, sec = self.dend[54]) h.pt3dadd(539, 285, -56.5, 1.3, sec = self.dend[54]) h.pt3dadd(543, 288, -56.5, 1.3, sec = self.dend[54]) h.pt3dadd(547, 290, -58.5, 1.3, sec = self.dend[54]) h.pt3dadd(553.5, 290.5, -60.5, 1, sec = self.dend[54]) h.pt3dadd(554.5, 293, -60.5, 1, sec = self.dend[54]) h.pt3dadd(558.5, 296.5, -60.5, 1.6, sec = self.dend[54]) h.pt3dadd(561.5, 299, -60.5, 1.6, sec = self.dend[54]) h.pt3dadd(568.5, 302.5, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(571, 305, -60.5, 1.4, sec = self.dend[54]) h.pt3dadd(574.5, 307.5, -60.5, 1.4, sec = self.dend[54]) h.pt3dadd(580.5, 312, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(583.5, 314.5, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(588, 317, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(591, 318, -60.5, 1.5, sec = self.dend[54]) h.pt3dadd(593, 320.5, -60.5, 1.5, sec = self.dend[54]) h.pt3dadd(598.5, 323, -64, 1.5, sec = self.dend[54]) h.pt3dadd(600, 326.5, -66, 1.5, sec = self.dend[54]) h.pt3dadd(603, 329.5, -66, 1.3, sec = self.dend[54]) h.pt3dadd(603, 331.5, -66, 1.3, sec = self.dend[54]) h.pt3dadd(604.5, 333.5, -68, 1, sec = self.dend[54]) h.pt3dadd(604.5, 333.5, -60.5, 1.2, sec = self.dend[54]) h.pt3dadd(605, 339, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(607, 342, -60.5, 1.3, sec = self.dend[54]) h.pt3dadd(609.5, 344, -64, 1.3, sec = self.dend[54]) h.pt3dadd(610.5, 347, -58, 0.8, sec = self.dend[54]) h.pt3dadd(612.5, 348, -58, 1, sec = self.dend[54]) h.pt3dadd(615.5, 351, -61, 1.1, sec = self.dend[54]) h.pt3dadd(617.5, 353, -61, 1.2, sec = self.dend[54]) h.pt3dadd(618.5, 355, -61, 1.4, sec = self.dend[54]) h.pt3dadd(620.5, 358, -61, 2.6, sec = self.dend[54]) h.pt3dadd(623.5, 359, -58, 2.8, sec = self.dend[54]) h.pt3dadd(625.5, 360.5, -58, 2.1, sec = self.dend[54]) h.pt3dadd(627.5, 361, -58, 1.6, sec = self.dend[54]) h.pt3dadd(629.5, 362, -55, 1.2, sec = self.dend[54]) h.pt3dadd(633.5, 362.5, -64, 2, sec = self.dend[54]) h.pt3dadd(633.5, 365.5, -58, 2.2, sec = self.dend[54]) h.pt3dadd(636.5, 368, -64, 2.2, sec = self.dend[54]) h.pt3dadd(639, 370.5, -61, 1.4, sec = self.dend[54]) h.pt3dadd(642.5, 372.5, -61, 1.5, sec = self.dend[54]) h.pt3dadd(646, 374.5, -61, 2.2, sec = self.dend[54]) h.pt3dadd(648.5, 377, -58, 2.9, sec = self.dend[54]) h.pt3dadd(649.5, 376.5, -58, 2.9, sec = self.dend[54]) h.pt3dadd(651, 378, -64, 2.8, sec = self.dend[54]) h.pt3dadd(653, 380, -64, 2.8, sec = self.dend[54]) h.pt3dadd(653.5, 382.5, -61, 4, sec = self.dend[54]) h.pt3dclear(sec = self.dend[55]) h.pt3dadd(653.5, 382.5, -61, 4, sec = self.dend[55]) h.pt3dadd(657.5, 381.5, -67, 0.9, sec = self.dend[55]) h.pt3dadd(660.5, 381.5, -70, 0.9, sec = self.dend[55]) h.pt3dadd(662.5, 381.5, -67, 0.9, sec = self.dend[55]) h.pt3dadd(665.5, 383, -70, 0.9, sec = self.dend[55]) h.pt3dadd(669, 383, -67, 0.9, sec = self.dend[55]) h.pt3dadd(671, 385, -70, 1.8, sec = self.dend[55]) h.pt3dadd(673, 385, -70, 1.6, sec = self.dend[55]) h.pt3dadd(674, 384, -70, 1.6, sec = self.dend[55]) h.pt3dadd(677, 384.5, -75.5, 1.1, sec = self.dend[55]) h.pt3dadd(677.5, 384.5, -73, 0.6, sec = self.dend[55]) h.pt3dadd(679, 384.5, -73, 0.6, sec = self.dend[55]) h.pt3dadd(681.5, 384.5, -73, 2, sec = self.dend[55]) h.pt3dadd(686, 384.5, -73, 0.7, sec = self.dend[55]) h.pt3dadd(692, 385.5, -73, 0.7, sec = self.dend[55]) h.pt3dadd(694.5, 387.5, -73, 1.6, sec = self.dend[55]) h.pt3dadd(697, 387, -78.5, 0.9, sec = self.dend[55]) h.pt3dadd(699.5, 386.5, -78.5, 0.9, sec = self.dend[55]) h.pt3dadd(701.5, 385, -78.5, 0.9, sec = self.dend[55]) h.pt3dadd(703.5, 385, -81.5, 1.2, sec = self.dend[55]) h.pt3dadd(706, 385.5, -81.5, 1, sec = self.dend[55]) h.pt3dadd(706, 388.5, -78.5, 0.6, sec = self.dend[55]) h.pt3dadd(708.5, 388.5, -81.5, 1.4, sec = self.dend[55]) h.pt3dadd(711.5, 388, -87.5, 1.5, sec = self.dend[55]) h.pt3dadd(715.5, 390.5, -90.5, 1.5, sec = self.dend[55]) h.pt3dadd(717, 390, -99.5, 1.5, sec = self.dend[55]) h.pt3dadd(720.5, 390.5, -90.5, 0.6, sec = self.dend[55]) h.pt3dadd(721, 387.5, -90.5, 0.7, sec = self.dend[55]) h.pt3dadd(722, 386.5, -97.5, 0.9, sec = self.dend[55]) h.pt3dadd(723.5, 384, -92.5, 1.4, sec = self.dend[55]) h.pt3dadd(725, 384, -100, 0.7, sec = self.dend[55]) h.pt3dadd(727, 383.5, -100, 0.7, sec = self.dend[55]) h.pt3dadd(728, 382.5, -97.5, 0.7, sec = self.dend[55]) h.pt3dadd(728.5, 379, -100, 1.1, sec = self.dend[55]) h.pt3dadd(730, 379, -102, 1.1, sec = self.dend[55]) h.pt3dadd(731.5, 381.5, -102, 1.3, sec = self.dend[55]) h.pt3dadd(733.5, 381.5, -100, 0.8, sec = self.dend[55]) h.pt3dadd(735, 381.5, -100, 0.8, sec = self.dend[55]) h.pt3dadd(735, 380, -104.5, 0.8, sec = self.dend[55]) h.pt3dadd(737.5, 380, -104.5, 0.7, sec = self.dend[55]) h.pt3dadd(736.5, 381.5, -107, 0.7, sec = self.dend[55]) h.pt3dadd(738, 382, -109.5, 0.7, sec = self.dend[55]) h.pt3dadd(740.5, 381.5, -107, 0.9, sec = self.dend[55]) h.pt3dadd(741.5, 381.5, -107, 0.9, sec = self.dend[55]) h.pt3dadd(742.5, 380, -104.5, 0.8, sec = self.dend[55]) h.pt3dadd(744.5, 379.5, -104.5, 0.8, sec = self.dend[55]) h.pt3dadd(747.5, 379.5, -104.5, 0.8, sec = self.dend[55]) h.pt3dadd(747.5, 376.5, -109.5, 0.7, sec = self.dend[55]) h.pt3dadd(750.5, 376.5, -109.5, 0.7, sec = self.dend[55]) h.pt3dadd(752.5, 376.5, -109.5, 1.8, sec = self.dend[55]) h.pt3dadd(754, 375.5, -109.5, 0.9, sec = self.dend[55]) h.pt3dadd(756, 376, -111.5, 0.9, sec = self.dend[55]) h.pt3dadd(757, 376, -114, 0.7, sec = self.dend[55]) h.pt3dadd(759, 376, -119, 0.7, sec = self.dend[55]) h.pt3dadd(760.5, 377, -111.5, 0.9, sec = self.dend[55]) h.pt3dadd(762, 377.5, -114, 1.7, sec = self.dend[55]) h.pt3dadd(765, 377.5, -114, 1.8, sec = self.dend[55]) h.pt3dadd(766, 377.5, -114, 1.5, sec = self.dend[55]) h.pt3dadd(768.5, 375.5, -119, 0.4, sec = self.dend[55]) h.pt3dadd(769, 377, -119, 0.4, sec = self.dend[55]) h.pt3dadd(770, 378, -119, 1.8, sec = self.dend[55]) h.pt3dadd(772, 377.5, -114, 1.5, sec = self.dend[55]) h.pt3dadd(773.5, 377.5, -119, 1.5, sec = self.dend[55]) h.pt3dadd(775.5, 377.5, -121, 1.6, sec = self.dend[55]) h.pt3dadd(777, 378, -114, 1.3, sec = self.dend[55]) h.pt3dadd(778.5, 379, -116.5, 1, sec = self.dend[55]) h.pt3dadd(781.5, 379, -116.5, 1.2, sec = self.dend[55]) h.pt3dadd(782.5, 380.5, -116.5, 1.2, sec = self.dend[55]) h.pt3dadd(784.5, 383.5, -116.5, 1.1, sec = self.dend[55]) h.pt3dadd(785.5, 385, -114, 1.1, sec = self.dend[55]) h.pt3dadd(786.5, 386, -114, 1.1, sec = self.dend[55]) h.pt3dadd(787, 388, -119, 0.9, sec = self.dend[55]) h.pt3dadd(787.5, 388, -114, 1.4, sec = self.dend[55]) h.pt3dadd(790, 387, -119, 1.4, sec = self.dend[55]) h.pt3dadd(791.5, 387.5, -121, 1.3, sec = self.dend[55]) h.pt3dadd(791.5, 391, -116.5, 0.7, sec = self.dend[55]) h.pt3dadd(794.5, 390.5, -116.5, 0.8, sec = self.dend[55]) h.pt3dadd(795, 392, -119, 1, sec = self.dend[55]) h.pt3dadd(796, 393.5, -119, 1, sec = self.dend[55]) h.pt3dadd(798.5, 393.5, -119, 1.2, sec = self.dend[55]) h.pt3dadd(799.5, 393.5, -114, 1.4, sec = self.dend[55]) h.pt3dadd(801, 393.5, -114, 1.5, sec = self.dend[55]) h.pt3dadd(802.5, 394, -116.5, 1, sec = self.dend[55]) h.pt3dadd(804, 397, -116.5, 0.6, sec = self.dend[55]) h.pt3dadd(805.5, 397, -116.5, 0.9, sec = self.dend[55]) h.pt3dadd(806, 397, -116.5, 1.2, sec = self.dend[55]) h.pt3dadd(808, 397.5, -116.5, 1.4, sec = self.dend[55]) h.pt3dadd(809, 397.5, -116.5, 1.4, sec = self.dend[55]) h.pt3dadd(810.5, 397.5, -116.5, 1.4, sec = self.dend[55]) h.pt3dadd(811.5, 397.5, -121, 1.1, sec = self.dend[55]) h.pt3dadd(812, 400, -119, 0.9, sec = self.dend[55]) h.pt3dadd(814, 401, -119, 0.9, sec = self.dend[55]) h.pt3dadd(816, 401, -119, 1, sec = self.dend[55]) h.pt3dadd(817.5, 401.5, -119, 1.1, sec = self.dend[55]) h.pt3dadd(818.5, 403, -121, 1.1, sec = self.dend[55]) h.pt3dadd(820.5, 404, -126, 0.9, sec = self.dend[55]) h.pt3dadd(824.5, 406, -131, 0.8, sec = self.dend[55]) h.pt3dclear(sec = self.dend[56]) h.pt3dadd(653.5, 382.5, -61, 4, sec = self.dend[56]) h.pt3dadd(652.5, 386, -61, 0.8, sec = self.dend[56]) h.pt3dadd(652.5, 388.5, -61, 0.8, sec = self.dend[56]) h.pt3dadd(652.5, 392, -61, 0.7, sec = self.dend[56]) h.pt3dadd(653.5, 396, -61, 0.7, sec = self.dend[56]) h.pt3dadd(654, 398, -61, 0.9, sec = self.dend[56]) h.pt3dadd(655, 400.5, -58, 1.1, sec = self.dend[56]) h.pt3dadd(656.5, 404, -61, 1.2, sec = self.dend[56]) h.pt3dadd(657, 405.5, -61, 1.7, sec = self.dend[56]) h.pt3dadd(658, 409, -61, 1.9, sec = self.dend[56]) h.pt3dadd(659, 410, -64, 1.3, sec = self.dend[56]) h.pt3dadd(660.5, 412, -64, 0.1, sec = self.dend[56]) h.pt3dadd(662, 414.5, -61, 0.1, sec = self.dend[56]) h.pt3dadd(665, 417.5, -61, 0.1, sec = self.dend[56]) h.pt3dadd(667.5, 421.5, -58, 0.1, sec = self.dend[56]) h.pt3dadd(672.5, 424, -56.5, 0.7, sec = self.dend[56]) h.pt3dadd(675.5, 426, -56.5, 0.7, sec = self.dend[56]) h.pt3dadd(676.5, 427.5, -54.5, 1.7, sec = self.dend[56]) h.pt3dadd(677, 429, -56.5, 0.3, sec = self.dend[56]) h.pt3dadd(679, 429.5, -56.5, 0.3, sec = self.dend[56]) h.pt3dadd(681, 434, -56.5, 0.3, sec = self.dend[56]) h.pt3dadd(681, 435.5, -54.5, 0.3, sec = self.dend[56]) h.pt3dadd(684, 438, -52.5, 0.3, sec = self.dend[56]) h.pt3dadd(685, 442, -50.5, 0.3, sec = self.dend[56]) h.pt3dadd(686, 444.5, -50.5, 1.6, sec = self.dend[56]) h.pt3dadd(689, 446, -50.5, 1.6, sec = self.dend[56]) h.pt3dadd(690.5, 447.5, -50.5, 0.6, sec = self.dend[56]) h.pt3dadd(693, 449.5, -52.5, 0.6, sec = self.dend[56]) h.pt3dadd(693, 451.5, -50.5, 0.6, sec = self.dend[56]) h.pt3dadd(695, 453, -50.5, 1, sec = self.dend[56]) h.pt3dadd(696, 454.5, -50.5, 1.2, sec = self.dend[56]) h.pt3dadd(697.5, 458, -50.5, 1.3, sec = self.dend[56]) h.pt3dadd(698.5, 461, -48.5, 1.6, sec = self.dend[56]) h.pt3dadd(700, 462.5, -48.5, 1.9, sec = self.dend[56]) h.pt3dadd(700, 464.5, -48.5, 2.3, sec = self.dend[56]) h.pt3dadd(700, 466.5, -48.5, 1.6, sec = self.dend[56]) h.pt3dadd(700.5, 469.5, -43, 1, sec = self.dend[56]) h.pt3dadd(701, 469.5, -45, 1, sec = self.dend[56]) h.pt3dadd(704.5, 471, -45, 1.1, sec = self.dend[56]) h.pt3dadd(704.5, 473.5, -45, 1.2, sec = self.dend[56]) h.pt3dadd(705, 477.5, -45, 1.2, sec = self.dend[56]) h.pt3dadd(704.5, 481, -45, 1.4, sec = self.dend[56]) h.pt3dadd(703.5, 481, -45, 1.6, sec = self.dend[56]) h.pt3dadd(703.5, 484, -45, 2.5, sec = self.dend[56]) h.pt3dadd(704, 485.5, -45, 3.3, sec = self.dend[56]) h.pt3dadd(705.5, 488.5, -45, 2.3, sec = self.dend[56]) h.pt3dadd(705.5, 489.5, -39, 1.3, sec = self.dend[56]) h.pt3dadd(706, 493, -37, 0.7, sec = self.dend[56]) h.pt3dadd(706, 495.5, -37, 0.8, sec = self.dend[56]) h.pt3dadd(707.5, 498.5, -39, 0.9, sec = self.dend[56]) h.pt3dadd(709, 501.5, -39, 1, sec = self.dend[56]) h.pt3dadd(709.5, 504.5, -39, 1, sec = self.dend[56]) h.pt3dadd(713, 509.5, -39, 1, sec = self.dend[56]) h.pt3dadd(713.5, 512, -39, 0.9, sec = self.dend[56]) h.pt3dadd(713, 519, -33, 2, sec = self.dend[56]) h.pt3dadd(713, 522.5, -39, 0.6, sec = self.dend[56]) h.pt3dadd(714, 523.5, -33, 0.6, sec = self.dend[56]) h.pt3dadd(713.5, 524.5, -26.5, 1.3, sec = self.dend[56]) h.pt3dadd(713, 526, -33, 1.7, sec = self.dend[56]) h.pt3dadd(714, 528, -33, 1.8, sec = self.dend[56]) h.pt3dadd(714, 528.5, -26.5, 0.1, sec = self.dend[56]) h.pt3dadd(714, 531, -33, 1.5, sec = self.dend[56]) h.pt3dadd(714, 533, -26.5, 1.5, sec = self.dend[56]) h.pt3dadd(714.5, 534, -26.5, 1.5, sec = self.dend[56]) h.pt3dadd(714.5, 536, -26.5, 1.2, sec = self.dend[56]) h.pt3dadd(715.5, 537.5, -26.5, 1, sec = self.dend[56]) h.pt3dadd(716, 538, -26.5, 0.5, sec = self.dend[56]) h.pt3dadd(716.5, 540.5, -26.5, 0.2, sec = self.dend[56]) h.pt3dadd(716.5, 541.5, -26.5, 0.1, sec = self.dend[56]) h.pt3dadd(717, 543, -26.5, 1.3, sec = self.dend[56]) h.pt3dadd(717, 545, -26.5, 2.1, sec = self.dend[56]) h.pt3dadd(718.5, 545.5, -26.5, 1.3, sec = self.dend[56]) h.pt3dadd(719, 548.5, -26.5, 0.9, sec = self.dend[56]) h.pt3dadd(720, 550, -26.5, 1.3, sec = self.dend[56]) h.pt3dadd(720, 551, -26.5, 0.9, sec = self.dend[56]) h.pt3dadd(720, 553, -26.5, 0.7, sec = self.dend[56]) h.pt3dadd(720, 554.5, -26.5, 0.9, sec = self.dend[56]) h.pt3dadd(720.5, 556, -20.5, 1.7, sec = self.dend[56]) h.pt3dadd(723, 557.5, -26.5, 1.7, sec = self.dend[56]) h.pt3dadd(723.5, 559.5, -20.5, 1.2, sec = self.dend[56]) h.pt3dadd(723.5, 561, -20.5, 0.9, sec = self.dend[56]) h.pt3dadd(724.5, 563.5, -20.5, 1.3, sec = self.dend[56]) h.pt3dadd(725.5, 565, -20.5, 1.2, sec = self.dend[56]) h.pt3dadd(725.5, 566, -20.5, 0.9, sec = self.dend[56]) h.pt3dadd(726, 567, -20.5, 0.9, sec = self.dend[56]) h.pt3dadd(726, 568.5, -20.5, 1.1, sec = self.dend[56]) h.pt3dadd(726, 570, -20.5, 1.1, sec = self.dend[56]) h.pt3dadd(728, 570, -20.5, 1.3, sec = self.dend[56]) h.pt3dadd(729, 569, -20.5, 0.9, sec = self.dend[56]) h.pt3dadd(730, 571, -14, 1.4, sec = self.dend[56]) h.pt3dadd(729.5, 572, -8, 0.9, sec = self.dend[56]) h.pt3dadd(729.5, 574, -8, 0.9, sec = self.dend[56]) h.pt3dadd(730, 574, -8, 1.7, sec = self.dend[56]) h.pt3dadd(730.5, 574.5, -8, 1.7, sec = self.dend[56]) h.pt3dadd(732.5, 574.5, -14, 2.1, sec = self.dend[56]) h.pt3dadd(731, 575.5, -8, 1.7, sec = self.dend[56]) h.pt3dadd(732, 576, -8, 0.9, sec = self.dend[56]) h.pt3dadd(731.5, 577, -8, 1.1, sec = self.dend[56]) h.pt3dadd(731.5, 579.5, -1.5, 1.2, sec = self.dend[56]) h.pt3dadd(731.5, 582, -1.5, 1.2, sec = self.dend[56]) h.pt3dadd(733, 584, -1.5, 1.1, sec = self.dend[56]) h.pt3dadd(734, 587, -8, 1.1, sec = self.dend[56]) h.pt3dadd(735.5, 589, -8, 1, sec = self.dend[56]) h.pt3dadd(735.5, 590.5, -1.5, 2.1, sec = self.dend[56]) h.pt3dadd(736, 591.5, -8, 2.5, sec = self.dend[56]) h.pt3dadd(736, 594.5, -1.5, 1.3, sec = self.dend[56]) h.pt3dadd(736.5, 597, -8, 1.1, sec = self.dend[56]) h.pt3dadd(737, 598, -8, 0.6, sec = self.dend[56]) h.pt3dadd(737, 599.5, 4.5, 0.4, sec = self.dend[56]) h.pt3dadd(738.5, 602.5, -1.5, 0.4, sec = self.dend[56]) h.pt3dadd(740.5, 603.5, -8, 0.4, sec = self.dend[56]) h.pt3dclear(sec = self.dend[57]) h.pt3dadd(513, 275, -58.5, 3.7, sec = self.dend[57]) h.pt3dadd(515, 280.5, -56.5, 1.6, sec = self.dend[57]) h.pt3dadd(516.5, 285, -58.5, 1.3, sec = self.dend[57]) h.pt3dadd(518, 287, -58.5, 1.4, sec = self.dend[57]) h.pt3dadd(518.5, 289.5, -58.5, 1.4, sec = self.dend[57]) h.pt3dadd(521, 290.5, -58.5, 1, sec = self.dend[57]) h.pt3dadd(524, 291.5, -58.5, 1, sec = self.dend[57]) h.pt3dadd(524, 296, -58.5, 1.2, sec = self.dend[57]) h.pt3dadd(525, 299, -58.5, 1.6, sec = self.dend[57]) h.pt3dadd(526.5, 304, -60.5, 1.2, sec = self.dend[57]) h.pt3dadd(528.5, 306.5, -62.5, 1.2, sec = self.dend[57]) h.pt3dadd(531.5, 309.5, -62.5, 1.2, sec = self.dend[57]) h.pt3dadd(535, 310.5, -62.5, 1.7, sec = self.dend[57]) h.pt3dadd(538, 312, -62.5, 1.7, sec = self.dend[57]) h.pt3dadd(540, 314, -62.5, 1.7, sec = self.dend[57]) h.pt3dadd(542.5, 316, -62.5, 1.7, sec = self.dend[57]) h.pt3dadd(544, 318.5, -62.5, 1.6, sec = self.dend[57]) h.pt3dadd(544.5, 320, -62.5, 1.4, sec = self.dend[57]) h.pt3dadd(546, 322, -60.5, 0.9, sec = self.dend[57]) h.pt3dadd(548, 325.5, -60.5, 0.9, sec = self.dend[57]) h.pt3dadd(549, 328, -60.5, 1.1, sec = self.dend[57]) h.pt3dadd(552, 331, -60.5, 1.2, sec = self.dend[57]) h.pt3dadd(555, 333, -60.5, 1.2, sec = self.dend[57]) h.pt3dadd(560, 333, -66, 1.1, sec = self.dend[57]) h.pt3dadd(563, 334.5, -62.5, 1.6, sec = self.dend[57]) h.pt3dadd(566.5, 336.5, -62.5, 1.6, sec = self.dend[57]) h.pt3dadd(566.5, 339.5, -62.5, 1.7, sec = self.dend[57]) h.pt3dadd(569.5, 343, -66, 1.7, sec = self.dend[57]) h.pt3dadd(571.5, 347, -66, 1.3, sec = self.dend[57]) h.pt3dadd(571, 349, -66, 1.4, sec = self.dend[57]) h.pt3dadd(571.5, 351.5, -66, 1.4, sec = self.dend[57]) h.pt3dadd(573, 352.5, -66, 1.7, sec = self.dend[57]) h.pt3dadd(573, 353, -66, 2, sec = self.dend[57]) h.pt3dadd(574, 355, -69, 2.1, sec = self.dend[57]) h.pt3dadd(576, 357, -69, 1.7, sec = self.dend[57]) h.pt3dadd(576, 358.5, -69, 1.5, sec = self.dend[57]) h.pt3dadd(577.5, 360.5, -69, 1.2, sec = self.dend[57]) h.pt3dadd(578.5, 363, -69, 1, sec = self.dend[57]) h.pt3dadd(581, 365, -69, 1, sec = self.dend[57]) h.pt3dadd(581, 367.5, -66, 1.5, sec = self.dend[57]) h.pt3dadd(581.5, 368, -72, 2, sec = self.dend[57]) h.pt3dadd(584.5, 372, -72, 2.1, sec = self.dend[57]) h.pt3dadd(586, 375.5, -72, 2.1, sec = self.dend[57]) h.pt3dadd(586.5, 378, -72, 2.1, sec = self.dend[57]) h.pt3dadd(587.5, 380.5, -69, 1.9, sec = self.dend[57]) h.pt3dadd(588.5, 382, -69, 1.8, sec = self.dend[57]) h.pt3dadd(588, 385.5, -69, 2.1, sec = self.dend[57]) h.pt3dclear(sec = self.dend[58]) h.pt3dadd(588, 385.5, -69, 2.1, sec = self.dend[58]) h.pt3dadd(590.5, 387.5, -75, 0.9, sec = self.dend[58]) h.pt3dadd(590.5, 385.5, -69, 0.9, sec = self.dend[58]) h.pt3dadd(591, 384.5, -69, 0.6, sec = self.dend[58]) h.pt3dadd(592, 383.5, -72, 0.6, sec = self.dend[58]) h.pt3dadd(592.5, 381.5, -78, 2.1, sec = self.dend[58]) h.pt3dadd(592.5, 385.5, -80.5, 0.3, sec = self.dend[58]) h.pt3dadd(592, 387.5, -83.5, 0.3, sec = self.dend[58]) h.pt3dadd(591.5, 390, -83.5, 0.4, sec = self.dend[58]) h.pt3dadd(594.5, 393, -80.5, 0.4, sec = self.dend[58]) h.pt3dadd(596.5, 396, -83.5, 0.6, sec = self.dend[58]) h.pt3dadd(597.5, 396, -83.5, 0.7, sec = self.dend[58]) h.pt3dadd(599, 397, -83.5, 1.4, sec = self.dend[58]) h.pt3dadd(602, 397, -86.5, 1.4, sec = self.dend[58]) h.pt3dadd(605, 398.5, -86.5, 1.6, sec = self.dend[58]) h.pt3dadd(607.5, 399, -86.5, 1.2, sec = self.dend[58]) h.pt3dadd(610, 399, -86.5, 0.7, sec = self.dend[58]) h.pt3dadd(613, 399, -89.5, 0.9, sec = self.dend[58]) h.pt3dadd(614, 401.5, -89.5, 1, sec = self.dend[58]) h.pt3dadd(615, 403.5, -89.5, 1.1, sec = self.dend[58]) h.pt3dadd(617, 405, -86.5, 0.6, sec = self.dend[58]) h.pt3dadd(617.5, 408.5, -89.5, 0.6, sec = self.dend[58]) h.pt3dadd(618.5, 410.5, -89.5, 0.6, sec = self.dend[58]) h.pt3dadd(619.5, 412, -89.5, 1.2, sec = self.dend[58]) h.pt3dadd(620.5, 414, -92.5, 1.7, sec = self.dend[58]) h.pt3dadd(622.5, 416, -92.5, 1.1, sec = self.dend[58]) h.pt3dadd(623.5, 417, -95.5, 1.1, sec = self.dend[58]) h.pt3dadd(627, 419.5, -95.5, 1.2, sec = self.dend[58]) h.pt3dadd(628.5, 421.5, -95.5, 1.3, sec = self.dend[58]) h.pt3dadd(631, 424.5, -95.5, 1.3, sec = self.dend[58]) h.pt3dadd(632.5, 425.5, -95.5, 1.2, sec = self.dend[58]) h.pt3dadd(632.5, 421, -95.5, 1.4, sec = self.dend[58]) h.pt3dadd(633.5, 421, -98, 0.7, sec = self.dend[58]) h.pt3dadd(636.5, 421, -98, 0.7, sec = self.dend[58]) h.pt3dadd(637.5, 420, -100.5, 0.7, sec = self.dend[58]) h.pt3dadd(639.5, 419.5, -100.5, 0.7, sec = self.dend[58]) h.pt3dadd(640.5, 419.5, -103, 0.7, sec = self.dend[58]) h.pt3dadd(642, 420.5, -103, 0.7, sec = self.dend[58]) h.pt3dadd(642, 422, -103, 0.7, sec = self.dend[58]) h.pt3dadd(642.5, 422, -103, 0.7, sec = self.dend[58]) h.pt3dadd(644, 421.5, -103, 0.7, sec = self.dend[58]) h.pt3dadd(646.5, 421.5, -103, 1.1, sec = self.dend[58]) h.pt3dadd(646.5, 422, -110, 1.5, sec = self.dend[58]) h.pt3dadd(649, 423.5, -103, 0.6, sec = self.dend[58]) h.pt3dadd(651, 423, -103, 0.6, sec = self.dend[58]) h.pt3dadd(651, 421.5, -103, 0.6, sec = self.dend[58]) h.pt3dadd(653, 421, -103, 0.7, sec = self.dend[58]) h.pt3dadd(655, 421, -103, 0.7, sec = self.dend[58]) h.pt3dadd(657, 422.5, -105, 0.7, sec = self.dend[58]) h.pt3dadd(657.5, 423.5, -105, 0.7, sec = self.dend[58]) h.pt3dadd(660.5, 425.5, -105, 0.7, sec = self.dend[58]) h.pt3dadd(662.5, 427, -105, 0.7, sec = self.dend[58]) h.pt3dadd(662.5, 429.5, -105, 0.7, sec = self.dend[58]) h.pt3dadd(663, 429.5, -105, 1.2, sec = self.dend[58]) h.pt3dadd(664, 432, -105, 0.9, sec = self.dend[58]) h.pt3dadd(665, 434.5, -105, 1.1, sec = self.dend[58]) h.pt3dadd(665.5, 436.5, -105, 0.7, sec = self.dend[58]) h.pt3dadd(667, 436.5, -107.5, 0.8, sec = self.dend[58]) h.pt3dadd(669, 439, -110, 0.6, sec = self.dend[58]) h.pt3dadd(672, 440.5, -112.5, 1.1, sec = self.dend[58]) h.pt3dadd(674, 442.5, -110, 0.5, sec = self.dend[58]) h.pt3dadd(674.5, 445.5, -110, 0.5, sec = self.dend[58]) h.pt3dadd(677, 446, -110, 0.5, sec = self.dend[58]) h.pt3dadd(677, 447, -110, 0.5, sec = self.dend[58]) h.pt3dadd(678, 447.5, -110, 0.5, sec = self.dend[58]) h.pt3dadd(680, 450.5, -112.5, 0.5, sec = self.dend[58]) h.pt3dadd(681, 449, -112.5, 1.1, sec = self.dend[58]) h.pt3dadd(682.5, 450.5, -114.5, 0.8, sec = self.dend[58]) h.pt3dadd(682.5, 453, -114.5, 0.8, sec = self.dend[58]) h.pt3dadd(683.5, 454.5, -117, 0.8, sec = self.dend[58]) h.pt3dadd(685, 457.5, -117, 0.8, sec = self.dend[58]) h.pt3dadd(685, 459.5, -117, 0.8, sec = self.dend[58]) h.pt3dadd(685, 461.5, -117, 0.8, sec = self.dend[58]) h.pt3dadd(687.5, 463, -117, 0.8, sec = self.dend[58]) h.pt3dadd(689, 466, -114.5, 0.8, sec = self.dend[58]) h.pt3dadd(690.5, 466.5, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(692, 468, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(693.5, 470.5, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(694.5, 472, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(695.5, 474.5, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(697, 476.5, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(699, 478.5, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(701.5, 478.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(704, 478.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(707, 479.5, -117, 0.7, sec = self.dend[58]) h.pt3dadd(707, 480, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(707, 482.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(708, 483, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(709, 484, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(710, 485, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(710, 486.5, -112.5, 0.7, sec = self.dend[58]) h.pt3dadd(712.5, 487.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(715.5, 489.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(718, 489.5, -114.5, 0.7, sec = self.dend[58]) h.pt3dadd(719.5, 490, -117, 0.7, sec = self.dend[58]) h.pt3dadd(721, 492, -119.5, 0.7, sec = self.dend[58]) h.pt3dadd(721, 494, -122, 0.7, sec = self.dend[58]) h.pt3dadd(720.5, 495.5, -124, 0.7, sec = self.dend[58]) h.pt3dadd(722, 500.5, -124, 0.7, sec = self.dend[58]) h.pt3dadd(722, 502, -124, 0.7, sec = self.dend[58]) h.pt3dadd(723.5, 504, -117, 0.7, sec = self.dend[58]) h.pt3dadd(723.5, 506.5, -117, 0.7, sec = self.dend[58]) h.pt3dadd(724.5, 509, -117, 0.7, sec = self.dend[58]) h.pt3dadd(725, 511.5, -114.5, 0.1, sec = self.dend[58]) h.pt3dadd(727.5, 511.5, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(729.5, 513, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(730.5, 517, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(731.5, 519.5, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(732, 519.5, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(732.5, 521, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(734.5, 524.5, -114.5, 0.1, sec = self.dend[58]) h.pt3dadd(736.5, 529.5, -110, 0.1, sec = self.dend[58]) h.pt3dadd(741, 529.5, -110, 0.1, sec = self.dend[58]) h.pt3dadd(741.5, 532, -110, 0.1, sec = self.dend[58]) h.pt3dadd(741.5, 534.5, -110, 0.1, sec = self.dend[58]) h.pt3dadd(744.5, 537, -110, 0.1, sec = self.dend[58]) h.pt3dadd(744.5, 539, -110, 0.1, sec = self.dend[58]) h.pt3dadd(748.5, 541, -112.5, 0.1, sec = self.dend[58]) h.pt3dadd(749, 541, -107.5, 0.9, sec = self.dend[58]) h.pt3dadd(750, 544, -107.5, 0.1, sec = self.dend[58]) h.pt3dadd(752.5, 548.5, -107.5, 0.1, sec = self.dend[58]) h.pt3dadd(754.5, 553, -107.5, 0.1, sec = self.dend[58]) h.pt3dclear(sec = self.dend[59]) h.pt3dadd(588, 385.5, -69, 2.1, sec = self.dend[59]) h.pt3dadd(587.5, 391, -72, 1.1, sec = self.dend[59]) h.pt3dadd(587.5, 392, -66, 0.5, sec = self.dend[59]) h.pt3dadd(586.5, 393.5, -63, 0.7, sec = self.dend[59]) h.pt3dadd(586.5, 396, -63, 0.7, sec = self.dend[59]) h.pt3dadd(586.5, 396.5, -69, 0.7, sec = self.dend[59]) h.pt3dadd(586, 398.5, -69, 0.7, sec = self.dend[59]) h.pt3dadd(586, 400.5, -66, 1.1, sec = self.dend[59]) h.pt3dadd(587.5, 401.5, -69, 1.1, sec = self.dend[59]) h.pt3dadd(588.5, 405.5, -69, 1.3, sec = self.dend[59]) h.pt3dadd(589, 408.5, -69, 1.4, sec = self.dend[59]) h.pt3dadd(589.5, 412, -69, 1.4, sec = self.dend[59]) h.pt3dadd(589.5, 414.5, -69, 1.3, sec = self.dend[59]) h.pt3dadd(589.5, 417.5, -69, 1.3, sec = self.dend[59]) h.pt3dadd(589, 419.5, -66, 1.3, sec = self.dend[59]) h.pt3dadd(588, 424.5, -66, 1.3, sec = self.dend[59]) h.pt3dadd(590, 429, -60, 0.9, sec = self.dend[59]) h.pt3dadd(591, 432, -60, 0.9, sec = self.dend[59]) h.pt3dadd(593, 433.5, -60, 1.1, sec = self.dend[59]) h.pt3dadd(592, 438, -60, 1.1, sec = self.dend[59]) h.pt3dadd(592, 440, -60, 1.1, sec = self.dend[59]) h.pt3dadd(592, 444, -60, 1.2, sec = self.dend[59]) h.pt3dadd(592, 447, -60, 1.2, sec = self.dend[59]) h.pt3dadd(592, 448.5, -60, 1.2, sec = self.dend[59]) h.pt3dadd(590.5, 450.5, -56.5, 0.9, sec = self.dend[59]) h.pt3dadd(592.5, 451, -56.5, 1.4, sec = self.dend[59]) h.pt3dadd(593.5, 455.5, -56.5, 0.9, sec = self.dend[59]) h.pt3dadd(594.5, 459.5, -58, 0.9, sec = self.dend[59]) h.pt3dadd(594.5, 460.5, -56.5, 1, sec = self.dend[59]) h.pt3dadd(595.5, 463.5, -56.5, 1, sec = self.dend[59]) h.pt3dadd(595.5, 466, -56.5, 1, sec = self.dend[59]) h.pt3dadd(597, 469.5, -56.5, 1.1, sec = self.dend[59]) h.pt3dadd(597, 472.5, -56.5, 1.2, sec = self.dend[59]) h.pt3dadd(597, 476, -56.5, 1.2, sec = self.dend[59]) h.pt3dadd(598.5, 476.5, -56.5, 1.5, sec = self.dend[59]) h.pt3dadd(599.5, 481, -56.5, 2, sec = self.dend[59]) h.pt3dadd(601, 484.5, -60, 2, sec = self.dend[59]) h.pt3dadd(601, 488, -60, 2.7, sec = self.dend[59]) h.pt3dadd(602, 491, -60, 2.8, sec = self.dend[59]) h.pt3dadd(601.5, 493.5, -48.5, 1, sec = self.dend[59]) h.pt3dadd(602.5, 499.5, -52.5, 1.1, sec = self.dend[59]) h.pt3dadd(602, 502, -52.5, 1.4, sec = self.dend[59]) h.pt3dadd(600, 504.5, -52.5, 1.3, sec = self.dend[59]) h.pt3dadd(599.5, 506, -52.5, 1.3, sec = self.dend[59]) h.pt3dadd(600.5, 508, -52.5, 1.1, sec = self.dend[59]) h.pt3dadd(600.5, 510.5, -52.5, 1.8, sec = self.dend[59]) h.pt3dadd(600.5, 512, -52.5, 2, sec = self.dend[59]) h.pt3dadd(601.5, 514.5, -52.5, 1.9, sec = self.dend[59]) h.pt3dadd(602.5, 517, -52.5, 0.8, sec = self.dend[59]) h.pt3dadd(602.5, 520, -54.5, 1.1, sec = self.dend[59]) h.pt3dadd(603, 522, -54.5, 1.1, sec = self.dend[59]) h.pt3dadd(603, 524, -52.5, 1.5, sec = self.dend[59]) h.pt3dadd(605.5, 525.5, -52.5, 1.5, sec = self.dend[59]) h.pt3dadd(607, 529, -52.5, 1.2, sec = self.dend[59]) h.pt3dadd(607.5, 531, -52.5, 1, sec = self.dend[59]) h.pt3dadd(608, 535, -52.5, 1, sec = self.dend[59]) h.pt3dadd(608, 536.5, -54.5, 1, sec = self.dend[59]) h.pt3dadd(608.5, 540, -54.5, 0.7, sec = self.dend[59]) h.pt3dadd(608, 545, -52.5, 1.1, sec = self.dend[59]) h.pt3dadd(609.5, 553.5, -58, 1.1, sec = self.dend[59]) h.pt3dadd(610, 557.5, -54.5, 0.1, sec = self.dend[59]) h.pt3dadd(608.5, 567.5, -54.5, 0.1, sec = self.dend[59]) h.pt3dadd(609.5, 576.5, -54.5, 0.1, sec = self.dend[59]) h.pt3dadd(609, 580.5, -54.5, 0.1, sec = self.dend[59]) h.pt3dadd(609, 582.5, -48, 0.1, sec = self.dend[59]) h.pt3dadd(610, 585, -54.5, 0.9, sec = self.dend[59]) h.pt3dadd(610.5, 587, -48, 1.1, sec = self.dend[59]) h.pt3dadd(610.5, 587.5, -48, 1.1, sec = self.dend[59]) h.pt3dadd(611.5, 589, -48, 0.4, sec = self.dend[59]) h.pt3dadd(611.5, 591, -48, 0.4, sec = self.dend[59]) h.pt3dadd(611, 592.5, -48, 0.4, sec = self.dend[59]) h.pt3dadd(610, 595, -48, 0.4, sec = self.dend[59]) h.pt3dadd(610.5, 596.5, -48, 0.3, sec = self.dend[59]) h.pt3dadd(610.5, 598, -54.5, 2, sec = self.dend[59]) h.pt3dadd(610, 599.5, -48, 0.1, sec = self.dend[59]) h.pt3dadd(611.5, 603.5, -54.5, 0.2, sec = self.dend[59]) h.pt3dadd(612, 605, -48, 0.6, sec = self.dend[59]) h.pt3dadd(612.5, 606.5, -48, 1.1, sec = self.dend[59]) h.pt3dadd(612.5, 608, -48, 1.2, sec = self.dend[59]) h.pt3dadd(612.5, 611.5, -48, 1.5, sec = self.dend[59]) h.pt3dadd(613, 613.5, -48, 2.2, sec = self.dend[59]) h.pt3dadd(614, 616.5, -48, 2.2, sec = self.dend[59]) h.pt3dadd(614, 619, -48, 2.1, sec = self.dend[59]) h.pt3dadd(613.5, 621.5, -42, 1.4, sec = self.dend[59]) h.pt3dadd(613, 621.5, -42, 1.2, sec = self.dend[59]) h.pt3dadd(612.5, 623.5, -42, 1.2, sec = self.dend[59]) h.pt3dadd(612, 626.5, -35.5, 1.9, sec = self.dend[59]) h.pt3dadd(610.5, 627.5, -42, 1.6, sec = self.dend[59]) h.pt3dadd(610, 629.5, -42, 1.3, sec = self.dend[59]) h.pt3dadd(610, 632, -42, 1.3, sec = self.dend[59]) h.pt3dadd(610, 635, -42, 1.1, sec = self.dend[59]) h.pt3dadd(610, 638, -42, 1, sec = self.dend[59]) h.pt3dadd(610, 638.5, -42, 1, sec = self.dend[59]) h.pt3dadd(609, 639.5, -42, 2.5, sec = self.dend[59]) h.pt3dadd(609, 641, -42, 2.6, sec = self.dend[59]) h.pt3dadd(609, 642.5, -42, 2, sec = self.dend[59]) h.pt3dadd(609.5, 645, -35.5, 1, sec = self.dend[59]) h.pt3dadd(608, 645.5, -35.5, 1, sec = self.dend[59]) h.pt3dadd(607.5, 647.5, -35.5, 1, sec = self.dend[59]) h.pt3dadd(606, 648.5, -35.5, 0.1, sec = self.dend[59]) h.pt3dadd(607, 649.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(608.5, 651.5, -35.5, 1.7, sec = self.dend[59]) h.pt3dadd(608, 652.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(608, 654.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(608.5, 655.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(609, 656.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(609, 658, -29.5, 1.4, sec = self.dend[59]) h.pt3dadd(608.5, 660, -29.5, 1.7, sec = self.dend[59]) h.pt3dadd(608, 661, -35.5, 0.1, sec = self.dend[59]) h.pt3dadd(607.5, 664, -35.5, 0.2, sec = self.dend[59]) h.pt3dadd(607, 664, -29.5, 0.7, sec = self.dend[59]) h.pt3dadd(607, 665, -29.5, 2, sec = self.dend[59]) h.pt3dadd(607, 668, -29.5, 2.5, sec = self.dend[59]) h.pt3dadd(606.5, 670, -35.5, 2.5, sec = self.dend[59]) h.pt3dadd(605.5, 673, -35.5, 2.4, sec = self.dend[59]) h.pt3dadd(603.5, 673, -35.5, 0.9, sec = self.dend[59]) h.pt3dadd(601.5, 674.5, -35.5, 0.1, sec = self.dend[59]) h.pt3dadd(601, 676.5, -35.5, 0.1, sec = self.dend[59]) h.pt3dadd(600, 679, -35.5, 0.1, sec = self.dend[59]) h.pt3dadd(600, 680.5, -35.5, 1.6, sec = self.dend[59]) h.pt3dadd(597.5, 682, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(596, 684, -29.5, 1.3, sec = self.dend[59]) h.pt3dadd(595, 685.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(595, 689.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(595, 692, -23, 0.1, sec = self.dend[59]) h.pt3dadd(595.5, 693, -23, 0.1, sec = self.dend[59]) h.pt3dadd(595.5, 695.5, -29.5, 1.6, sec = self.dend[59]) h.pt3dadd(595.5, 697, -23, 3, sec = self.dend[59]) h.pt3dadd(595, 699.5, -23, 3.9, sec = self.dend[59]) h.pt3dadd(593.5, 699.5, -23, 2.5, sec = self.dend[59]) h.pt3dadd(593.5, 701, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(592.5, 702.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(590.5, 703, -29.5, 2.8, sec = self.dend[59]) h.pt3dadd(590, 706.5, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(590, 709, -29.5, 0.1, sec = self.dend[59]) h.pt3dadd(591, 710.5, -29.5, 1.1, sec = self.dend[59]) h.pt3dadd(591, 712, -29.5, 1.1, sec = self.dend[59]) h.pt3dadd(591, 716, -29.5, 0.7, sec = self.dend[59]) h.pt3dadd(591, 717.5, -23, 2.2, sec = self.dend[59]) h.pt3dadd(590.5, 720.5, -23, 2.7, sec = self.dend[59]) h.pt3dadd(591, 723, -23, 1.7, sec = self.dend[59]) h.pt3dadd(592, 725.5, -23, 1.5, sec = self.dend[59]) h.pt3dadd(591.5, 727, -23, 0.9, sec = self.dend[59]) h.pt3dadd(591.5, 729, -23, 0.1, sec = self.dend[59]) h.pt3dadd(591.5, 732.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(591, 734, -23, 0.1, sec = self.dend[59]) h.pt3dadd(591, 734.5, -23, 0.9, sec = self.dend[59]) h.pt3dadd(589.5, 737, -23, 0.1, sec = self.dend[59]) h.pt3dadd(589, 738.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(589, 740.5, -23, 0.8, sec = self.dend[59]) h.pt3dadd(589.5, 743, -23, 0.1, sec = self.dend[59]) h.pt3dadd(590, 744, -23, 0.1, sec = self.dend[59]) h.pt3dadd(590, 746.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(589.5, 748, -17, 1.3, sec = self.dend[59]) h.pt3dadd(588, 750.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(588, 752.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(588.5, 753, -17, 4.3, sec = self.dend[59]) h.pt3dadd(587, 756.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(586, 759.5, -23, 0.1, sec = self.dend[59]) h.pt3dadd(584.5, 760, -23, 2.6, sec = self.dend[59]) h.pt3dadd(583.5, 762, -17, 0.1, sec = self.dend[59]) h.pt3dadd(582.5, 766, -17, 0.1, sec = self.dend[59]) h.pt3dadd(580.5, 770, -17, 0.1, sec = self.dend[59]) h.pt3dadd(580, 773.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(579, 776.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(576, 780.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(572.5, 783, -17, 0.1, sec = self.dend[59]) h.pt3dadd(571, 783.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(568, 784, -17, 0.1, sec = self.dend[59]) h.pt3dadd(566.5, 786.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(564, 790.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(564, 794.5, -17, 0.1, sec = self.dend[59]) h.pt3dadd(564, 798, -10.5, 0.1, sec = self.dend[59]) h.pt3dadd(564.5, 802.5, -10.5, 0.1, sec = self.dend[59]) h.pt3dclear(sec = self.dend[60]) h.pt3dadd(305.5, 165, -33.5, 11.2, sec = self.dend[60]) h.pt3dadd(310.5, 160.5, -40, 7.6, sec = self.dend[60]) h.pt3dadd(314, 159.5, -40, 6.3, sec = self.dend[60]) h.pt3dadd(317.5, 159.5, -40, 6, sec = self.dend[60]) h.pt3dadd(319, 158.5, -40, 4.7, sec = self.dend[60]) h.pt3dadd(322.5, 158.5, -46, 3.8, sec = self.dend[60]) h.pt3dadd(325, 159, -46, 3.8, sec = self.dend[60]) h.pt3dadd(326.5, 160, -46, 4, sec = self.dend[60]) h.pt3dadd(328.5, 160.5, -52.5, 5, sec = self.dend[60]) h.pt3dadd(331, 163, -58.5, 4.7, sec = self.dend[60]) h.pt3dadd(332, 165, -52.5, 4, sec = self.dend[60]) h.pt3dadd(334, 166.5, -52.5, 4, sec = self.dend[60]) h.pt3dadd(336, 168, -52.5, 4.8, sec = self.dend[60]) h.pt3dadd(336, 171, -52.5, 5.7, sec = self.dend[60]) h.pt3dadd(336.5, 174.5, -52.5, 5.8, sec = self.dend[60]) h.pt3dadd(337, 178, -52.5, 6, sec = self.dend[60]) h.pt3dadd(341, 182, -56.5, 4.3, sec = self.dend[60]) h.pt3dadd(344.5, 182, -56.5, 3.8, sec = self.dend[60]) h.pt3dadd(348, 183, -56.5, 4.3, sec = self.dend[60]) h.pt3dadd(351, 184.5, -56.5, 4.3, sec = self.dend[60]) h.pt3dadd(354, 185.5, -58, 4.8, sec = self.dend[60]) h.pt3dadd(355.5, 185.5, -58, 5.5, sec = self.dend[60]) h.pt3dadd(357, 186.5, -58, 5.3, sec = self.dend[60]) h.pt3dadd(358.5, 186.5, -58, 4.8, sec = self.dend[60]) h.pt3dadd(359.5, 187.5, -62, 4.3, sec = self.dend[60]) h.pt3dadd(362, 188.5, -60, 2.6, sec = self.dend[60]) h.pt3dadd(364.5, 188.5, -60, 3.4, sec = self.dend[60]) h.pt3dadd(366, 188.5, -60, 5, sec = self.dend[60]) h.pt3dadd(368, 189.5, -60, 4.9, sec = self.dend[60]) h.pt3dadd(369, 191, -62, 4.9, sec = self.dend[60]) h.pt3dadd(374, 191, -66, 4.7, sec = self.dend[60]) h.pt3dadd(376.5, 191, -63, 2.9, sec = self.dend[60]) h.pt3dadd(378.5, 191.5, -63, 4.3, sec = self.dend[60]) h.pt3dadd(380.5, 191.5, -66, 5.7, sec = self.dend[60]) h.pt3dclear(sec = self.dend[61]) h.pt3dadd(380.5, 191.5, -66, 5.7, sec = self.dend[61]) h.pt3dadd(384, 189.5, -63, 3.7, sec = self.dend[61]) h.pt3dadd(385.5, 188, -66, 3.1, sec = self.dend[61]) h.pt3dadd(386.5, 188, -66, 2.7, sec = self.dend[61]) h.pt3dadd(389, 187.5, -72, 3.8, sec = self.dend[61]) h.pt3dadd(391.5, 187.5, -72, 3.6, sec = self.dend[61]) h.pt3dadd(393.5, 187, -72, 2.7, sec = self.dend[61]) h.pt3dadd(396.5, 183.5, -69, 3.1, sec = self.dend[61]) h.pt3dadd(397.5, 183, -69, 4.3, sec = self.dend[61]) h.pt3dadd(398.5, 182.5, -69, 4.3, sec = self.dend[61]) h.pt3dadd(400, 180.5, -78, 4.3, sec = self.dend[61]) h.pt3dadd(401, 180.5, -78, 5.4, sec = self.dend[61]) h.pt3dadd(402, 180, -78, 5.9, sec = self.dend[61]) h.pt3dclear(sec = self.dend[62]) h.pt3dadd(402, 180, -78, 5.9, sec = self.dend[62]) h.pt3dadd(404.5, 175.5, -81, 2.6, sec = self.dend[62]) h.pt3dadd(404.5, 174, -81, 2.6, sec = self.dend[62]) h.pt3dadd(400.5, 172.5, -81, 2.4, sec = self.dend[62]) h.pt3dadd(399.5, 173, -86.5, 2.9, sec = self.dend[62]) h.pt3dadd(396, 174, -86.5, 3.1, sec = self.dend[62]) h.pt3dadd(398.5, 175.5, -86.5, 3.3, sec = self.dend[62]) h.pt3dadd(397.5, 171, -86.5, 3.4, sec = self.dend[62]) h.pt3dadd(397.5, 168, -86.5, 3, sec = self.dend[62]) h.pt3dadd(396, 165, -89, 1.7, sec = self.dend[62]) h.pt3dadd(394.5, 164.5, -89, 2.5, sec = self.dend[62]) h.pt3dadd(395, 168, -89, 2.2, sec = self.dend[62]) h.pt3dadd(393, 164.5, -96, 3.1, sec = self.dend[62]) h.pt3dadd(395.5, 162, -96, 3.1, sec = self.dend[62]) h.pt3dadd(396.5, 160, -96, 3.1, sec = self.dend[62]) h.pt3dadd(396.5, 157, -96, 2.8, sec = self.dend[62]) h.pt3dadd(393.5, 157.5, -96, 2.6, sec = self.dend[62]) h.pt3dadd(394, 156, -105.5, 2.1, sec = self.dend[62]) h.pt3dadd(395, 154.5, -105.5, 1.9, sec = self.dend[62]) h.pt3dadd(397.5, 152, -113, 2.6, sec = self.dend[62]) h.pt3dadd(394.5, 151, -105.5, 2.8, sec = self.dend[62]) h.pt3dadd(393, 151, -113, 3.4, sec = self.dend[62]) h.pt3dadd(393.5, 148.5, -117.5, 3.4, sec = self.dend[62]) h.pt3dclear(sec = self.dend[63]) h.pt3dadd(402, 180, -78, 5.9, sec = self.dend[63]) h.pt3dadd(406.5, 178.5, -81, 2.8, sec = self.dend[63]) h.pt3dadd(408, 178.5, -81, 2.6, sec = self.dend[63]) h.pt3dadd(410.5, 177.5, -81, 2.1, sec = self.dend[63]) h.pt3dadd(412.5, 177.5, -81, 2.1, sec = self.dend[63]) h.pt3dadd(415.5, 177, -81, 2.7, sec = self.dend[63]) h.pt3dadd(416.5, 177, -81, 2.4, sec = self.dend[63]) h.pt3dadd(419, 176, -84, 1.9, sec = self.dend[63]) h.pt3dadd(421, 175, -84, 1.9, sec = self.dend[63]) h.pt3dadd(423, 175, -84, 2.5, sec = self.dend[63]) h.pt3dadd(429.5, 171.5, -81, 3.1, sec = self.dend[63]) h.pt3dadd(433, 170, -81, 2.3, sec = self.dend[63]) h.pt3dadd(436, 168, -86.5, 2.7, sec = self.dend[63]) h.pt3dadd(439, 166, -89.5, 2.7, sec = self.dend[63]) h.pt3dadd(441.5, 164.5, -89.5, 3.3, sec = self.dend[63]) h.pt3dadd(443, 163.5, -84, 3.7, sec = self.dend[63]) h.pt3dadd(445.5, 162, -84, 3.7, sec = self.dend[63]) h.pt3dadd(448, 160, -84, 2.3, sec = self.dend[63]) h.pt3dadd(449, 158.5, -84, 2.6, sec = self.dend[63]) h.pt3dadd(451.5, 156, -89.5, 2.5, sec = self.dend[63]) h.pt3dadd(454.5, 151.5, -89.5, 2.7, sec = self.dend[63]) h.pt3dadd(455, 150.5, -94.5, 3.1, sec = self.dend[63]) h.pt3dadd(456, 148, -89.5, 2.7, sec = self.dend[63]) h.pt3dadd(456.5, 147, -94.5, 2.4, sec = self.dend[63]) h.pt3dadd(456.5, 144.5, -92, 2.7, sec = self.dend[63]) h.pt3dadd(457, 143.5, -94.5, 2.5, sec = self.dend[63]) h.pt3dadd(457, 141.5, -94.5, 2.4, sec = self.dend[63]) h.pt3dadd(458.5, 141, -94.5, 2.4, sec = self.dend[63]) h.pt3dadd(459, 139.5, -92, 3.1, sec = self.dend[63]) h.pt3dadd(460.5, 138.5, -94.5, 2.8, sec = self.dend[63]) h.pt3dadd(462, 137.5, -94.5, 2.3, sec = self.dend[63]) h.pt3dadd(462.5, 135.5, -96.5, 2.1, sec = self.dend[63]) h.pt3dadd(464, 134.5, -96.5, 1.9, sec = self.dend[63]) h.pt3dadd(464.5, 132.5, -96.5, 1.6, sec = self.dend[63]) h.pt3dadd(465, 131.5, -99, 1.6, sec = self.dend[63]) h.pt3dadd(466, 131, -99, 1.6, sec = self.dend[63]) h.pt3dadd(467.5, 130, -99, 2, sec = self.dend[63]) h.pt3dadd(469, 129.5, -101.5, 2.1, sec = self.dend[63]) h.pt3dadd(470.5, 129.5, -101.5, 1.9, sec = self.dend[63]) h.pt3dadd(472, 128, -101.5, 1.8, sec = self.dend[63]) h.pt3dadd(473, 127.5, -104, 1.8, sec = self.dend[63]) h.pt3dadd(474.5, 126, -104, 1.8, sec = self.dend[63]) h.pt3dadd(473.5, 124, -104, 2.2, sec = self.dend[63]) h.pt3dadd(473.5, 121.5, -104, 2.5, sec = self.dend[63]) h.pt3dadd(474.5, 117.5, -104, 2.5, sec = self.dend[63]) h.pt3dadd(474.5, 117, -104, 2.5, sec = self.dend[63]) h.pt3dadd(474.5, 115, -101.5, 2.7, sec = self.dend[63]) h.pt3dadd(474, 109.5, -106, 2.5, sec = self.dend[63]) h.pt3dadd(473, 105.5, -106, 2.4, sec = self.dend[63]) h.pt3dadd(472, 104.5, -106, 2, sec = self.dend[63]) h.pt3dadd(471, 102.5, -106, 1.9, sec = self.dend[63]) h.pt3dadd(470.5, 101, -106, 1.8, sec = self.dend[63]) h.pt3dadd(471, 98.5, -106, 1.8, sec = self.dend[63]) h.pt3dadd(469.5, 96.5, -106, 1.6, sec = self.dend[63]) h.pt3dadd(469.5, 95.5, -108.5, 1.4, sec = self.dend[63]) h.pt3dadd(469, 94, -108.5, 1.4, sec = self.dend[63]) h.pt3dadd(468.5, 92, -108.5, 1.4, sec = self.dend[63]) h.pt3dclear(sec = self.dend[64]) h.pt3dadd(380.5, 191.5, -66, 5.7, sec = self.dend[64]) h.pt3dadd(382, 195, -63, 1.5, sec = self.dend[64]) h.pt3dadd(384.5, 196, -66, 1.5, sec = self.dend[64]) h.pt3dadd(387.5, 198.5, -66, 1.5, sec = self.dend[64]) h.pt3dadd(389.5, 200.5, -66, 1.5, sec = self.dend[64]) h.pt3dadd(390, 200.5, -63, 2.6, sec = self.dend[64]) h.pt3dadd(392.5, 202, -63, 2.6, sec = self.dend[64]) h.pt3dadd(395, 202.5, -63, 2.7, sec = self.dend[64]) h.pt3dadd(397, 204, -63, 2.7, sec = self.dend[64]) h.pt3dadd(400, 205.5, -66, 1.7, sec = self.dend[64]) h.pt3dadd(400.5, 206, -66, 1.8, sec = self.dend[64]) h.pt3dadd(403.5, 206.5, -69, 1.8, sec = self.dend[64]) h.pt3dadd(405.5, 207.5, -69, 2, sec = self.dend[64]) h.pt3dadd(408, 207.5, -69, 1.8, sec = self.dend[64]) h.pt3dadd(410.5, 208, -69, 1.4, sec = self.dend[64]) h.pt3dadd(412, 210, -69, 2, sec = self.dend[64]) h.pt3dadd(413.5, 211.5, -69, 3, sec = self.dend[64]) h.pt3dadd(415, 212.5, -72, 3.7, sec = self.dend[64]) h.pt3dadd(417, 214.5, -72, 3.3, sec = self.dend[64]) h.pt3dadd(418.5, 216.5, -69, 2.5, sec = self.dend[64]) h.pt3dadd(418.5, 218, -69, 2.7, sec = self.dend[64]) h.pt3dadd(420.5, 219.5, -75, 2.1, sec = self.dend[64]) h.pt3dadd(421, 221, -75, 1.7, sec = self.dend[64]) h.pt3dadd(423.5, 221, -75, 1.7, sec = self.dend[64]) h.pt3dadd(426.5, 221, -78, 2.1, sec = self.dend[64]) h.pt3dadd(428, 221.5, -78, 2.8, sec = self.dend[64]) h.pt3dadd(430.5, 223.5, -78, 3, sec = self.dend[64]) h.pt3dadd(433, 223.5, -78, 2.8, sec = self.dend[64]) h.pt3dadd(434, 225, -78, 3.1, sec = self.dend[64]) h.pt3dadd(435.5, 225.5, -81, 3.7, sec = self.dend[64]) h.pt3dadd(437.5, 228.5, -81, 2.7, sec = self.dend[64]) h.pt3dadd(441, 230.5, -81, 3.4, sec = self.dend[64]) h.pt3dadd(444, 233, -81, 3.1, sec = self.dend[64]) h.pt3dadd(447, 235.5, -84, 3.4, sec = self.dend[64]) h.pt3dadd(450, 236.5, -84, 2.5, sec = self.dend[64]) h.pt3dadd(452.5, 239, -84, 2.5, sec = self.dend[64]) h.pt3dadd(454, 242, -86.5, 2.5, sec = self.dend[64]) h.pt3dadd(456, 245.5, -86.5, 2.3, sec = self.dend[64]) h.pt3dadd(458.5, 247.5, -89.5, 1.8, sec = self.dend[64]) h.pt3dadd(463, 249.5, -94.5, 1.8, sec = self.dend[64]) h.pt3dadd(465.5, 250, -94.5, 1.8, sec = self.dend[64]) h.pt3dadd(463.5, 253, -97, 1.8, sec = self.dend[64]) h.pt3dadd(466, 253, -99, 1.8, sec = self.dend[64]) h.pt3dadd(468, 254, -99, 1.8, sec = self.dend[64]) h.pt3dadd(470, 254, -99, 2.1, sec = self.dend[64]) h.pt3dadd(471, 255, -97, 2.4, sec = self.dend[64]) h.pt3dadd(472, 256.5, -97, 2, sec = self.dend[64]) h.pt3dadd(474.5, 256.5, -97, 2, sec = self.dend[64]) h.pt3dadd(476, 256.5, -97, 2.8, sec = self.dend[64]) h.pt3dadd(477, 256, -99, 3.6, sec = self.dend[64]) h.pt3dadd(479.5, 256, -99, 3.6, sec = self.dend[64]) h.pt3dadd(481, 255, -104, 2.7, sec = self.dend[64]) h.pt3dadd(482, 255, -104, 2.2, sec = self.dend[64]) h.pt3dadd(483.5, 253, -104, 2.2, sec = self.dend[64]) h.pt3dadd(485.5, 253, -104, 2.2, sec = self.dend[64]) h.pt3dadd(488, 253, -104, 2.2, sec = self.dend[64]) h.pt3dadd(488, 255, -104, 2.2, sec = self.dend[64]) h.pt3dadd(489.5, 255, -104, 2.2, sec = self.dend[64]) h.pt3dadd(490.5, 257, -106.5, 1.4, sec = self.dend[64]) h.pt3dadd(492.5, 257.5, -106.5, 1.4, sec = self.dend[64]) h.pt3dadd(494.5, 257.5, -106.5, 2.7, sec = self.dend[64]) h.pt3dadd(496, 257.5, -106.5, 2.6, sec = self.dend[64]) h.pt3dadd(498, 257.5, -111, 2.4, sec = self.dend[64]) h.pt3dadd(499.5, 257.5, -111, 2.1, sec = self.dend[64]) h.pt3dadd(502.5, 257.5, -111, 2.1, sec = self.dend[64]) h.pt3dadd(504.5, 258, -111, 2.1, sec = self.dend[64]) h.pt3dadd(506, 259, -111, 2, sec = self.dend[64]) h.pt3dadd(508, 260, -111, 1.9, sec = self.dend[64]) h.pt3dadd(509.5, 260, -111, 1.9, sec = self.dend[64]) h.pt3dadd(510, 263, -113.5, 2.4, sec = self.dend[64]) h.pt3dadd(511, 265, -116, 2.4, sec = self.dend[64]) h.pt3dadd(513, 265, -116, 2.4, sec = self.dend[64]) h.pt3dclear(sec = self.dend[65]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[65]) h.pt3dadd(26, 44, -11, 7.7, sec = self.dend[65]) h.pt3dadd(25.5, 47, -10, 7, sec = self.dend[65]) h.pt3dadd(24, 49.5, -10, 7, sec = self.dend[65]) h.pt3dadd(22, 53, -10, 7, sec = self.dend[65]) h.pt3dadd(22, 56, -10, 7, sec = self.dend[65]) h.pt3dadd(22, 59.5, -10, 7, sec = self.dend[65]) h.pt3dadd(22, 61.5, -10, 7, sec = self.dend[65]) h.pt3dadd(22, 64, -10, 7, sec = self.dend[65]) h.pt3dadd(21.5, 66.5, -9.5, 7.3, sec = self.dend[65]) h.pt3dadd(21.5, 69.5, -9.5, 6.5, sec = self.dend[65]) h.pt3dadd(19.5, 72.5, -9.5, 6.5, sec = self.dend[65]) h.pt3dadd(18, 77, -9.5, 6.5, sec = self.dend[65]) h.pt3dadd(16.5, 81, -9.5, 6.5, sec = self.dend[65]) h.pt3dadd(14.5, 83, -8.5, 6.2, sec = self.dend[65]) h.pt3dadd(14.5, 85.5, -8.5, 5.6, sec = self.dend[65]) h.pt3dadd(13, 88.5, -8.5, 5, sec = self.dend[65]) h.pt3dadd(11, 91, -8.5, 5.3, sec = self.dend[65]) h.pt3dadd(10, 94, -8.5, 7.3, sec = self.dend[65]) h.pt3dadd(9.5, 97, -7.5, 8, sec = self.dend[65]) h.pt3dadd(7, 102.5, -7.5, 8.1, sec = self.dend[65]) h.pt3dadd(6.5, 104.5, -9.5, 8.2, sec = self.dend[65]) h.pt3dadd(4, 108, -9.5, 8.2, sec = self.dend[65]) h.pt3dadd(2.5, 110.5, -9.5, 8.2, sec = self.dend[65]) h.pt3dadd(0.5, 114, -10, 7.5, sec = self.dend[65]) h.pt3dadd(-1, 117, -10, 7.3, sec = self.dend[65]) h.pt3dadd(-3.5, 119.5, -11, 7.1, sec = self.dend[65]) h.pt3dadd(-5.5, 122.5, -9.5, 8.2, sec = self.dend[65]) h.pt3dadd(-5.5, 125.5, -12, 7.7, sec = self.dend[65]) h.pt3dadd(-7.5, 128.5, -11, 7.1, sec = self.dend[65]) h.pt3dadd(-9.5, 131.5, -11, 7.1, sec = self.dend[65]) h.pt3dadd(-11, 135, -11, 7.2, sec = self.dend[65]) h.pt3dadd(-12, 138, -11, 7.6, sec = self.dend[65]) h.pt3dadd(-12, 140.5, -11, 7.3, sec = self.dend[65]) h.pt3dadd(-13.5, 144.5, -9.5, 7.5, sec = self.dend[65]) h.pt3dadd(-14.5, 147.5, -10, 7.3, sec = self.dend[65]) h.pt3dadd(-15.5, 150, -10, 7.8, sec = self.dend[65]) h.pt3dadd(-18, 153, -10, 7.6, sec = self.dend[65]) h.pt3dadd(-18.5, 157.5, -11, 8.1, sec = self.dend[65]) h.pt3dadd(-20, 158.5, -11, 9.3, sec = self.dend[65]) h.pt3dadd(-22.5, 163, -11, 8, sec = self.dend[65]) h.pt3dadd(-25, 166.5, -9.5, 7.9, sec = self.dend[65]) h.pt3dadd(-27, 170, -10, 8.3, sec = self.dend[65]) h.pt3dadd(-27.5, 174, -10, 8.1, sec = self.dend[65]) h.pt3dadd(-31, 178, -10, 9.3, sec = self.dend[65]) h.pt3dadd(-34, 182.5, -11, 10.9, sec = self.dend[65]) h.pt3dadd(-35.5, 185, -12, 10.9, sec = self.dend[65]) h.pt3dclear(sec = self.dend[66]) h.pt3dadd(-35.5, 185, -12, 10.9, sec = self.dend[66]) h.pt3dadd(-42.5, 187.5, -11, 4.3, sec = self.dend[66]) h.pt3dadd(-45, 189.5, -10, 3.8, sec = self.dend[66]) h.pt3dadd(-47, 192.5, -9.5, 2.8, sec = self.dend[66]) h.pt3dadd(-49.5, 193, -10, 1.9, sec = self.dend[66]) h.pt3dadd(-50.5, 196, -9.5, 2.3, sec = self.dend[66]) h.pt3dadd(-53, 199, -9.5, 3.4, sec = self.dend[66]) h.pt3dadd(-53.5, 202, -7.5, 5.4, sec = self.dend[66]) h.pt3dadd(-55, 205.5, -6.5, 5.4, sec = self.dend[66]) h.pt3dadd(-57, 210, -6.5, 5.4, sec = self.dend[66]) h.pt3dadd(-58, 214.5, -9, 1.5, sec = self.dend[66]) h.pt3dadd(-58.5, 217.5, -14.5, 2.2, sec = self.dend[66]) h.pt3dadd(-58.5, 221.5, -12, 3.1, sec = self.dend[66]) h.pt3dadd(-58.5, 224.5, -12, 3.1, sec = self.dend[66]) h.pt3dadd(-59.5, 226.5, -9, 2.4, sec = self.dend[66]) h.pt3dadd(-60, 228, 2, 2.3, sec = self.dend[66]) h.pt3dadd(-60.5, 232, 2, 2.8, sec = self.dend[66]) h.pt3dadd(-60.5, 235.5, 2, 3.3, sec = self.dend[66]) h.pt3dadd(-60.5, 238, 2, 3.3, sec = self.dend[66]) h.pt3dadd(-60.5, 240.5, 2, 3.2, sec = self.dend[66]) h.pt3dadd(-59.5, 242.5, 2, 3.2, sec = self.dend[66]) h.pt3dadd(-57, 247.5, 2, 2.7, sec = self.dend[66]) h.pt3dadd(-56, 249, -1, 3.2, sec = self.dend[66]) h.pt3dadd(-55.5, 254, -1, 3.3, sec = self.dend[66]) h.pt3dadd(-55, 256.5, 2, 3.8, sec = self.dend[66]) h.pt3dadd(-55, 260.5, 2, 3.8, sec = self.dend[66]) h.pt3dadd(-55, 264, 2, 3.8, sec = self.dend[66]) h.pt3dadd(-54.5, 266.5, 2, 3.8, sec = self.dend[66]) h.pt3dadd(-54.5, 268.5, 5, 3.8, sec = self.dend[66]) h.pt3dadd(-54, 269, 7.5, 4, sec = self.dend[66]) h.pt3dadd(-54, 270.5, 13, 4, sec = self.dend[66]) h.pt3dadd(-54.5, 274, 10.5, 3.4, sec = self.dend[66]) h.pt3dadd(-54.5, 276.5, 16, 3.2, sec = self.dend[66]) h.pt3dadd(-54.5, 278, 16, 3.2, sec = self.dend[66]) h.pt3dadd(-54.5, 282, 16, 3.2, sec = self.dend[66]) h.pt3dadd(-54.5, 288, 17.5, 3.1, sec = self.dend[66]) h.pt3dadd(-54.5, 292, 17.5, 3.3, sec = self.dend[66]) h.pt3dadd(-54.5, 295, 20, 3.3, sec = self.dend[66]) h.pt3dadd(-54.5, 299, 20, 3.3, sec = self.dend[66]) h.pt3dadd(-54.5, 301, 20, 3.1, sec = self.dend[66]) h.pt3dadd(-54.5, 303, 21.5, 2.8, sec = self.dend[66]) h.pt3dadd(-55.5, 304.5, 21.5, 2.8, sec = self.dend[66]) h.pt3dadd(-57, 306.5, 21.5, 2.9, sec = self.dend[66]) h.pt3dadd(-54.5, 307, 21.5, 3.3, sec = self.dend[66]) h.pt3dadd(-53.5, 310, 21.5, 3.3, sec = self.dend[66]) h.pt3dadd(-53.5, 313, 21.5, 3.3, sec = self.dend[66]) h.pt3dadd(-55, 315.5, 21.5, 3.3, sec = self.dend[66]) h.pt3dadd(-57, 320.5, 21.5, 3.4, sec = self.dend[66]) h.pt3dadd(-59.5, 324, 21.5, 3.7, sec = self.dend[66]) h.pt3dadd(-61, 326, 21.5, 4.3, sec = self.dend[66]) h.pt3dadd(-62.5, 327.5, 21.5, 4.5, sec = self.dend[66]) h.pt3dadd(-63.5, 330, 21.5, 5.5, sec = self.dend[66]) h.pt3dadd(-65.5, 331.5, 21.5, 4.1, sec = self.dend[66]) h.pt3dadd(-67.5, 334.5, 21.5, 3.8, sec = self.dend[66]) h.pt3dadd(-70, 337, 21.5, 4.3, sec = self.dend[66]) h.pt3dadd(-71.5, 339.5, 21.5, 3.1, sec = self.dend[66]) h.pt3dadd(-72.5, 343, 21.5, 3.5, sec = self.dend[66]) h.pt3dadd(-73, 344.5, 21.5, 4.3, sec = self.dend[66]) h.pt3dadd(-74.5, 347.5, 21.5, 5.2, sec = self.dend[66]) h.pt3dadd(-75, 349.5, 27.5, 4.6, sec = self.dend[66]) h.pt3dadd(-76, 353.5, 30, 4, sec = self.dend[66]) h.pt3dadd(-76.5, 355.5, 31.5, 4.3, sec = self.dend[66]) h.pt3dadd(-78, 359, 30, 4, sec = self.dend[66]) h.pt3dadd(-79.5, 361, 30, 3.5, sec = self.dend[66]) h.pt3dadd(-80, 364, 31.5, 3.7, sec = self.dend[66]) h.pt3dadd(-82.5, 365.5, 30, 3.3, sec = self.dend[66]) h.pt3dadd(-84, 368, 28.5, 3.3, sec = self.dend[66]) h.pt3dadd(-86, 370, 33, 4.2, sec = self.dend[66]) h.pt3dadd(-88.5, 371, 31.5, 4.6, sec = self.dend[66]) h.pt3dadd(-91.5, 372.5, 31.5, 4.6, sec = self.dend[66]) h.pt3dadd(-94.5, 375, 31.5, 4.6, sec = self.dend[66]) h.pt3dadd(-97, 375.5, 31.5, 4.6, sec = self.dend[66]) h.pt3dadd(-100.5, 376, 31.5, 4, sec = self.dend[66]) h.pt3dadd(-103.5, 377, 31.5, 4.1, sec = self.dend[66]) h.pt3dadd(-106.5, 377, 31.5, 4.1, sec = self.dend[66]) h.pt3dadd(-110.5, 377.5, 31.5, 4.1, sec = self.dend[66]) h.pt3dadd(-113, 377, 30, 3.8, sec = self.dend[66]) h.pt3dadd(-118, 377.5, 31.5, 3.8, sec = self.dend[66]) h.pt3dadd(-122.5, 378, 33.5, 2.8, sec = self.dend[66]) h.pt3dadd(-125, 378.5, 33.5, 3.2, sec = self.dend[66]) h.pt3dadd(-127.5, 380, 33.5, 3.2, sec = self.dend[66]) h.pt3dadd(-130, 381, 33.5, 2.5, sec = self.dend[66]) h.pt3dadd(-132, 382.5, 33.5, 2.3, sec = self.dend[66]) h.pt3dadd(-135.5, 382.5, 33.5, 1.9, sec = self.dend[66]) h.pt3dadd(-137.5, 384.5, 35.5, 2.7, sec = self.dend[66]) h.pt3dadd(-141, 384, 35.5, 3.2, sec = self.dend[66]) h.pt3dadd(-144, 383.5, 35.5, 2.8, sec = self.dend[66]) h.pt3dadd(-145.5, 383.5, 35.5, 2.3, sec = self.dend[66]) h.pt3dadd(-146.5, 385, 37, 3.3, sec = self.dend[66]) h.pt3dadd(-147.5, 386, 37, 3.6, sec = self.dend[66]) h.pt3dadd(-149.5, 387.5, 46, 2.9, sec = self.dend[66]) h.pt3dadd(-151, 390, 42.5, 2.9, sec = self.dend[66]) h.pt3dadd(-153.5, 392.5, 46, 2.8, sec = self.dend[66]) h.pt3dadd(-155.5, 395, 46, 3, sec = self.dend[66]) h.pt3dadd(-157.5, 398, 46, 3.3, sec = self.dend[66]) h.pt3dadd(-160.5, 400, 47.5, 3.5, sec = self.dend[66]) h.pt3dadd(-161.5, 402, 47.5, 2, sec = self.dend[66]) h.pt3dadd(-164.5, 399, 47.5, 2, sec = self.dend[66]) h.pt3dadd(-164.5, 401, 47.5, 1.7, sec = self.dend[66]) h.pt3dadd(-165, 402.5, 47.5, 2.2, sec = self.dend[66]) h.pt3dadd(-166, 403, 47.5, 3.8, sec = self.dend[66]) h.pt3dadd(-168.5, 404.5, 47.5, 4.9, sec = self.dend[66]) h.pt3dadd(-172.5, 407.5, 47.5, 1.8, sec = self.dend[66]) h.pt3dadd(-175, 408, 49, 2.5, sec = self.dend[66]) h.pt3dadd(-175, 409, 52, 3.8, sec = self.dend[66]) h.pt3dadd(-176, 410.5, 52, 1.5, sec = self.dend[66]) h.pt3dadd(-177, 412, 53.5, 1.6, sec = self.dend[66]) h.pt3dadd(-178.5, 415, 55, 1.3, sec = self.dend[66]) h.pt3dadd(-181, 415.5, 59.5, 3.1, sec = self.dend[66]) h.pt3dadd(-184, 415, 59.5, 2.3, sec = self.dend[66]) h.pt3dadd(-188, 416, 56.5, 2.2, sec = self.dend[66]) h.pt3dadd(-191, 415.5, 56.5, 1.8, sec = self.dend[66]) h.pt3dadd(-192.5, 414.5, 58, 1.6, sec = self.dend[66]) h.pt3dadd(-195, 417.5, 59.5, 3.1, sec = self.dend[66]) h.pt3dadd(-197, 417.5, 58, 4.7, sec = self.dend[66]) h.pt3dadd(-200, 421, 58, 2.1, sec = self.dend[66]) h.pt3dadd(-201.5, 422.5, 58, 2.4, sec = self.dend[66]) h.pt3dadd(-202, 425, 58, 4.3, sec = self.dend[66]) h.pt3dadd(-206.5, 430.5, 55, 3.8, sec = self.dend[66]) h.pt3dadd(-208.5, 433, 55, 3.3, sec = self.dend[66]) h.pt3dadd(-211, 434, 59.5, 2.8, sec = self.dend[66]) h.pt3dadd(-213, 434, 58, 4.3, sec = self.dend[66]) h.pt3dadd(-217, 437.5, 58, 2.5, sec = self.dend[66]) h.pt3dadd(-221, 437, 58, 3.3, sec = self.dend[66]) h.pt3dadd(-224.5, 436.5, 61, 3.3, sec = self.dend[66]) h.pt3dadd(-229.5, 437.5, 59.5, 3.3, sec = self.dend[66]) h.pt3dadd(-235, 440.5, 63.5, 1.6, sec = self.dend[66]) h.pt3dadd(-238.5, 442.5, 65.5, 1.2, sec = self.dend[66]) h.pt3dadd(-241.5, 442.5, 65.5, 1.2, sec = self.dend[66]) h.pt3dadd(-243.5, 442.5, 63.5, 2.1, sec = self.dend[66]) h.pt3dclear(sec = self.dend[67]) h.pt3dadd(-243.5, 442.5, 63.5, 2.1, sec = self.dend[67]) h.pt3dadd(-245, 442, 57.5, 1.1, sec = self.dend[67]) h.pt3dadd(-247, 441.5, 59.5, 1.1, sec = self.dend[67]) h.pt3dadd(-249, 440, 63.5, 1.4, sec = self.dend[67]) h.pt3dadd(-249, 438, 61.5, 1.1, sec = self.dend[67]) h.pt3dadd(-249.5, 438, 61.5, 0.5, sec = self.dend[67]) h.pt3dadd(-251, 437.5, 61.5, 0.5, sec = self.dend[67]) h.pt3dadd(-252.5, 436, 63.5, 1.3, sec = self.dend[67]) h.pt3dclear(sec = self.dend[68]) h.pt3dadd(-243.5, 442.5, 63.5, 2.1, sec = self.dend[68]) h.pt3dadd(-244, 447, 67.5, 1.5, sec = self.dend[68]) h.pt3dadd(-244, 450.5, 65.5, 1.6, sec = self.dend[68]) h.pt3dadd(-244, 452.5, 65.5, 1.1, sec = self.dend[68]) h.pt3dadd(-244.5, 453.5, 65.5, 0.9, sec = self.dend[68]) h.pt3dadd(-246, 455.5, 67.5, 2.4, sec = self.dend[68]) h.pt3dadd(-248, 457, 67.5, 1.1, sec = self.dend[68]) h.pt3dadd(-249, 458, 67.5, 0.3, sec = self.dend[68]) h.pt3dadd(-249.5, 461.5, 69.5, 1.1, sec = self.dend[68]) h.pt3dadd(-250, 463, 71.5, 1.9, sec = self.dend[68]) h.pt3dadd(-250.5, 465, 71.5, 2.5, sec = self.dend[68]) h.pt3dadd(-251.5, 467, 69.5, 1.9, sec = self.dend[68]) h.pt3dadd(-251.5, 468.5, 69.5, 1.3, sec = self.dend[68]) h.pt3dadd(-251.5, 470, 69.5, 0.7, sec = self.dend[68]) h.pt3dadd(-252.5, 472, 75.5, 1.2, sec = self.dend[68]) h.pt3dadd(-254, 472, 75.5, 0.8, sec = self.dend[68]) h.pt3dadd(-255.5, 474, 73.5, 0.8, sec = self.dend[68]) h.pt3dadd(-255.5, 476.5, 73.5, 0.3, sec = self.dend[68]) h.pt3dadd(-255, 478.5, 73.5, 0.3, sec = self.dend[68]) h.pt3dadd(-256, 480, 77.5, 1.3, sec = self.dend[68]) h.pt3dadd(-257, 482, 85.5, 2.1, sec = self.dend[68]) h.pt3dadd(-257.5, 485, 81.5, 2.1, sec = self.dend[68]) h.pt3dclear(sec = self.dend[69]) h.pt3dadd(-35.5, 185, -12, 10.9, sec = self.dend[69]) h.pt3dadd(-33.5, 190.5, -12, 6.7, sec = self.dend[69]) h.pt3dadd(-33, 194.5, -9.5, 6.2, sec = self.dend[69]) h.pt3dadd(-33, 199.5, -11, 6.7, sec = self.dend[69]) h.pt3dadd(-32.5, 202, -10, 8, sec = self.dend[69]) h.pt3dadd(-30.5, 205, -11, 8, sec = self.dend[69]) h.pt3dadd(-30, 207.5, -11, 7.1, sec = self.dend[69]) h.pt3dadd(-29, 210.5, -11, 6.5, sec = self.dend[69]) h.pt3dadd(-28, 214.5, -11, 5.7, sec = self.dend[69]) h.pt3dadd(-26.5, 218, -12, 5.3, sec = self.dend[69]) h.pt3dadd(-25.5, 220.5, -14, 5.7, sec = self.dend[69]) h.pt3dadd(-24, 222.5, -11, 5.7, sec = self.dend[69]) h.pt3dadd(-23.5, 225.5, -12, 5.7, sec = self.dend[69]) h.pt3dadd(-21.5, 229.5, -13, 7.7, sec = self.dend[69]) h.pt3dclear(sec = self.dend[70]) h.pt3dadd(-21.5, 229.5, -13, 7.7, sec = self.dend[70]) h.pt3dadd(-27, 231.5, -13, 2.3, sec = self.dend[70]) h.pt3dadd(-29, 233, -13, 2.3, sec = self.dend[70]) h.pt3dadd(-29, 235, -13, 2.5, sec = self.dend[70]) h.pt3dadd(-28.5, 237, -13, 2, sec = self.dend[70]) h.pt3dadd(-28.5, 239, -13, 2.1, sec = self.dend[70]) h.pt3dadd(-29, 241, -13, 2.3, sec = self.dend[70]) h.pt3dadd(-30.5, 241.5, -13, 2.8, sec = self.dend[70]) h.pt3dadd(-31, 244.5, -13, 2.8, sec = self.dend[70]) h.pt3dadd(-31, 248, -13, 2.8, sec = self.dend[70]) h.pt3dadd(-33, 246.5, -13, 2.3, sec = self.dend[70]) h.pt3dadd(-35, 247, -13, 2.3, sec = self.dend[70]) h.pt3dadd(-36, 249.5, -13, 2.5, sec = self.dend[70]) h.pt3dadd(-40, 250.5, -13, 2.5, sec = self.dend[70]) h.pt3dadd(-41.5, 249.5, -15, 2.5, sec = self.dend[70]) h.pt3dadd(-43.5, 248.5, -14, 2.5, sec = self.dend[70]) h.pt3dadd(-45.5, 249.5, -15, 2.5, sec = self.dend[70]) h.pt3dadd(-47.5, 247.5, -15, 2.2, sec = self.dend[70]) h.pt3dadd(-50.5, 247.5, -15.5, 2, sec = self.dend[70]) h.pt3dadd(-51, 248, -15.5, 3.1, sec = self.dend[70]) h.pt3dadd(-53.5, 250.5, -15.5, 3.1, sec = self.dend[70]) h.pt3dadd(-55.5, 251.5, -15.5, 3.3, sec = self.dend[70]) h.pt3dadd(-59, 252, -15.5, 3.1, sec = self.dend[70]) h.pt3dadd(-61, 252, -15.5, 2.8, sec = self.dend[70]) h.pt3dadd(-62.5, 254, -15.5, 2.4, sec = self.dend[70]) h.pt3dadd(-65, 256.5, -17.5, 2.4, sec = self.dend[70]) h.pt3dadd(-67, 259, -19.5, 1.6, sec = self.dend[70]) h.pt3dadd(-69, 260, -18.5, 2.4, sec = self.dend[70]) h.pt3dadd(-70.5, 261, -17.5, 2.7, sec = self.dend[70]) h.pt3dadd(-73, 261.5, -20.5, 1.7, sec = self.dend[70]) h.pt3dadd(-75, 261.5, -19.5, 2.8, sec = self.dend[70]) h.pt3dadd(-75.5, 264, -20.5, 2.6, sec = self.dend[70]) h.pt3dadd(-75.5, 264.5, -20.5, 2.6, sec = self.dend[70]) h.pt3dadd(-76.5, 267.5, -20.5, 2.9, sec = self.dend[70]) h.pt3dadd(-76, 270.5, -20.5, 3.3, sec = self.dend[70]) h.pt3dadd(-75, 272, -20.5, 3.6, sec = self.dend[70]) h.pt3dadd(-76.5, 271.5, -23, 3.3, sec = self.dend[70]) h.pt3dadd(-78.5, 272, -23, 3.1, sec = self.dend[70]) h.pt3dadd(-81, 273.5, -23, 2.7, sec = self.dend[70]) h.pt3dadd(-83.5, 275.5, -23, 2.1, sec = self.dend[70]) h.pt3dadd(-85, 275.5, -23, 1.9, sec = self.dend[70]) h.pt3dadd(-87, 275, -25, 1.9, sec = self.dend[70]) h.pt3dadd(-89, 275, -24, 2.1, sec = self.dend[70]) h.pt3dadd(-91.5, 275, -24, 2.4, sec = self.dend[70]) h.pt3dadd(-93, 273.5, -24, 2.4, sec = self.dend[70]) h.pt3dadd(-96.5, 273.5, -24, 2.4, sec = self.dend[70]) h.pt3dadd(-98.5, 273, -24, 1.9, sec = self.dend[70]) h.pt3dadd(-102, 273, -24, 2.7, sec = self.dend[70]) h.pt3dadd(-104.5, 273.5, -22, 2.9, sec = self.dend[70]) h.pt3dadd(-107, 274.5, -25, 3.2, sec = self.dend[70]) h.pt3dadd(-109.5, 274.5, -24, 3.2, sec = self.dend[70]) h.pt3dadd(-112, 274.5, -24, 2, sec = self.dend[70]) h.pt3dadd(-115, 274, -24, 1.6, sec = self.dend[70]) h.pt3dadd(-117.5, 274, -24, 1.2, sec = self.dend[70]) h.pt3dadd(-119, 274, -24, 2, sec = self.dend[70]) h.pt3dadd(-121.5, 276, -24, 1.9, sec = self.dend[70]) h.pt3dadd(-123, 277, -23, 3, sec = self.dend[70]) h.pt3dadd(-124.5, 275, -26, 3.7, sec = self.dend[70]) h.pt3dadd(-121, 275.5, -28, 4.6, sec = self.dend[70]) h.pt3dadd(-121, 278.5, -26.5, 4, sec = self.dend[70]) h.pt3dadd(-123.5, 281, -28, 4, sec = self.dend[70]) h.pt3dadd(-123, 283, -28, 2.8, sec = self.dend[70]) h.pt3dadd(-124, 284.5, -28, 2.7, sec = self.dend[70]) h.pt3dadd(-125.5, 286.5, -28, 2.2, sec = self.dend[70]) h.pt3dadd(-127, 286.5, -28, 1.6, sec = self.dend[70]) h.pt3dadd(-128, 288, -28.5, 1.6, sec = self.dend[70]) h.pt3dadd(-129.5, 289, -28.5, 2, sec = self.dend[70]) h.pt3dadd(-131.5, 289.5, -29, 2.9, sec = self.dend[70]) h.pt3dadd(-133.5, 289.5, -29, 2.9, sec = self.dend[70]) h.pt3dadd(-138, 290.5, -28.5, 2.5, sec = self.dend[70]) h.pt3dadd(-141, 292, -28.5, 2.5, sec = self.dend[70]) h.pt3dadd(-143, 292.5, -28.5, 2.7, sec = self.dend[70]) h.pt3dadd(-146, 293.5, -28.5, 1.6, sec = self.dend[70]) h.pt3dadd(-148.5, 296, -34.5, 1.4, sec = self.dend[70]) h.pt3dadd(-151, 296, -34.5, 1.6, sec = self.dend[70]) h.pt3dadd(-153.5, 297, -34.5, 1.5, sec = self.dend[70]) h.pt3dadd(-156, 298.5, -34.5, 1.5, sec = self.dend[70]) h.pt3dadd(-159, 298.5, -34.5, 1.3, sec = self.dend[70]) h.pt3dadd(-160.5, 297.5, -34.5, 1.3, sec = self.dend[70]) h.pt3dadd(-162.5, 296.5, -34.5, 1.5, sec = self.dend[70]) h.pt3dadd(-164, 295, -34.5, 2.6, sec = self.dend[70]) h.pt3dadd(-166, 293, -34.5, 2.8, sec = self.dend[70]) h.pt3dadd(-169.5, 292, -41, 1.2, sec = self.dend[70]) h.pt3dadd(-170.5, 291, -41, 1, sec = self.dend[70]) h.pt3dadd(-172, 289.5, -41, 1.6, sec = self.dend[70]) h.pt3dadd(-173, 289.5, -34.5, 2.3, sec = self.dend[70]) h.pt3dadd(-174, 289.5, -41, 2.5, sec = self.dend[70]) h.pt3dadd(-176, 289.5, -41, 2.5, sec = self.dend[70]) h.pt3dadd(-178, 290.5, -41, 1.4, sec = self.dend[70]) h.pt3dadd(-178.5, 290.5, -41, 1.4, sec = self.dend[70]) h.pt3dadd(-180.5, 290.5, -41, 2.2, sec = self.dend[70]) h.pt3dadd(-181, 289.5, -41, 2.5, sec = self.dend[70]) h.pt3dadd(-182.5, 289, -41, 2.7, sec = self.dend[70]) h.pt3dadd(-183, 291, -41, 2.7, sec = self.dend[70]) h.pt3dadd(-184, 291.5, -47, 2.5, sec = self.dend[70]) h.pt3dadd(-185.5, 293, -47, 2.4, sec = self.dend[70]) h.pt3dadd(-185.5, 295.5, -47, 2.4, sec = self.dend[70]) h.pt3dadd(-188, 294.5, -47, 2.4, sec = self.dend[70]) h.pt3dadd(-188, 295, -47, 2.4, sec = self.dend[70]) h.pt3dadd(-186, 297.5, -59.5, 2.4, sec = self.dend[70]) h.pt3dadd(-184.5, 297.5, -59.5, 2.4, sec = self.dend[70]) h.pt3dadd(-186.5, 297.5, -59.5, 2, sec = self.dend[70]) h.pt3dadd(-186, 299.5, -57.5, 1.6, sec = self.dend[70]) h.pt3dadd(-188.5, 299.5, -59.5, 0.7, sec = self.dend[70]) h.pt3dadd(-191, 299, -61.5, 0.7, sec = self.dend[70]) h.pt3dadd(-191, 295.5, -63.5, 1.3, sec = self.dend[70]) h.pt3dadd(-191, 294.5, -63.5, 1.4, sec = self.dend[70]) h.pt3dadd(-190, 293.5, -65.5, 2.9, sec = self.dend[70]) h.pt3dadd(-190, 292, -65.5, 3.8, sec = self.dend[70]) h.pt3dadd(-191, 288.5, -65.5, 1.8, sec = self.dend[70]) h.pt3dadd(-194, 288.5, -65.5, 1.4, sec = self.dend[70]) h.pt3dadd(-197.5, 288.5, -73, 1.4, sec = self.dend[70]) h.pt3dadd(-198, 290, -67.5, 1.4, sec = self.dend[70]) h.pt3dadd(-199.5, 290, -71, 1.6, sec = self.dend[70]) h.pt3dadd(-201.5, 291.5, -71, 2, sec = self.dend[70]) h.pt3dadd(-204, 292, -71, 1.3, sec = self.dend[70]) h.pt3dadd(-205, 294, -75, 1.9, sec = self.dend[70]) h.pt3dadd(-206, 294.5, -75, 1.9, sec = self.dend[70]) h.pt3dadd(-209, 296, -71, 1, sec = self.dend[70]) h.pt3dadd(-209.5, 298.5, -71, 1.6, sec = self.dend[70]) h.pt3dadd(-212, 298.5, -75, 2.2, sec = self.dend[70]) h.pt3dadd(-215.5, 299, -75, 1.6, sec = self.dend[70]) h.pt3dadd(-217.5, 298.5, -75, 1.1, sec = self.dend[70]) h.pt3dadd(-219, 298.5, -75, 1.2, sec = self.dend[70]) h.pt3dadd(-220.5, 300.5, -75, 1.7, sec = self.dend[70]) h.pt3dadd(-226, 302, -79, 1.7, sec = self.dend[70]) h.pt3dadd(-229, 302, -90.5, 2.2, sec = self.dend[70]) h.pt3dadd(-230.5, 303.5, -93.5, 1.5, sec = self.dend[70]) h.pt3dadd(-229, 304, -90.5, 1.5, sec = self.dend[70]) h.pt3dadd(-229, 300.5, -90.5, 1.3, sec = self.dend[70]) h.pt3dadd(-229, 297, -96.5, 1.2, sec = self.dend[70]) h.pt3dadd(-228.5, 297, -96.5, 1.5, sec = self.dend[70]) h.pt3dadd(-228.5, 295.5, -93.5, 2, sec = self.dend[70]) h.pt3dadd(-230, 294, -93.5, 1.4, sec = self.dend[70]) h.pt3dadd(-231.5, 295, -99.5, 1.4, sec = self.dend[70]) h.pt3dadd(-232.5, 294, -99.5, 2.1, sec = self.dend[70]) h.pt3dadd(-234.5, 292, -99.5, 2.1, sec = self.dend[70]) h.pt3dadd(-235.5, 290.5, -99.5, 1.3, sec = self.dend[70]) h.pt3dadd(-236.5, 288.5, -105, 1.3, sec = self.dend[70]) h.pt3dadd(-235.5, 286, -105, 1.8, sec = self.dend[70]) h.pt3dadd(-235.5, 284, -108, 1.7, sec = self.dend[70]) h.pt3dadd(-241.5, 283.5, -103, 0.9, sec = self.dend[70]) h.pt3dadd(-243, 283.5, -103, 1.2, sec = self.dend[70]) h.pt3dadd(-244, 282.5, -105.5, 1.1, sec = self.dend[70]) h.pt3dadd(-245, 279.5, -105.5, 1.1, sec = self.dend[70]) h.pt3dadd(-245.5, 278, -110, 2, sec = self.dend[70]) h.pt3dadd(-247.5, 279, -108, 2.3, sec = self.dend[70]) h.pt3dadd(-249.5, 282, -110, 2.3, sec = self.dend[70]) h.pt3dadd(-250, 278.5, -110, 2.3, sec = self.dend[70]) h.pt3dadd(-251, 277, -110, 2.4, sec = self.dend[70]) h.pt3dadd(-252.5, 277, -115, 1.9, sec = self.dend[70]) h.pt3dadd(-252.5, 275, -115, 1.9, sec = self.dend[70]) h.pt3dadd(-251.5, 272.5, -119.5, 1.8, sec = self.dend[70]) h.pt3dclear(sec = self.dend[71]) h.pt3dadd(-251.5, 272.5, -119.5, 1.8, sec = self.dend[71]) h.pt3dadd(-250, 271.5, -117.5, 0.1, sec = self.dend[71]) h.pt3dadd(-248.5, 271, -115, 0.1, sec = self.dend[71]) h.pt3dadd(-247, 270, -119.5, 0.1, sec = self.dend[71]) h.pt3dadd(-246, 268.5, -127, 0.1, sec = self.dend[71]) h.pt3dadd(-245.5, 267, -119.5, 0.1, sec = self.dend[71]) h.pt3dadd(-244.5, 265.5, -124.5, 0.1, sec = self.dend[71]) h.pt3dadd(-243.5, 266, -124.5, 0.9, sec = self.dend[71]) h.pt3dadd(-243.5, 262.5, -129, 0.9, sec = self.dend[71]) h.pt3dadd(-246, 264.5, -129, 1.3, sec = self.dend[71]) h.pt3dclear(sec = self.dend[72]) h.pt3dadd(-251.5, 272.5, -119.5, 1.8, sec = self.dend[72]) h.pt3dadd(-253.5, 271.5, -117.5, 0.7, sec = self.dend[72]) h.pt3dadd(-254.5, 271.5, -117.5, 0.7, sec = self.dend[72]) h.pt3dadd(-255.5, 271.5, -115, 1.4, sec = self.dend[72]) h.pt3dadd(-257, 270, -115, 2.3, sec = self.dend[72]) h.pt3dadd(-257, 268, -119.5, 2, sec = self.dend[72]) h.pt3dadd(-257, 266.5, -119.5, 2, sec = self.dend[72]) h.pt3dadd(-257, 266, -119.5, 0.9, sec = self.dend[72]) h.pt3dadd(-258.5, 265, -119.5, 0.7, sec = self.dend[72]) h.pt3dadd(-256.5, 263.5, -122, 1.2, sec = self.dend[72]) h.pt3dadd(-255.5, 262, -122, 1.6, sec = self.dend[72]) h.pt3dadd(-255.5, 261.5, -122, 1.6, sec = self.dend[72]) h.pt3dadd(-255.5, 259.5, -122, 1.6, sec = self.dend[72]) h.pt3dadd(-257, 258, -122, 1, sec = self.dend[72]) h.pt3dadd(-258, 258, -122, 0.7, sec = self.dend[72]) h.pt3dadd(-259, 258, -122, 0.8, sec = self.dend[72]) h.pt3dadd(-261, 258, -122, 0.8, sec = self.dend[72]) h.pt3dadd(-262.5, 256, -122, 0.7, sec = self.dend[72]) h.pt3dadd(-263.5, 256, -122, 1.2, sec = self.dend[72]) h.pt3dadd(-265, 257, -122, 0.7, sec = self.dend[72]) h.pt3dadd(-267.5, 257, -122, 0.9, sec = self.dend[72]) h.pt3dadd(-269, 257, -127, 1.3, sec = self.dend[72]) h.pt3dadd(-271, 258, -122, 1.5, sec = self.dend[72]) h.pt3dadd(-273, 259, -124.5, 1.7, sec = self.dend[72]) h.pt3dclear(sec = self.dend[73]) h.pt3dadd(-21.5, 229.5, -13, 7.7, sec = self.dend[73]) h.pt3dadd(-19.5, 235, -13, 4.9, sec = self.dend[73]) h.pt3dadd(-16.5, 238.5, -13, 4.4, sec = self.dend[73]) h.pt3dadd(-16, 240.5, -13, 4.6, sec = self.dend[73]) h.pt3dadd(-14.5, 243, -13, 4.7, sec = self.dend[73]) h.pt3dadd(-13.5, 245, -13, 4.7, sec = self.dend[73]) h.pt3dadd(-13.5, 247.5, -13, 4.6, sec = self.dend[73]) h.pt3dadd(-11.5, 250, -13, 4.3, sec = self.dend[73]) h.pt3dadd(-10.5, 253.5, -13, 5.2, sec = self.dend[73]) h.pt3dadd(-8.5, 255, -13, 5.2, sec = self.dend[73]) h.pt3dadd(-7.5, 258, -13, 4.6, sec = self.dend[73]) h.pt3dadd(-5.5, 259.5, -12, 3.7, sec = self.dend[73]) h.pt3dadd(-2.5, 260.5, -12, 4.4, sec = self.dend[73]) h.pt3dadd(0, 264, -12, 4.4, sec = self.dend[73]) h.pt3dadd(1, 266, -13, 4.4, sec = self.dend[73]) h.pt3dadd(3, 266, -13, 4.8, sec = self.dend[73]) h.pt3dadd(5.5, 269.5, -13, 4.1, sec = self.dend[73]) h.pt3dadd(8, 273, -13, 4.8, sec = self.dend[73]) h.pt3dadd(10.5, 275, -13, 4, sec = self.dend[73]) h.pt3dadd(13, 279.5, -11, 4.4, sec = self.dend[73]) h.pt3dadd(15, 283, -11, 4.7, sec = self.dend[73]) h.pt3dadd(17, 283.5, -11, 4.3, sec = self.dend[73]) h.pt3dadd(20, 287, -13, 4.9, sec = self.dend[73]) h.pt3dadd(21.5, 290, -13, 4.2, sec = self.dend[73]) h.pt3dadd(23.5, 293, -13, 4.4, sec = self.dend[73]) h.pt3dadd(24, 295.5, -13, 4.9, sec = self.dend[73]) h.pt3dadd(26, 298.5, -15.5, 4.9, sec = self.dend[73]) h.pt3dadd(26.5, 301.5, -15, 5.2, sec = self.dend[73]) h.pt3dclear(sec = self.dend[74]) h.pt3dadd(26.5, 301.5, -15, 5.2, sec = self.dend[74]) h.pt3dadd(28, 307.5, -15, 2.2, sec = self.dend[74]) h.pt3dadd(28.5, 311.5, -15, 2, sec = self.dend[74]) h.pt3dadd(28.5, 314.5, -15, 2.6, sec = self.dend[74]) h.pt3dadd(29, 317.5, -15, 3, sec = self.dend[74]) h.pt3dadd(30.5, 320, -14, 2.7, sec = self.dend[74]) h.pt3dadd(30, 323, -14, 2.4, sec = self.dend[74]) h.pt3dadd(29.5, 325.5, -12, 2.1, sec = self.dend[74]) h.pt3dadd(29.5, 328, -12, 1.8, sec = self.dend[74]) h.pt3dadd(30.5, 331.5, -12, 2.5, sec = self.dend[74]) h.pt3dadd(31, 333, -9.5, 2.5, sec = self.dend[74]) h.pt3dadd(31, 336.5, -7.5, 2.6, sec = self.dend[74]) h.pt3dadd(31.5, 340.5, -5, 1.5, sec = self.dend[74]) h.pt3dadd(32.5, 342.5, 0.5, 2.1, sec = self.dend[74]) h.pt3dadd(34, 344.5, 0.5, 1.2, sec = self.dend[74]) h.pt3dadd(34, 345.5, 0.5, 0.7, sec = self.dend[74]) h.pt3dadd(34.5, 346.5, 0.5, 0.7, sec = self.dend[74]) h.pt3dadd(35.5, 348, 0.5, 1.3, sec = self.dend[74]) h.pt3dadd(37, 349.5, 0.5, 2.1, sec = self.dend[74]) h.pt3dadd(38.5, 351, 0.5, 1.9, sec = self.dend[74]) h.pt3dadd(39.5, 352.5, 0.5, 1.2, sec = self.dend[74]) h.pt3dadd(41.5, 352.5, 0.5, 0.9, sec = self.dend[74]) h.pt3dadd(43, 354, 0.5, 0.9, sec = self.dend[74]) h.pt3dadd(44, 355, 0.5, 1.5, sec = self.dend[74]) h.pt3dadd(47.5, 358.5, 0.5, 1.7, sec = self.dend[74]) h.pt3dadd(50.5, 361, 0.5, 0.9, sec = self.dend[74]) h.pt3dadd(50.5, 362.5, 0.5, 0.9, sec = self.dend[74]) h.pt3dadd(50.5, 365, 0.5, 1.1, sec = self.dend[74]) h.pt3dadd(51, 366, 0.5, 1.8, sec = self.dend[74]) h.pt3dadd(54, 367.5, 3.5, 2.3, sec = self.dend[74]) h.pt3dadd(55.5, 369.5, 3.5, 2.7, sec = self.dend[74]) h.pt3dadd(57, 371.5, 3.5, 2.2, sec = self.dend[74]) h.pt3dadd(58, 373, 3.5, 1.8, sec = self.dend[74]) h.pt3dadd(59, 374.5, 3.5, 1.6, sec = self.dend[74]) h.pt3dadd(60.5, 376.5, 6, 1.3, sec = self.dend[74]) h.pt3dadd(61.5, 377, 6, 1.1, sec = self.dend[74]) h.pt3dadd(64.5, 379, 6, 1.1, sec = self.dend[74]) h.pt3dadd(66, 379, 6, 1.7, sec = self.dend[74]) h.pt3dadd(67, 381.5, 6, 2.2, sec = self.dend[74]) h.pt3dadd(68.5, 382, 6, 1.7, sec = self.dend[74]) h.pt3dadd(70.5, 385, 6, 0.9, sec = self.dend[74]) h.pt3dadd(72, 385, 6, 0.9, sec = self.dend[74]) h.pt3dadd(73.5, 386, 6, 0.9, sec = self.dend[74]) h.pt3dadd(76, 386.5, 12, 1.7, sec = self.dend[74]) h.pt3dadd(79, 387, 12, 1, sec = self.dend[74]) h.pt3dadd(80.5, 387, 12, 0.8, sec = self.dend[74]) h.pt3dadd(84.5, 387.5, 3.5, 1.4, sec = self.dend[74]) h.pt3dadd(84.5, 389.5, 6, 1.4, sec = self.dend[74]) h.pt3dadd(86.5, 390.5, 3.5, 2.5, sec = self.dend[74]) h.pt3dadd(87.5, 392.5, 3.5, 2.5, sec = self.dend[74]) h.pt3dadd(90, 392.5, 3.5, 1.6, sec = self.dend[74]) h.pt3dadd(91.5, 393, 3.5, 1.2, sec = self.dend[74]) h.pt3dadd(91.5, 394.5, 12, 1.2, sec = self.dend[74]) h.pt3dadd(94.5, 398, 17.5, 1.6, sec = self.dend[74]) h.pt3dadd(96, 399, 12, 1.2, sec = self.dend[74]) h.pt3dadd(98, 401, 12, 1, sec = self.dend[74]) h.pt3dadd(99.5, 403.5, 12, 1, sec = self.dend[74]) h.pt3dadd(103.5, 404, 12, 1.3, sec = self.dend[74]) h.pt3dadd(103.5, 406, 12, 1.3, sec = self.dend[74]) h.pt3dadd(104.5, 408, 13.5, 1.4, sec = self.dend[74]) h.pt3dadd(107, 408, 13.5, 1.4, sec = self.dend[74]) h.pt3dadd(107.5, 407.5, 13.5, 0.9, sec = self.dend[74]) h.pt3dadd(110.5, 407.5, 13.5, 0.9, sec = self.dend[74]) h.pt3dadd(111, 407.5, 12, 0.9, sec = self.dend[74]) h.pt3dadd(112.5, 409, 15, 0.9, sec = self.dend[74]) h.pt3dadd(112.5, 411.5, 15, 0.9, sec = self.dend[74]) h.pt3dadd(115, 411.5, 15, 0.9, sec = self.dend[74]) h.pt3dadd(118, 411.5, 15, 0.9, sec = self.dend[74]) h.pt3dadd(118, 413, 15, 0.9, sec = self.dend[74]) h.pt3dadd(117.5, 414.5, 21, 1, sec = self.dend[74]) h.pt3dadd(119, 415, 21, 1.2, sec = self.dend[74]) h.pt3dadd(121, 417, 21, 1.2, sec = self.dend[74]) h.pt3dadd(122.5, 419, 19.5, 1.2, sec = self.dend[74]) h.pt3dadd(123.5, 419.5, 19.5, 1.6, sec = self.dend[74]) h.pt3dadd(125, 421.5, 18, 1.6, sec = self.dend[74]) h.pt3dadd(127, 423.5, 18, 0.8, sec = self.dend[74]) h.pt3dadd(128, 425, 21, 0.9, sec = self.dend[74]) h.pt3dadd(129.5, 427.5, 21, 0.9, sec = self.dend[74]) h.pt3dadd(130.5, 429, 21, 0.7, sec = self.dend[74]) h.pt3dadd(131, 432, 21, 0.7, sec = self.dend[74]) h.pt3dadd(134, 433.5, 21, 0.5, sec = self.dend[74]) h.pt3dadd(136.5, 434, 21, 0.5, sec = self.dend[74]) h.pt3dadd(138.5, 434, 21, 0.5, sec = self.dend[74]) h.pt3dadd(139.5, 434, 21, 1.6, sec = self.dend[74]) h.pt3dadd(141.5, 434, 21, 2.1, sec = self.dend[74]) h.pt3dadd(142.5, 435, 18, 1.3, sec = self.dend[74]) h.pt3dadd(143.5, 435, 18, 0.6, sec = self.dend[74]) h.pt3dadd(145.5, 436, 18, 0.6, sec = self.dend[74]) h.pt3dadd(147, 439, 22, 0.7, sec = self.dend[74]) h.pt3dadd(148, 440, 22, 0.7, sec = self.dend[74]) h.pt3dadd(153, 442, 21, 0.1, sec = self.dend[74]) h.pt3dadd(152.5, 443, 22, 0.1, sec = self.dend[74]) h.pt3dadd(155, 443, 22, 0.1, sec = self.dend[74]) h.pt3dadd(157.5, 443, 22, 0.1, sec = self.dend[74]) h.pt3dadd(157.5, 445.5, 21, 0.1, sec = self.dend[74]) h.pt3dadd(159.5, 445.5, 21, 0.1, sec = self.dend[74]) h.pt3dadd(162.5, 446.5, 21, 0.1, sec = self.dend[74]) h.pt3dadd(165.5, 448, 21, 0.1, sec = self.dend[74]) h.pt3dadd(167, 449.5, 21, 0.1, sec = self.dend[74]) h.pt3dadd(170.5, 448.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(174.5, 449.5, 36.5, 0.1, sec = self.dend[74]) h.pt3dadd(178.5, 449.5, 35, 0.1, sec = self.dend[74]) h.pt3dadd(181.5, 450, 33.5, 0.1, sec = self.dend[74]) h.pt3dadd(190, 456.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(190, 459, 32, 0.1, sec = self.dend[74]) h.pt3dadd(192.5, 460, 32, 0.1, sec = self.dend[74]) h.pt3dadd(195, 462, 32, 0.1, sec = self.dend[74]) h.pt3dadd(197.5, 463.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(200, 465.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(201.5, 466, 32, 0.1, sec = self.dend[74]) h.pt3dadd(207, 471, 29.5, 0.1, sec = self.dend[74]) h.pt3dadd(210.5, 471, 29.5, 0.1, sec = self.dend[74]) h.pt3dadd(212, 471, 31, 0.1, sec = self.dend[74]) h.pt3dadd(214, 471, 31, 0.1, sec = self.dend[74]) h.pt3dadd(215.5, 473.5, 28, 0.1, sec = self.dend[74]) h.pt3dadd(217.5, 475.5, 31, 0.1, sec = self.dend[74]) h.pt3dadd(221.5, 478.5, 31, 0.1, sec = self.dend[74]) h.pt3dadd(223.5, 481, 31, 0.1, sec = self.dend[74]) h.pt3dadd(226, 483.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(231, 485.5, 33.5, 0.1, sec = self.dend[74]) h.pt3dadd(234, 489.5, 32, 0.1, sec = self.dend[74]) h.pt3dadd(234.5, 493, 32, 0.1, sec = self.dend[74]) h.pt3dadd(235, 495, 32, 0.1, sec = self.dend[74]) h.pt3dadd(238, 500, 28, 0.1, sec = self.dend[74]) h.pt3dadd(238.5, 503.5, 28, 0.1, sec = self.dend[74]) h.pt3dadd(241, 507, 36.5, 0.4, sec = self.dend[74]) h.pt3dadd(241.5, 513, 38, 0.6, sec = self.dend[74]) h.pt3dadd(244, 519, 51, 0.7, sec = self.dend[74]) h.pt3dadd(246, 522, 36.5, 0.6, sec = self.dend[74]) h.pt3dadd(246.5, 526, 36.5, 0.6, sec = self.dend[74]) h.pt3dadd(249, 527, 38, 0.6, sec = self.dend[74]) h.pt3dclear(sec = self.dend[75]) h.pt3dadd(26.5, 301.5, -15, 5.2, sec = self.dend[75]) h.pt3dadd(28, 304, -14, 4.1, sec = self.dend[75]) h.pt3dadd(28.5, 304.5, -16.5, 3.3, sec = self.dend[75]) h.pt3dadd(32, 304.5, -17.5, 3.6, sec = self.dend[75]) h.pt3dadd(34.5, 303, -16.5, 3.8, sec = self.dend[75]) h.pt3dadd(37.5, 303.5, -18.5, 3.8, sec = self.dend[75]) h.pt3dadd(38.5, 307, -18.5, 4.1, sec = self.dend[75]) h.pt3dadd(41.5, 309, -17.5, 3.6, sec = self.dend[75]) h.pt3dadd(43.5, 311.5, -17.5, 3.3, sec = self.dend[75]) h.pt3dadd(45, 313, -17.5, 3.3, sec = self.dend[75]) h.pt3dadd(48.5, 315.5, -19.5, 3.3, sec = self.dend[75]) h.pt3dadd(50, 319.5, -19.5, 3.8, sec = self.dend[75]) h.pt3dadd(51, 322, -19.5, 3.3, sec = self.dend[75]) h.pt3dadd(52, 322, -19.5, 3.5, sec = self.dend[75]) h.pt3dadd(54, 324, -19.5, 3.2, sec = self.dend[75]) h.pt3dadd(55, 324.5, -21, 3.7, sec = self.dend[75]) h.pt3dadd(55.5, 327.5, -22, 4.3, sec = self.dend[75]) h.pt3dadd(56, 327.5, -22, 4.3, sec = self.dend[75]) h.pt3dadd(58, 329.5, -22, 4, sec = self.dend[75]) h.pt3dadd(59, 331, -22, 4, sec = self.dend[75]) h.pt3dadd(60, 332, -23, 4.1, sec = self.dend[75]) h.pt3dadd(61, 334.5, -26.5, 4.4, sec = self.dend[75]) h.pt3dadd(63, 334.5, -25.5, 4.4, sec = self.dend[75]) h.pt3dadd(65.5, 337.5, -26.5, 4.6, sec = self.dend[75]) h.pt3dadd(67, 340.5, -24, 4.2, sec = self.dend[75]) h.pt3dadd(68, 341.5, -24, 3.2, sec = self.dend[75]) h.pt3dadd(69.5, 343.5, -25.5, 2.7, sec = self.dend[75]) h.pt3dadd(70, 343.5, -24, 1.9, sec = self.dend[75]) h.pt3dadd(71, 345, -24, 2.3, sec = self.dend[75]) h.pt3dadd(71, 346.5, -24, 3.1, sec = self.dend[75]) h.pt3dadd(72, 348, -26.5, 3.8, sec = self.dend[75]) h.pt3dadd(74.5, 349.5, -25.5, 2.9, sec = self.dend[75]) h.pt3dadd(76, 351, -25.5, 3.6, sec = self.dend[75]) h.pt3dadd(77.5, 354, -25.5, 3.6, sec = self.dend[75]) h.pt3dadd(78.5, 357, -26.5, 2.8, sec = self.dend[75]) h.pt3dadd(79.5, 359, -26.5, 2.8, sec = self.dend[75]) h.pt3dadd(82, 361, -26.5, 2.8, sec = self.dend[75]) h.pt3dadd(84, 362.5, -26.5, 2.8, sec = self.dend[75]) h.pt3dadd(87, 365, -27.5, 2.8, sec = self.dend[75]) h.pt3dadd(89.5, 366, -28, 4.6, sec = self.dend[75]) h.pt3dadd(90.5, 369.5, -28, 4.4, sec = self.dend[75]) h.pt3dadd(90.5, 372, -29, 3.6, sec = self.dend[75]) h.pt3dadd(91.5, 375, -29, 3.6, sec = self.dend[75]) h.pt3dadd(93, 377.5, -29, 3.8, sec = self.dend[75]) h.pt3dadd(93.5, 380.5, -29.5, 4.1, sec = self.dend[75]) h.pt3dadd(95, 382.5, -29.5, 4.1, sec = self.dend[75]) h.pt3dadd(96, 383, -29.5, 3.4, sec = self.dend[75]) h.pt3dadd(98, 385, -29.5, 3.4, sec = self.dend[75]) h.pt3dadd(99.5, 386.5, -29, 3.9, sec = self.dend[75]) h.pt3dadd(101, 386.5, -29.5, 3.8, sec = self.dend[75]) h.pt3dadd(104, 389, -28, 3.8, sec = self.dend[75]) h.pt3dadd(108.5, 390.5, -29.5, 4.3, sec = self.dend[75]) h.pt3dclear(sec = self.dend[76]) h.pt3dadd(108.5, 390.5, -29.5, 4.3, sec = self.dend[76]) h.pt3dadd(112.5, 393, -27.5, 1.7, sec = self.dend[76]) h.pt3dadd(115.5, 393, -28, 1.7, sec = self.dend[76]) h.pt3dadd(118.5, 395.5, -28, 1.4, sec = self.dend[76]) h.pt3dadd(121.5, 398, -28, 1.4, sec = self.dend[76]) h.pt3dadd(123.5, 398, -28, 1.7, sec = self.dend[76]) h.pt3dadd(126, 400.5, -29, 1.7, sec = self.dend[76]) h.pt3dadd(128, 402.5, -29.5, 1.7, sec = self.dend[76]) h.pt3dadd(130.5, 403, -28, 2.1, sec = self.dend[76]) h.pt3dadd(132.5, 405, -28, 1.9, sec = self.dend[76]) h.pt3dadd(134, 406.5, -27.5, 1.6, sec = self.dend[76]) h.pt3dadd(135.5, 407.5, -27.5, 1.8, sec = self.dend[76]) h.pt3dadd(136.5, 409, -27.5, 2.7, sec = self.dend[76]) h.pt3dadd(137.5, 410, -27, 3.4, sec = self.dend[76]) h.pt3dadd(139.5, 412, -28, 1.8, sec = self.dend[76]) h.pt3dadd(141.5, 413, -27.5, 1.4, sec = self.dend[76]) h.pt3dadd(143.5, 413.5, -27.5, 1.8, sec = self.dend[76]) h.pt3dadd(145.5, 414.5, -29, 2, sec = self.dend[76]) h.pt3dadd(148, 416, -29, 2.2, sec = self.dend[76]) h.pt3dadd(149, 416.5, -25.5, 2, sec = self.dend[76]) h.pt3dadd(150.5, 417, -29, 1.4, sec = self.dend[76]) h.pt3dadd(153, 419, -29.5, 1.4, sec = self.dend[76]) h.pt3dadd(156, 421.5, -27.5, 1.3, sec = self.dend[76]) h.pt3dadd(157.5, 423.5, -27.5, 2.4, sec = self.dend[76]) h.pt3dadd(160.5, 425, -27.5, 3.3, sec = self.dend[76]) h.pt3dadd(163, 427.5, -28, 2, sec = self.dend[76]) h.pt3dadd(167.5, 428.5, -28, 1.6, sec = self.dend[76]) h.pt3dadd(167.5, 430, -28, 1.6, sec = self.dend[76]) h.pt3dadd(170, 431, -28, 1.8, sec = self.dend[76]) h.pt3dadd(173, 432.5, -27.5, 1.4, sec = self.dend[76]) h.pt3dadd(176, 434.5, -27.5, 1.4, sec = self.dend[76]) h.pt3dadd(178, 436, -27.5, 1.8, sec = self.dend[76]) h.pt3dadd(181, 438, -27.5, 2, sec = self.dend[76]) h.pt3dadd(183.5, 439, -27.5, 2, sec = self.dend[76]) h.pt3dadd(185, 440.5, -27.5, 2, sec = self.dend[76]) h.pt3dadd(185, 441.5, -27.5, 2, sec = self.dend[76]) h.pt3dadd(188, 443.5, -27.5, 1.7, sec = self.dend[76]) h.pt3dadd(189, 444.5, -27.5, 1.4, sec = self.dend[76]) h.pt3dadd(190, 446.5, -27.5, 1.3, sec = self.dend[76]) h.pt3dadd(191, 448.5, -26, 1.3, sec = self.dend[76]) h.pt3dadd(193, 448.5, -26, 1.3, sec = self.dend[76]) h.pt3dadd(195.5, 448.5, -26, 1.3, sec = self.dend[76]) h.pt3dadd(197.5, 450.5, -26, 2.1, sec = self.dend[76]) h.pt3dadd(199.5, 451, -26, 2.8, sec = self.dend[76]) h.pt3dadd(201.5, 452.5, -26, 1.8, sec = self.dend[76]) h.pt3dadd(203.5, 454.5, -26, 1.6, sec = self.dend[76]) h.pt3dadd(205.5, 456, -26, 2.1, sec = self.dend[76]) h.pt3dadd(209, 458, -27, 2.1, sec = self.dend[76]) h.pt3dadd(211.5, 458, -25.5, 2.1, sec = self.dend[76]) h.pt3dadd(213.5, 457, -25.5, 1.8, sec = self.dend[76]) h.pt3dadd(216, 457, -25.5, 1.8, sec = self.dend[76]) h.pt3dadd(218.5, 457, -25.5, 2.7, sec = self.dend[76]) h.pt3dadd(221.5, 457, -25.5, 2.8, sec = self.dend[76]) h.pt3dadd(224, 457, -26, 2.1, sec = self.dend[76]) h.pt3dadd(225.5, 457, -26, 1.7, sec = self.dend[76]) h.pt3dadd(228, 457, -26, 1.7, sec = self.dend[76]) h.pt3dadd(230, 457, -26, 1.7, sec = self.dend[76]) h.pt3dadd(234, 458, -26, 1.6, sec = self.dend[76]) h.pt3dadd(235, 458, -26, 2.2, sec = self.dend[76]) h.pt3dadd(237, 457, -26, 2.2, sec = self.dend[76]) h.pt3dadd(241, 459, -26, 1.9, sec = self.dend[76]) h.pt3dadd(244, 459, -26, 2, sec = self.dend[76]) h.pt3dadd(247, 461, -26, 2.4, sec = self.dend[76]) h.pt3dadd(250, 461, -26, 2.4, sec = self.dend[76]) h.pt3dadd(251, 461, -25.5, 1.9, sec = self.dend[76]) h.pt3dadd(253.5, 461, -26, 1.9, sec = self.dend[76]) h.pt3dadd(254.5, 461, -26, 1.5, sec = self.dend[76]) h.pt3dadd(257, 461, -27, 1.1, sec = self.dend[76]) h.pt3dadd(258, 461, -27, 2, sec = self.dend[76]) h.pt3dadd(259, 461, -27, 2.6, sec = self.dend[76]) h.pt3dadd(261.5, 461, -25.5, 0.4, sec = self.dend[76]) h.pt3dadd(263.5, 462, -25.5, 2.2, sec = self.dend[76]) h.pt3dadd(266, 462, -25.5, 2.2, sec = self.dend[76]) h.pt3dadd(269, 462, -25.5, 2.2, sec = self.dend[76]) h.pt3dadd(271.5, 462, -26, 1.2, sec = self.dend[76]) h.pt3dadd(275, 462.5, -26, 1.2, sec = self.dend[76]) h.pt3dadd(276.5, 463, -25.5, 0.7, sec = self.dend[76]) h.pt3dadd(277.5, 465, -26, 1.5, sec = self.dend[76]) h.pt3dadd(280, 466, -26, 1.7, sec = self.dend[76]) h.pt3dadd(282, 467.5, -26, 1.8, sec = self.dend[76]) h.pt3dadd(284.5, 468.5, -26, 1.8, sec = self.dend[76]) h.pt3dadd(286.5, 471, -26, 1.8, sec = self.dend[76]) h.pt3dadd(288.5, 473, -26, 1.8, sec = self.dend[76]) h.pt3dadd(290.5, 476, -26, 1.8, sec = self.dend[76]) h.pt3dadd(290.5, 478.5, -26, 1.8, sec = self.dend[76]) h.pt3dadd(293, 481, -26, 1.1, sec = self.dend[76]) h.pt3dadd(295.5, 482, -25.5, 1.1, sec = self.dend[76]) h.pt3dadd(300.5, 484, -25, 1.1, sec = self.dend[76]) h.pt3dadd(304, 486.5, -26, 1.1, sec = self.dend[76]) h.pt3dadd(308.5, 488, -26, 1.1, sec = self.dend[76]) h.pt3dadd(311.5, 490.5, -25, 1.7, sec = self.dend[76]) h.pt3dadd(313.5, 494, -25, 1.7, sec = self.dend[76]) h.pt3dadd(316, 496, -25.5, 1, sec = self.dend[76]) h.pt3dadd(318, 498.5, -25.5, 1.5, sec = self.dend[76]) h.pt3dadd(319, 501.5, -25.5, 1.7, sec = self.dend[76]) h.pt3dadd(321, 502, -26, 0.7, sec = self.dend[76]) h.pt3dadd(321, 504.5, -26, 1.9, sec = self.dend[76]) h.pt3dadd(322, 506, -26, 1.6, sec = self.dend[76]) h.pt3dadd(324, 509, -26, 2, sec = self.dend[76]) h.pt3dadd(325, 512, -26, 2.1, sec = self.dend[76]) h.pt3dadd(324, 514.5, -26, 1.4, sec = self.dend[76]) h.pt3dadd(324, 517, -26, 1.5, sec = self.dend[76]) h.pt3dadd(324, 519.5, -25.5, 1.7, sec = self.dend[76]) h.pt3dadd(323, 521.5, -26, 1.7, sec = self.dend[76]) h.pt3dadd(323.5, 524.5, -26, 1.7, sec = self.dend[76]) h.pt3dadd(324.5, 525, -22.5, 2, sec = self.dend[76]) h.pt3dadd(325.5, 527.5, -22.5, 1.1, sec = self.dend[76]) h.pt3dadd(325.5, 529.5, -23.5, 1.6, sec = self.dend[76]) h.pt3dadd(325.5, 530, -23.5, 1.9, sec = self.dend[76]) h.pt3dadd(325.5, 532, -22.5, 2.3, sec = self.dend[76]) h.pt3dadd(326.5, 534, -22.5, 1.8, sec = self.dend[76]) h.pt3dadd(326.5, 536, -22.5, 1.6, sec = self.dend[76]) h.pt3dadd(327.5, 537.5, -22.5, 1.8, sec = self.dend[76]) h.pt3dadd(327.5, 539.5, -22.5, 1.8, sec = self.dend[76]) h.pt3dadd(327.5, 542.5, -22.5, 1.9, sec = self.dend[76]) h.pt3dadd(329, 544, -23.5, 1.9, sec = self.dend[76]) h.pt3dadd(329, 546, -21.5, 2.4, sec = self.dend[76]) h.pt3dadd(329, 548, -21.5, 2.1, sec = self.dend[76]) h.pt3dadd(329.5, 550, -21.5, 0.8, sec = self.dend[76]) h.pt3dadd(330.5, 552.5, -18, 1.1, sec = self.dend[76]) h.pt3dadd(331, 554.5, -18, 1.1, sec = self.dend[76]) h.pt3dadd(333, 555.5, -18, 1.1, sec = self.dend[76]) h.pt3dadd(333, 559, -18, 1.2, sec = self.dend[76]) h.pt3dadd(333.5, 560.5, -19, 1.8, sec = self.dend[76]) h.pt3dadd(333.5, 563, -16.5, 2.5, sec = self.dend[76]) h.pt3dadd(335, 565, -19, 2.9, sec = self.dend[76]) h.pt3dadd(335.5, 566.5, -18, 2.3, sec = self.dend[76]) h.pt3dadd(337, 567.5, -16.5, 1.3, sec = self.dend[76]) h.pt3dadd(337, 569.5, -18, 1.1, sec = self.dend[76]) h.pt3dadd(339.5, 571, -18, 1.1, sec = self.dend[76]) h.pt3dadd(339.5, 574, -18, 2, sec = self.dend[76]) h.pt3dadd(339.5, 577, -18, 3.1, sec = self.dend[76]) h.pt3dadd(339.5, 579.5, -16.5, 1.9, sec = self.dend[76]) h.pt3dadd(340, 581.5, -16.5, 0.9, sec = self.dend[76]) h.pt3dadd(341.5, 583.5, -16.5, 0.9, sec = self.dend[76]) h.pt3dadd(343, 585.5, -18, 1.6, sec = self.dend[76]) h.pt3dadd(343, 589.5, -16.5, 1.3, sec = self.dend[76]) h.pt3dadd(343, 591.5, -15.5, 1.4, sec = self.dend[76]) h.pt3dadd(343, 594.5, -15.5, 2.3, sec = self.dend[76]) h.pt3dadd(344, 597, -14.5, 1.6, sec = self.dend[76]) h.pt3dadd(345.5, 601, -14.5, 1.4, sec = self.dend[76]) h.pt3dadd(346, 602, -14.5, 1.4, sec = self.dend[76]) h.pt3dadd(346.5, 604.5, -15.5, 1.4, sec = self.dend[76]) h.pt3dadd(347.5, 607, -15.5, 1.4, sec = self.dend[76]) h.pt3dadd(349.5, 610, -15.5, 1.1, sec = self.dend[76]) h.pt3dadd(351.5, 610, -15.5, 1.1, sec = self.dend[76]) h.pt3dadd(352, 614.5, -15.5, 1.4, sec = self.dend[76]) h.pt3dadd(352, 615.5, -15.5, 1.6, sec = self.dend[76]) h.pt3dadd(354, 618, -14.5, 1.4, sec = self.dend[76]) h.pt3dadd(354, 620, -14.5, 1.8, sec = self.dend[76]) h.pt3dadd(355, 621.5, -15.5, 1.8, sec = self.dend[76]) h.pt3dadd(357, 622, -14.5, 1.8, sec = self.dend[76]) h.pt3dadd(356.5, 625.5, -14.5, 1.5, sec = self.dend[76]) h.pt3dadd(357, 627.5, -11.5, 1.4, sec = self.dend[76]) h.pt3dadd(358, 629.5, -11.5, 1.1, sec = self.dend[76]) h.pt3dadd(359.5, 631, -11.5, 0.9, sec = self.dend[76]) h.pt3dadd(361, 632.5, -11.5, 1, sec = self.dend[76]) h.pt3dadd(361.5, 633.5, -12.5, 0.9, sec = self.dend[76]) h.pt3dadd(363, 635, -13.5, 1.2, sec = self.dend[76]) h.pt3dadd(365, 637.5, -13.5, 1.7, sec = self.dend[76]) h.pt3dadd(365.5, 639.5, -13.5, 2, sec = self.dend[76]) h.pt3dadd(366.5, 640.5, -11.5, 2.1, sec = self.dend[76]) h.pt3dadd(369, 641.5, -11.5, 1.8, sec = self.dend[76]) h.pt3dadd(372, 643, -13.5, 2.1, sec = self.dend[76]) h.pt3dadd(374.5, 644, -13.5, 2.3, sec = self.dend[76]) h.pt3dadd(374.5, 648.5, -10, 1.9, sec = self.dend[76]) h.pt3dadd(374.5, 650, -10, 2, sec = self.dend[76]) h.pt3dadd(374.5, 652, -10, 2, sec = self.dend[76]) h.pt3dadd(376, 654, -8, 1.3, sec = self.dend[76]) h.pt3dadd(376, 655, -8, 1.3, sec = self.dend[76]) h.pt3dadd(375.5, 656.5, -7, 1.8, sec = self.dend[76]) h.pt3dadd(375.5, 657.5, -7, 3, sec = self.dend[76]) h.pt3dadd(375.5, 659, -7, 4.1, sec = self.dend[76]) h.pt3dadd(377, 662, -7, 2.1, sec = self.dend[76]) h.pt3dadd(377.5, 663.5, -7, 1.5, sec = self.dend[76]) h.pt3dadd(379.5, 664.5, -7, 1.4, sec = self.dend[76]) h.pt3dadd(379, 666.5, -7, 1.4, sec = self.dend[76]) h.pt3dadd(379, 668.5, -6.5, 2.1, sec = self.dend[76]) h.pt3dadd(379.5, 671.5, -5.5, 2.8, sec = self.dend[76]) h.pt3dadd(379.5, 673, -6.5, 4, sec = self.dend[76]) h.pt3dadd(379.5, 675, -7, 1.6, sec = self.dend[76]) h.pt3dadd(379.5, 679.5, -7, 1.1, sec = self.dend[76]) h.pt3dadd(379.5, 681.5, -7, 0.9, sec = self.dend[76]) h.pt3dadd(381, 684, -7, 0.9, sec = self.dend[76]) h.pt3dadd(381.5, 686.5, -7, 1, sec = self.dend[76]) h.pt3dadd(381.5, 691.5, -2.5, 1, sec = self.dend[76]) h.pt3dadd(379.5, 694, -4.5, 1, sec = self.dend[76]) h.pt3dadd(379.5, 697.5, -5.5, 1, sec = self.dend[76]) h.pt3dadd(379.5, 700, -5.5, 1, sec = self.dend[76]) h.pt3dadd(379.5, 704, -5.5, 1, sec = self.dend[76]) h.pt3dadd(379.5, 706, -6.5, 1, sec = self.dend[76]) h.pt3dadd(378.5, 706.5, -3.5, 1, sec = self.dend[76]) h.pt3dclear(sec = self.dend[77]) h.pt3dadd(108.5, 390.5, -29.5, 4.3, sec = self.dend[77]) h.pt3dadd(109.5, 395, -30.5, 2.5, sec = self.dend[77]) h.pt3dadd(113.5, 398.5, -29.5, 2.5, sec = self.dend[77]) h.pt3dadd(115, 399, -30.5, 2.4, sec = self.dend[77]) h.pt3dadd(115.5, 401.5, -31, 2.4, sec = self.dend[77]) h.pt3dadd(117, 402, -31, 2.4, sec = self.dend[77]) h.pt3dadd(117, 404.5, -31, 3.2, sec = self.dend[77]) h.pt3dadd(117.5, 408.5, -31, 3.1, sec = self.dend[77]) h.pt3dadd(118.5, 410.5, -31, 2.5, sec = self.dend[77]) h.pt3dadd(119.5, 411, -31, 2.3, sec = self.dend[77]) h.pt3dadd(121, 413, -31, 2.3, sec = self.dend[77]) h.pt3dadd(122, 414.5, -31.5, 2.3, sec = self.dend[77]) h.pt3dadd(122.5, 416.5, -31.5, 2.3, sec = self.dend[77]) h.pt3dadd(123, 418.5, -29.5, 2.5, sec = self.dend[77]) h.pt3dadd(125, 421, -29, 2.5, sec = self.dend[77]) h.pt3dadd(125, 422, -29.5, 3.1, sec = self.dend[77]) h.pt3dadd(126.5, 424, -29.5, 3.1, sec = self.dend[77]) h.pt3dadd(129.5, 425.5, -29.5, 2.8, sec = self.dend[77]) h.pt3dadd(132, 426.5, -29, 2.5, sec = self.dend[77]) h.pt3dadd(133.5, 427, -30.5, 2.3, sec = self.dend[77]) h.pt3dadd(134.5, 427, -30.5, 2.1, sec = self.dend[77]) h.pt3dadd(136, 429, -30.5, 2.3, sec = self.dend[77]) h.pt3dadd(137.5, 431, -31, 2.6, sec = self.dend[77]) h.pt3dadd(138.5, 433.5, -31.5, 2.4, sec = self.dend[77]) h.pt3dadd(140, 436, -31, 2.4, sec = self.dend[77]) h.pt3dadd(139.5, 439, -31, 1.7, sec = self.dend[77]) h.pt3dadd(140, 442, -37, 2.2, sec = self.dend[77]) h.pt3dadd(140, 443.5, -31, 2.5, sec = self.dend[77]) h.pt3dadd(140, 444.5, -31, 2.4, sec = self.dend[77]) h.pt3dadd(141, 445.5, -31, 2.3, sec = self.dend[77]) h.pt3dadd(141, 446, -31, 2.1, sec = self.dend[77]) h.pt3dadd(141, 448, -37, 2, sec = self.dend[77]) h.pt3dadd(141, 450.5, -37, 2.1, sec = self.dend[77]) h.pt3dadd(141.5, 452, -37, 2.1, sec = self.dend[77]) h.pt3dadd(142.5, 452.5, -37, 2.5, sec = self.dend[77]) h.pt3dadd(144, 453, -37, 2.6, sec = self.dend[77]) h.pt3dadd(145, 455, -37, 1.7, sec = self.dend[77]) h.pt3dadd(146, 455, -37, 0.9, sec = self.dend[77]) h.pt3dadd(146.5, 455, -37, 1.6, sec = self.dend[77]) h.pt3dadd(147.5, 455, -37, 1.7, sec = self.dend[77]) h.pt3dadd(148.5, 455, -37, 1.8, sec = self.dend[77]) h.pt3dadd(149.5, 456, -37, 1.7, sec = self.dend[77]) h.pt3dadd(151, 456.5, -37, 2.5, sec = self.dend[77]) h.pt3dadd(152.5, 457, -37, 3.1, sec = self.dend[77]) h.pt3dadd(153.5, 457.5, -37, 2.8, sec = self.dend[77]) h.pt3dadd(155, 457.5, -43.5, 2.2, sec = self.dend[77]) h.pt3dadd(156.5, 457.5, -43.5, 1.7, sec = self.dend[77]) h.pt3dadd(158.5, 457.5, -43.5, 1.7, sec = self.dend[77]) h.pt3dadd(160, 458.5, -43.5, 1.7, sec = self.dend[77]) h.pt3dadd(160, 459.5, -43.5, 2.3, sec = self.dend[77]) h.pt3dadd(160, 462, -43.5, 3.1, sec = self.dend[77]) h.pt3dadd(160.5, 462, -43.5, 3.9, sec = self.dend[77]) h.pt3dadd(162, 465, -43.5, 3.8, sec = self.dend[77]) h.pt3dadd(162, 466.5, -43.5, 3.1, sec = self.dend[77]) h.pt3dadd(162.5, 469, -43.5, 2.4, sec = self.dend[77]) h.pt3dadd(163, 470.5, -43.5, 2.6, sec = self.dend[77]) h.pt3dclear(sec = self.dend[78]) h.pt3dadd(163, 470.5, -43.5, 2.6, sec = self.dend[78]) h.pt3dadd(163.5, 475.5, -49.5, 0.3, sec = self.dend[78]) h.pt3dadd(164.5, 477.5, -49.5, 0.3, sec = self.dend[78]) h.pt3dadd(167, 483.5, -49.5, 0.9, sec = self.dend[78]) h.pt3dadd(168.5, 486.5, -43.5, 1.6, sec = self.dend[78]) h.pt3dadd(169.5, 489.5, -49.5, 1.1, sec = self.dend[78]) h.pt3dadd(171, 490, -49.5, 1.4, sec = self.dend[78]) h.pt3dadd(172, 490, -49.5, 0.6, sec = self.dend[78]) h.pt3dadd(173.5, 490.5, -49.5, 0.6, sec = self.dend[78]) h.pt3dadd(173.5, 493, -49.5, 0.6, sec = self.dend[78]) h.pt3dadd(173.5, 493.5, -49.5, 0.6, sec = self.dend[78]) h.pt3dadd(176.5, 493.5, -49.5, 0.8, sec = self.dend[78]) h.pt3dadd(177.5, 494.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(178, 494.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(180, 495, -49.5, 0.7, sec = self.dend[78]) h.pt3dadd(181.5, 495.5, -49.5, 1.1, sec = self.dend[78]) h.pt3dadd(183, 496, -49.5, 1.2, sec = self.dend[78]) h.pt3dadd(183.5, 497.5, -49.5, 1, sec = self.dend[78]) h.pt3dadd(185, 498, -49.5, 0.9, sec = self.dend[78]) h.pt3dadd(185.5, 499, -49.5, 1.6, sec = self.dend[78]) h.pt3dadd(186.5, 500.5, -49.5, 2.1, sec = self.dend[78]) h.pt3dadd(187.5, 502, -49.5, 1.4, sec = self.dend[78]) h.pt3dadd(188, 502, -49.5, 0.5, sec = self.dend[78]) h.pt3dadd(188.5, 503.5, -43.5, 0.5, sec = self.dend[78]) h.pt3dadd(188.5, 505, -49.5, 0.3, sec = self.dend[78]) h.pt3dadd(191, 509, -56, 0.5, sec = self.dend[78]) h.pt3dadd(192.5, 509, -56, 0.8, sec = self.dend[78]) h.pt3dadd(194.5, 509, -56, 0.8, sec = self.dend[78]) h.pt3dadd(194.5, 511, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(195, 512.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(197.5, 514.5, -62, 0.3, sec = self.dend[78]) h.pt3dadd(197.5, 515, -62, 0.3, sec = self.dend[78]) h.pt3dadd(199, 517, -62, 0.7, sec = self.dend[78]) h.pt3dadd(199.5, 517, -62, 1.1, sec = self.dend[78]) h.pt3dadd(201.5, 518, -62, 1.4, sec = self.dend[78]) h.pt3dadd(202, 520, -62, 0.9, sec = self.dend[78]) h.pt3dadd(202.5, 521.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(203, 521.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(205, 523.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(207.5, 526.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(210, 532, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(211.5, 534.5, -56, 0.3, sec = self.dend[78]) h.pt3dadd(211.5, 539, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212, 542, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212.5, 546, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212.5, 549.5, -56, 0.3, sec = self.dend[78]) h.pt3dadd(214.5, 554, -56, 0.3, sec = self.dend[78]) h.pt3dadd(213.5, 558, -56, 0.3, sec = self.dend[78]) h.pt3dadd(213.5, 562.5, -56, 0.3, sec = self.dend[78]) h.pt3dadd(213.5, 574, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212.5, 577.5, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212.5, 583, -56, 0.3, sec = self.dend[78]) h.pt3dadd(212.5, 585.5, -56, 0.3, sec = self.dend[78]) h.pt3dadd(209.5, 589, -56, 0.3, sec = self.dend[78]) h.pt3dadd(209.5, 592, -56, 0.3, sec = self.dend[78]) h.pt3dadd(208, 596, -56, 1.3, sec = self.dend[78]) h.pt3dadd(208, 598.5, -56, 1.2, sec = self.dend[78]) h.pt3dadd(207.5, 601, -56, 2.1, sec = self.dend[78]) h.pt3dadd(208, 603, -56, 3.4, sec = self.dend[78]) h.pt3dadd(207, 605, -56, 0.3, sec = self.dend[78]) h.pt3dadd(207, 608, -49.5, 0.3, sec = self.dend[78]) h.pt3dadd(206.5, 609.5, -49.5, 2.1, sec = self.dend[78]) h.pt3dadd(206.5, 613, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(206, 614.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(206, 617, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(205, 620, -49.5, 1.2, sec = self.dend[78]) h.pt3dadd(205, 621.5, -49.5, 1.4, sec = self.dend[78]) h.pt3dadd(205, 624, -49.5, 0.8, sec = self.dend[78]) h.pt3dadd(204, 628, -49.5, 0.5, sec = self.dend[78]) h.pt3dadd(204, 631, -49.5, 0.5, sec = self.dend[78]) h.pt3dadd(203, 632.5, -56, 0.8, sec = self.dend[78]) h.pt3dadd(201, 634.5, -49.5, 0.8, sec = self.dend[78]) h.pt3dadd(200.5, 636.5, -49.5, 0.8, sec = self.dend[78]) h.pt3dadd(200, 639, -49.5, 0.8, sec = self.dend[78]) h.pt3dadd(200, 641.5, -56, 2.5, sec = self.dend[78]) h.pt3dadd(199, 643.5, -56, 2.6, sec = self.dend[78]) h.pt3dadd(199, 645.5, -49.5, 1.9, sec = self.dend[78]) h.pt3dadd(198.5, 647.5, -49.5, 1, sec = self.dend[78]) h.pt3dadd(196.5, 650, -56, 0.1, sec = self.dend[78]) h.pt3dadd(196.5, 651.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(196.5, 653, -49.5, 1.5, sec = self.dend[78]) h.pt3dadd(194.5, 656, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194.5, 657.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194, 659, -56, 1.1, sec = self.dend[78]) h.pt3dadd(194, 660.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194, 663, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194, 664, -56, 1.7, sec = self.dend[78]) h.pt3dadd(194, 667, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194, 668.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(194, 670.5, -56, 2.2, sec = self.dend[78]) h.pt3dadd(194.5, 674, -56, 0.1, sec = self.dend[78]) h.pt3dadd(195.5, 676.5, -56, 0.1, sec = self.dend[78]) h.pt3dadd(195.5, 679, -56, 0.1, sec = self.dend[78]) h.pt3dadd(195.5, 680.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(195.5, 683.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(197, 686, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(197, 688.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(195.5, 689.5, -49.5, 1.2, sec = self.dend[78]) h.pt3dadd(195.5, 693.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(195, 696, -43.5, 1, sec = self.dend[78]) h.pt3dadd(195.5, 696, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(198, 699, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(199, 702.5, -49.5, 0.1, sec = self.dend[78]) h.pt3dadd(201.5, 702.5, -43.5, 0.1, sec = self.dend[78]) h.pt3dadd(202.5, 706, -43.5, 0.1, sec = self.dend[78]) h.pt3dclear(sec = self.dend[79]) h.pt3dadd(163, 470.5, -43.5, 2.6, sec = self.dend[79]) h.pt3dadd(163, 473, -43.5, 1.4, sec = self.dend[79]) h.pt3dadd(162.5, 474, -43.5, 1.8, sec = self.dend[79]) h.pt3dadd(162.5, 476, -49.5, 2.5, sec = self.dend[79]) h.pt3dadd(162.5, 477.5, -49.5, 2.5, sec = self.dend[79]) h.pt3dadd(163.5, 481, -49.5, 2.5, sec = self.dend[79]) h.pt3dadd(164.5, 481, -56, 2.9, sec = self.dend[79]) h.pt3dadd(166, 479.5, -49.5, 2.8, sec = self.dend[79]) h.pt3dadd(167.5, 480, -49.5, 0.6, sec = self.dend[79]) h.pt3dadd(169, 480.5, -49.5, 1.6, sec = self.dend[79]) h.pt3dadd(170, 481, -56, 2.2, sec = self.dend[79]) h.pt3dadd(171.5, 482.5, -56, 2.8, sec = self.dend[79]) h.pt3dadd(173, 483, -56, 2.2, sec = self.dend[79]) h.pt3dadd(175, 485.5, -56, 1.2, sec = self.dend[79]) h.pt3dadd(175, 486.5, -56, 1.2, sec = self.dend[79]) h.pt3dadd(175.5, 488, -56, 1.2, sec = self.dend[79]) h.pt3dadd(175.5, 490, -56, 2.3, sec = self.dend[79]) h.pt3dadd(175, 493, -56, 3.2, sec = self.dend[79]) h.pt3dadd(175, 495.5, -56, 3.3, sec = self.dend[79]) h.pt3dadd(176.5, 497.5, -56, 3.3, sec = self.dend[79]) h.pt3dadd(179, 498.5, -56, 3.3, sec = self.dend[79]) h.pt3dadd(181, 501.5, -56, 2.5, sec = self.dend[79]) h.pt3dadd(181, 504, -56, 2.8, sec = self.dend[79]) h.pt3dadd(182, 506.5, -56, 3.1, sec = self.dend[79]) h.pt3dadd(186.5, 510.5, -52, 1.7, sec = self.dend[79]) h.pt3dadd(189.5, 514, -52, 2, sec = self.dend[79]) h.pt3dadd(194.5, 517.5, -52, 2, sec = self.dend[79]) h.pt3dadd(195.5, 519.5, -52, 2.1, sec = self.dend[79]) h.pt3dadd(197.5, 521, -50.5, 2.1, sec = self.dend[79]) h.pt3dadd(200.5, 522.5, -54, 2.6, sec = self.dend[79]) h.pt3dadd(201.5, 524.5, -52, 3.4, sec = self.dend[79]) h.pt3dadd(204.5, 524.5, -48.5, 4.1, sec = self.dend[79]) h.pt3dclear(sec = self.dend[80]) h.pt3dadd(204.5, 524.5, -48.5, 4.1, sec = self.dend[80]) h.pt3dadd(203.5, 532.5, -46.5, 0.1, sec = self.dend[80]) h.pt3dadd(203.5, 535, -46.5, 0.1, sec = self.dend[80]) h.pt3dadd(205.5, 539, -44.5, 0.1, sec = self.dend[80]) h.pt3dadd(206, 545, -33, 0.1, sec = self.dend[80]) h.pt3dadd(206, 550.5, -40.5, 0.1, sec = self.dend[80]) h.pt3dadd(208.5, 558.5, -37, 0.1, sec = self.dend[80]) h.pt3dadd(208.5, 562.5, -37, 0.1, sec = self.dend[80]) h.pt3dadd(208, 567.5, -38.5, 0.1, sec = self.dend[80]) h.pt3dadd(208, 570, -29, 0.1, sec = self.dend[80]) h.pt3dadd(208.5, 575, -29, 0.1, sec = self.dend[80]) h.pt3dadd(212, 578, -25.5, 0.3, sec = self.dend[80]) h.pt3dadd(212.5, 581, -29, 0.3, sec = self.dend[80]) h.pt3dclear(sec = self.dend[81]) h.pt3dadd(204.5, 524.5, -48.5, 4.1, sec = self.dend[81]) h.pt3dadd(208, 526.5, -54, 1.9, sec = self.dend[81]) h.pt3dadd(209.5, 526.5, -54, 1.7, sec = self.dend[81]) h.pt3dadd(213.5, 526.5, -58, 1.9, sec = self.dend[81]) h.pt3dadd(217, 529, -60, 1.6, sec = self.dend[81]) h.pt3dadd(220.5, 533.5, -48.5, 1.1, sec = self.dend[81]) h.pt3dadd(220.5, 538.5, -48.5, 1.1, sec = self.dend[81]) h.pt3dadd(223.5, 544, -48.5, 1.1, sec = self.dend[81]) h.pt3dadd(224, 548.5, -48.5, 1.1, sec = self.dend[81]) h.pt3dadd(227.5, 553, -48.5, 1.1, sec = self.dend[81]) h.pt3dadd(229, 556, -48.5, 0.8, sec = self.dend[81]) h.pt3dadd(231, 563, -46.5, 1.2, sec = self.dend[81]) h.pt3dadd(231.5, 569, -46.5, 1.4, sec = self.dend[81]) h.pt3dadd(233.5, 571, -52, 1.4, sec = self.dend[81]) h.pt3dadd(235, 574, -54, 1.4, sec = self.dend[81]) h.pt3dadd(240, 577, -54, 1.4, sec = self.dend[81]) h.pt3dadd(241, 579.5, -54, 1.4, sec = self.dend[81]) h.pt3dadd(243, 582, -54, 1.4, sec = self.dend[81]) h.pt3dadd(243.5, 586, -56, 1.4, sec = self.dend[81]) h.pt3dadd(243.5, 589, -56, 1.1, sec = self.dend[81]) h.pt3dadd(245.5, 592.5, -56, 1.1, sec = self.dend[81]) h.pt3dadd(245, 594.5, -56, 0.7, sec = self.dend[81]) h.pt3dadd(246.5, 599.5, -56, 0.7, sec = self.dend[81]) h.pt3dadd(248, 604.5, -60, 0.7, sec = self.dend[81]) h.pt3dadd(249.5, 609, -63.5, 1.4, sec = self.dend[81]) h.pt3dadd(252.5, 611.5, -56, 1.3, sec = self.dend[81]) h.pt3dadd(252.5, 615, -56, 1.9, sec = self.dend[81]) h.pt3dadd(255, 617.5, -56, 2.5, sec = self.dend[81]) h.pt3dadd(256, 619.5, -56, 2.4, sec = self.dend[81]) h.pt3dadd(257.5, 622, -56, 0.2, sec = self.dend[81]) h.pt3dadd(260.5, 625.5, -56, 0.2, sec = self.dend[81]) h.pt3dadd(262, 625.5, -54, 1.2, sec = self.dend[81]) h.pt3dadd(261, 628.5, -54, 1.8, sec = self.dend[81]) h.pt3dadd(262, 630.5, -54, 2.1, sec = self.dend[81]) h.pt3dadd(267, 631.5, -52, 2.1, sec = self.dend[81]) h.pt3dadd(269, 633, -50.5, 0.2, sec = self.dend[81]) h.pt3dadd(271, 635.5, -56, 0.2, sec = self.dend[81]) h.pt3dadd(273, 639.5, -56, 0.3, sec = self.dend[81]) h.pt3dadd(274, 643, -56, 0.3, sec = self.dend[81]) h.pt3dadd(276.5, 644.5, -50.5, 0.4, sec = self.dend[81]) h.pt3dadd(281, 649.5, -54, 0.3, sec = self.dend[81]) h.pt3dadd(283.5, 654.5, -56, 0.2, sec = self.dend[81]) h.pt3dadd(287.5, 660.5, -54, 0.2, sec = self.dend[81]) h.pt3dadd(287.5, 665, -54, 0.2, sec = self.dend[81]) h.pt3dadd(289.5, 671.5, -62, 0.3, sec = self.dend[81]) h.pt3dadd(291.5, 677, -62, 0.3, sec = self.dend[81]) h.pt3dadd(295, 682.5, -62, 0.3, sec = self.dend[81]) h.pt3dadd(295.5, 683, -58, 0.1, sec = self.dend[81]) h.pt3dadd(295.5, 686.5, -52, 0.2, sec = self.dend[81]) h.pt3dadd(298.5, 692, -52, 0.2, sec = self.dend[81]) h.pt3dadd(298.5, 696.5, -63.5, 0.2, sec = self.dend[81]) h.pt3dadd(299, 699, -62, 0.2, sec = self.dend[81]) h.pt3dadd(301.5, 701, -62, 0.2, sec = self.dend[81]) h.pt3dadd(303, 703.5, -58, 1.9, sec = self.dend[81]) h.pt3dadd(305, 709, -58, 1.7, sec = self.dend[81]) h.pt3dadd(307, 715.5, -58, 0.2, sec = self.dend[81]) h.pt3dadd(307.5, 719.5, -63.5, 0.2, sec = self.dend[81]) h.pt3dadd(310.5, 721.5, -63.5, 1.1, sec = self.dend[81]) h.pt3dadd(312, 724.5, -63.5, 1.1, sec = self.dend[81]) h.pt3dadd(315.5, 727.5, -67.5, 0.3, sec = self.dend[81]) h.pt3dadd(319.5, 733.5, -62, 0.4, sec = self.dend[81]) h.pt3dadd(323.5, 737.5, -63.5, 0.4, sec = self.dend[81]) h.pt3dadd(327.5, 741, -65.5, 0.4, sec = self.dend[81]) h.pt3dclear(sec = self.dend[82]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[82]) h.pt3dadd(65, 37, -4, 6.6, sec = self.dend[82]) h.pt3dadd(68, 35.5, -3, 6.6, sec = self.dend[82]) h.pt3dadd(67.5, 31.5, -3, 6.5, sec = self.dend[82]) h.pt3dadd(67.5, 28.5, -3, 6.2, sec = self.dend[82]) h.pt3dadd(70.5, 26, -4, 5.7, sec = self.dend[82]) h.pt3dadd(75.5, 27, 1.5, 6.1, sec = self.dend[82]) h.pt3dadd(81, 29.5, 1.5, 6.1, sec = self.dend[82]) h.pt3dadd(85.5, 31, 7, 6.1, sec = self.dend[82]) h.pt3dadd(87.5, 34.5, 10, 6.3, sec = self.dend[82]) h.pt3dadd(91.5, 36.5, 10, 6.3, sec = self.dend[82]) h.pt3dadd(94.5, 38, 10, 6, sec = self.dend[82]) h.pt3dadd(97.5, 39.5, 10, 5.7, sec = self.dend[82]) h.pt3dadd(99, 41.5, 12.5, 5, sec = self.dend[82]) h.pt3dadd(101, 43, 12.5, 5.7, sec = self.dend[82]) h.pt3dadd(103, 45, 15.5, 5.6, sec = self.dend[82]) h.pt3dadd(105, 47.5, 17, 5.4, sec = self.dend[82]) h.pt3dadd(108.5, 48.5, 21.5, 4.9, sec = self.dend[82]) h.pt3dadd(111.5, 48.5, 15.5, 5.3, sec = self.dend[82]) h.pt3dadd(114, 49, 15.5, 6.1, sec = self.dend[82]) h.pt3dadd(116.5, 52.5, 15.5, 6.1, sec = self.dend[82]) h.pt3dadd(119.5, 52.5, 15.5, 5.6, sec = self.dend[82]) h.pt3dadd(122.5, 53, 15.5, 6.1, sec = self.dend[82]) h.pt3dadd(126, 53, 15.5, 7.1, sec = self.dend[82]) h.pt3dadd(128, 54.5, 15.5, 8, sec = self.dend[82]) h.pt3dclear(sec = self.dend[83]) h.pt3dadd(128, 54.5, 15.5, 8, sec = self.dend[83]) h.pt3dadd(132, 50, 21.5, 1.7, sec = self.dend[83]) h.pt3dadd(134.5, 49.5, 20, 1.9, sec = self.dend[83]) h.pt3dadd(137, 47.5, 20, 1.6, sec = self.dend[83]) h.pt3dadd(139, 46, 20, 1.6, sec = self.dend[83]) h.pt3dadd(140.5, 45.5, 18.5, 1.6, sec = self.dend[83]) h.pt3dadd(142, 44, 18.5, 2, sec = self.dend[83]) h.pt3dadd(143.5, 42, 18.5, 2.6, sec = self.dend[83]) h.pt3dadd(146, 41.5, 18.5, 1.8, sec = self.dend[83]) h.pt3dadd(147, 40, 17, 1.7, sec = self.dend[83]) h.pt3dadd(149.5, 40, 17, 1.8, sec = self.dend[83]) h.pt3dadd(151.5, 39, 17, 1.7, sec = self.dend[83]) h.pt3dadd(153.5, 38.5, 15.5, 1.7, sec = self.dend[83]) h.pt3dadd(156.5, 36.5, 15.5, 2.2, sec = self.dend[83]) h.pt3dadd(159, 36, 15.5, 2.4, sec = self.dend[83]) h.pt3dadd(162, 34.5, 15.5, 3.4, sec = self.dend[83]) h.pt3dadd(164.5, 33.5, 15.5, 2.7, sec = self.dend[83]) h.pt3dadd(167.5, 33.5, 15.5, 2.1, sec = self.dend[83]) h.pt3dadd(170, 32.5, 14, 1.9, sec = self.dend[83]) h.pt3dadd(175, 32.5, 12.5, 2.3, sec = self.dend[83]) h.pt3dadd(177.5, 32, 11.5, 2.8, sec = self.dend[83]) h.pt3dadd(181.5, 30.5, 11.5, 2.8, sec = self.dend[83]) h.pt3dadd(183.5, 29, 11.5, 1.7, sec = self.dend[83]) h.pt3dadd(185.5, 28.5, 7, 1.3, sec = self.dend[83]) h.pt3dadd(191.5, 26, 7, 1.1, sec = self.dend[83]) h.pt3dadd(193.5, 26, 7, 1.4, sec = self.dend[83]) h.pt3dadd(200, 26.5, 5.5, 1.6, sec = self.dend[83]) h.pt3dadd(205.5, 25, 3, 3.6, sec = self.dend[83]) h.pt3dadd(208.5, 23.5, 0, 3.4, sec = self.dend[83]) h.pt3dadd(210.5, 22.5, 0, 3.1, sec = self.dend[83]) h.pt3dadd(212, 21.5, -2.5, 1.9, sec = self.dend[83]) h.pt3dadd(213, 21.5, -2.5, 1.7, sec = self.dend[83]) h.pt3dadd(216, 20, 0, 1.5, sec = self.dend[83]) h.pt3dadd(218, 20, 0, 1.5, sec = self.dend[83]) h.pt3dadd(218.5, 20, 0, 2.1, sec = self.dend[83]) h.pt3dadd(220.5, 21, 0, 2.4, sec = self.dend[83]) h.pt3dadd(223, 21, 0, 2, sec = self.dend[83]) h.pt3dadd(227, 21, 0, 2, sec = self.dend[83]) h.pt3dadd(228, 21, 0, 2.4, sec = self.dend[83]) h.pt3dadd(232, 21, 0, 3.2, sec = self.dend[83]) h.pt3dadd(236, 21, -2.5, 2.3, sec = self.dend[83]) h.pt3dadd(239, 21, -8.5, 1.6, sec = self.dend[83]) h.pt3dadd(241.5, 21, -8.5, 1.4, sec = self.dend[83]) h.pt3dadd(243.5, 21, -8.5, 2, sec = self.dend[83]) h.pt3dadd(245.5, 23, -5.5, 2.7, sec = self.dend[83]) h.pt3dadd(247.5, 23.5, -5.5, 3.7, sec = self.dend[83]) h.pt3dadd(251, 24.5, -8.5, 2.3, sec = self.dend[83]) h.pt3dadd(254, 24.5, -8.5, 1.6, sec = self.dend[83]) h.pt3dadd(257.5, 24.5, 0, 1, sec = self.dend[83]) h.pt3dadd(260.5, 26.5, -2.5, 0.5, sec = self.dend[83]) h.pt3dadd(265.5, 27, -2.5, 0.5, sec = self.dend[83]) h.pt3dadd(269.5, 27, -2.5, 0.1, sec = self.dend[83]) h.pt3dadd(272, 27.5, -2.5, 0.1, sec = self.dend[83]) h.pt3dadd(275.5, 28, -2.5, 1.3, sec = self.dend[83]) h.pt3dadd(282, 30.5, -5.5, 1.4, sec = self.dend[83]) h.pt3dadd(286, 30.5, -5.5, 1.6, sec = self.dend[83]) h.pt3dadd(288.5, 31.5, 0, 1.3, sec = self.dend[83]) h.pt3dadd(291.5, 33.5, -2.5, 0.8, sec = self.dend[83]) h.pt3dadd(294, 33.5, -2.5, 1.5, sec = self.dend[83]) h.pt3dadd(295.5, 33, -5.5, 3.1, sec = self.dend[83]) h.pt3dadd(298, 33, -2.5, 3.8, sec = self.dend[83]) h.pt3dadd(301, 33, 0, 2.4, sec = self.dend[83]) h.pt3dadd(303, 33, 0, 1.5, sec = self.dend[83]) h.pt3dadd(304, 32, 0, 1, sec = self.dend[83]) h.pt3dadd(307.5, 32, 0, 1.2, sec = self.dend[83]) h.pt3dadd(309, 33, -2.5, 1.7, sec = self.dend[83]) h.pt3dadd(312, 33.5, -2.5, 3.4, sec = self.dend[83]) h.pt3dadd(313.5, 33.5, -2.5, 5.7, sec = self.dend[83]) h.pt3dadd(317.5, 34, -8.5, 2.3, sec = self.dend[83]) h.pt3dadd(320, 34, -8.5, 1.8, sec = self.dend[83]) h.pt3dadd(322.5, 34.5, -5.5, 1.7, sec = self.dend[83]) h.pt3dadd(326, 34.5, -5.5, 1.8, sec = self.dend[83]) h.pt3dadd(328.5, 34.5, -11, 0.7, sec = self.dend[83]) h.pt3dadd(330, 34.5, -11, 0.7, sec = self.dend[83]) h.pt3dadd(331, 34.5, -5.5, 2.6, sec = self.dend[83]) h.pt3dadd(334, 34.5, -2.5, 4.3, sec = self.dend[83]) h.pt3dadd(337, 35.5, -5.5, 4, sec = self.dend[83]) h.pt3dadd(340.5, 35.5, -5.5, 2.5, sec = self.dend[83]) h.pt3dadd(346, 36, -5.5, 1.9, sec = self.dend[83]) h.pt3dadd(348, 37, -8.5, 1.2, sec = self.dend[83]) h.pt3dadd(351, 38, -8.5, 0.4, sec = self.dend[83]) h.pt3dadd(355.5, 39, -8.5, 0.4, sec = self.dend[83]) h.pt3dadd(359.5, 40.5, -11, 0.5, sec = self.dend[83]) h.pt3dadd(367, 46, -11, 1.3, sec = self.dend[83]) h.pt3dclear(sec = self.dend[84]) h.pt3dadd(128, 54.5, 15.5, 8, sec = self.dend[84]) h.pt3dadd(131, 57.5, 15.5, 5.7, sec = self.dend[84]) h.pt3dadd(133.5, 60.5, 15.5, 5.7, sec = self.dend[84]) h.pt3dadd(135.5, 63.5, 15.5, 5.7, sec = self.dend[84]) h.pt3dadd(138, 65.5, 15.5, 5.8, sec = self.dend[84]) h.pt3dadd(141, 68, 17, 6.2, sec = self.dend[84]) h.pt3dadd(143.5, 71.5, 17, 6.1, sec = self.dend[84]) h.pt3dadd(145, 72, 17, 6.2, sec = self.dend[84]) h.pt3dadd(147.5, 75, 17, 6.2, sec = self.dend[84]) h.pt3dadd(149, 78.5, 18.5, 5.5, sec = self.dend[84]) h.pt3dadd(152, 81.5, 22.5, 5.5, sec = self.dend[84]) h.pt3dadd(154.5, 84.5, 20, 6.2, sec = self.dend[84]) h.pt3dadd(156, 86, 22.5, 7.1, sec = self.dend[84]) h.pt3dadd(157, 88, 22.5, 8.1, sec = self.dend[84]) h.pt3dclear(sec = self.dend[85]) h.pt3dadd(157, 88, 22.5, 8.1, sec = self.dend[85]) h.pt3dadd(156, 93, 22.5, 3.2, sec = self.dend[85]) h.pt3dadd(156, 95.5, 22.5, 3.2, sec = self.dend[85]) h.pt3dadd(155.5, 97.5, 22.5, 3.4, sec = self.dend[85]) h.pt3dadd(155.5, 101, 22.5, 3.7, sec = self.dend[85]) h.pt3dadd(156.5, 103.5, 22.5, 3.7, sec = self.dend[85]) h.pt3dadd(156.5, 105.5, 22.5, 3.3, sec = self.dend[85]) h.pt3dadd(158, 110, 22.5, 3.3, sec = self.dend[85]) h.pt3dadd(158, 111.5, 22.5, 3.3, sec = self.dend[85]) h.pt3dadd(159, 114, 21.5, 3.4, sec = self.dend[85]) h.pt3dadd(159, 116, 21.5, 3.4, sec = self.dend[85]) h.pt3dadd(159, 118.5, 21.5, 3.4, sec = self.dend[85]) h.pt3dadd(159, 121.5, 21.5, 3.4, sec = self.dend[85]) h.pt3dadd(158.5, 124, 20, 3.4, sec = self.dend[85]) h.pt3dadd(158, 128, 20, 3.4, sec = self.dend[85]) h.pt3dadd(158, 131, 20, 2.9, sec = self.dend[85]) h.pt3dadd(157.5, 134.5, 20, 3, sec = self.dend[85]) h.pt3dadd(157.5, 137.5, 20, 3.2, sec = self.dend[85]) h.pt3dadd(157, 139.5, 27, 2.6, sec = self.dend[85]) h.pt3dadd(157.5, 141.5, 28.5, 1.7, sec = self.dend[85]) h.pt3dadd(158, 144.5, 30, 1.9, sec = self.dend[85]) h.pt3dadd(158, 145.5, 31.5, 2.8, sec = self.dend[85]) h.pt3dadd(157, 151, 32.5, 3.7, sec = self.dend[85]) h.pt3dadd(157, 155, 34, 3.4, sec = self.dend[85]) h.pt3dadd(157.5, 158.5, 36, 3.4, sec = self.dend[85]) h.pt3dadd(158, 162, 36, 3, sec = self.dend[85]) h.pt3dadd(157.5, 164, 38, 2.5, sec = self.dend[85]) h.pt3dadd(157.5, 166.5, 41.5, 2.2, sec = self.dend[85]) h.pt3dadd(157.5, 168.5, 41.5, 2.7, sec = self.dend[85]) h.pt3dadd(157.5, 170, 43, 2.7, sec = self.dend[85]) h.pt3dadd(157.5, 173, 43, 2.7, sec = self.dend[85]) h.pt3dadd(157.5, 175, 43, 2.5, sec = self.dend[85]) h.pt3dadd(157, 176.5, 43, 2.5, sec = self.dend[85]) h.pt3dadd(156, 180, 43, 3.6, sec = self.dend[85]) h.pt3dadd(157, 181, 43, 3.3, sec = self.dend[85]) h.pt3dadd(157.5, 183, 43, 3.4, sec = self.dend[85]) h.pt3dadd(158.5, 184.5, 43, 3.4, sec = self.dend[85]) h.pt3dadd(159, 186.5, 43, 3.1, sec = self.dend[85]) h.pt3dadd(159.5, 187, 43, 2.7, sec = self.dend[85]) h.pt3dadd(159.5, 188.5, 45, 2.4, sec = self.dend[85]) h.pt3dadd(160, 190, 45, 2.3, sec = self.dend[85]) h.pt3dadd(161, 192.5, 39.5, 2.3, sec = self.dend[85]) h.pt3dadd(162, 195, 39.5, 2.3, sec = self.dend[85]) h.pt3dadd(162.5, 196, 41.5, 2.4, sec = self.dend[85]) h.pt3dadd(162.5, 198, 41.5, 2.5, sec = self.dend[85]) h.pt3dadd(163.5, 198, 41.5, 2, sec = self.dend[85]) h.pt3dadd(165, 200, 41.5, 2, sec = self.dend[85]) h.pt3dadd(165.5, 201.5, 41.5, 2, sec = self.dend[85]) h.pt3dadd(166, 203.5, 41.5, 2.5, sec = self.dend[85]) h.pt3dadd(166, 205, 41.5, 2.6, sec = self.dend[85]) h.pt3dadd(165.5, 208, 41.5, 2.7, sec = self.dend[85]) h.pt3dadd(164, 210.5, 43, 2.5, sec = self.dend[85]) h.pt3dadd(163, 213, 43, 2.2, sec = self.dend[85]) h.pt3dadd(162.5, 214.5, 46.5, 2, sec = self.dend[85]) h.pt3dadd(162, 216.5, 46.5, 1.1, sec = self.dend[85]) h.pt3dadd(162, 219, 46.5, 1.6, sec = self.dend[85]) h.pt3dadd(162.5, 220.5, 46.5, 2.1, sec = self.dend[85]) h.pt3dadd(162.5, 222.5, 46.5, 2.6, sec = self.dend[85]) h.pt3dadd(162.5, 224.5, 46.5, 3.2, sec = self.dend[85]) h.pt3dadd(163.5, 228, 46.5, 3.3, sec = self.dend[85]) h.pt3dadd(164, 230, 46.5, 3.5, sec = self.dend[85]) h.pt3dadd(164.5, 233, 46.5, 2.8, sec = self.dend[85]) h.pt3dadd(164.5, 235.5, 46.5, 2.5, sec = self.dend[85]) h.pt3dadd(164.5, 238.5, 46.5, 2.1, sec = self.dend[85]) h.pt3dadd(165, 241.5, 48.5, 2.7, sec = self.dend[85]) h.pt3dadd(165, 243, 50.5, 1.2, sec = self.dend[85]) h.pt3dadd(165, 246, 50.5, 1, sec = self.dend[85]) h.pt3dadd(164, 248, 50.5, 1, sec = self.dend[85]) h.pt3dadd(162.5, 250.5, 45, 1.4, sec = self.dend[85]) h.pt3dadd(162.5, 253, 46.5, 1.6, sec = self.dend[85]) h.pt3dadd(163, 256, 48.5, 1.4, sec = self.dend[85]) h.pt3dadd(163.5, 257.5, 48.5, 1.4, sec = self.dend[85]) h.pt3dadd(164.5, 259, 48.5, 1.4, sec = self.dend[85]) h.pt3dadd(164.5, 261, 50.5, 2.5, sec = self.dend[85]) h.pt3dadd(164.5, 261, 52, 3.3, sec = self.dend[85]) h.pt3dadd(166.5, 264, 52, 1.6, sec = self.dend[85]) h.pt3dadd(167, 265.5, 52, 1.1, sec = self.dend[85]) h.pt3dadd(169, 267.5, 52, 1.1, sec = self.dend[85]) h.pt3dadd(169.5, 268, 54, 1.8, sec = self.dend[85]) h.pt3dadd(169.5, 269, 54, 1.9, sec = self.dend[85]) h.pt3dadd(170, 269.5, 55.5, 1.6, sec = self.dend[85]) h.pt3dadd(170.5, 271.5, 54, 1.6, sec = self.dend[85]) h.pt3dadd(172.5, 272.5, 55.5, 1.3, sec = self.dend[85]) h.pt3dadd(172.5, 274.5, 55.5, 1.3, sec = self.dend[85]) h.pt3dadd(171.5, 277, 55.5, 1.9, sec = self.dend[85]) h.pt3dadd(171.5, 278.5, 55.5, 2.7, sec = self.dend[85]) h.pt3dadd(171, 281.5, 55.5, 2.1, sec = self.dend[85]) h.pt3dadd(169.5, 285, 55.5, 1.5, sec = self.dend[85]) h.pt3dadd(169.5, 286.5, 55.5, 0.9, sec = self.dend[85]) h.pt3dadd(166.5, 289.5, 55.5, 0.8, sec = self.dend[85]) h.pt3dadd(166.5, 291, 55.5, 0.8, sec = self.dend[85]) h.pt3dadd(167, 293, 54, 3.4, sec = self.dend[85]) h.pt3dadd(167, 295.5, 55.5, 2.7, sec = self.dend[85]) h.pt3dadd(167.5, 297.5, 55.5, 1.3, sec = self.dend[85]) h.pt3dadd(168.5, 299, 55.5, 1.3, sec = self.dend[85]) h.pt3dadd(170, 300, 55.5, 1.5, sec = self.dend[85]) h.pt3dadd(170, 301.5, 55.5, 1.4, sec = self.dend[85]) h.pt3dadd(171.5, 304, 55.5, 1.4, sec = self.dend[85]) h.pt3dadd(173, 305, 55.5, 1.4, sec = self.dend[85]) h.pt3dadd(171.5, 310, 58.5, 1.4, sec = self.dend[85]) h.pt3dadd(169.5, 313, 58.5, 1.5, sec = self.dend[85]) h.pt3dadd(169.5, 314, 58.5, 0.8, sec = self.dend[85]) h.pt3dadd(167.5, 317, 60, 0.5, sec = self.dend[85]) h.pt3dadd(169.5, 319.5, 60, 0.5, sec = self.dend[85]) h.pt3dadd(168.5, 322.5, 60, 0.6, sec = self.dend[85]) h.pt3dadd(169.5, 325, 60, 0.6, sec = self.dend[85]) h.pt3dadd(168, 326.5, 61.5, 0.6, sec = self.dend[85]) h.pt3dadd(167.5, 329, 60, 0.6, sec = self.dend[85]) h.pt3dadd(167.5, 331, 63, 2.2, sec = self.dend[85]) h.pt3dadd(166.5, 334, 63, 1.2, sec = self.dend[85]) h.pt3dadd(164, 337.5, 63, 1.2, sec = self.dend[85]) h.pt3dadd(164, 340.5, 64.5, 0.7, sec = self.dend[85]) h.pt3dadd(164.5, 344, 64.5, 0.7, sec = self.dend[85]) h.pt3dadd(162.5, 345, 64.5, 1.4, sec = self.dend[85]) h.pt3dadd(162, 348, 64.5, 1.4, sec = self.dend[85]) h.pt3dadd(160, 351.5, 64.5, 1.7, sec = self.dend[85]) h.pt3dadd(161, 355.5, 64.5, 2, sec = self.dend[85]) h.pt3dadd(161, 359, 64.5, 1.5, sec = self.dend[85]) h.pt3dadd(162.5, 361.5, 66, 1.2, sec = self.dend[85]) h.pt3dadd(164, 362.5, 66, 2, sec = self.dend[85]) h.pt3dadd(163, 365.5, 60, 1.3, sec = self.dend[85]) h.pt3dadd(165, 368, 61.5, 1.3, sec = self.dend[85]) h.pt3dadd(167, 369.5, 61.5, 1.3, sec = self.dend[85]) h.pt3dadd(169, 371, 60, 1.4, sec = self.dend[85]) h.pt3dadd(171.5, 372, 60, 1.4, sec = self.dend[85]) h.pt3dadd(173.5, 372, 66, 0.9, sec = self.dend[85]) h.pt3dadd(176.5, 372.5, 66, 0.9, sec = self.dend[85]) h.pt3dadd(179.5, 374.5, 66, 1.1, sec = self.dend[85]) h.pt3dadd(182.5, 376, 64.5, 1.1, sec = self.dend[85]) h.pt3dadd(184.5, 377, 67.5, 0.9, sec = self.dend[85]) h.pt3dadd(186.5, 380, 69, 1.1, sec = self.dend[85]) h.pt3dadd(187.5, 381, 69, 1.3, sec = self.dend[85]) h.pt3dadd(190.5, 383.5, 69, 1.5, sec = self.dend[85]) h.pt3dadd(193, 385.5, 69, 1, sec = self.dend[85]) h.pt3dadd(196.5, 384.5, 69, 1.1, sec = self.dend[85]) h.pt3dadd(200, 385.5, 69, 1.2, sec = self.dend[85]) h.pt3dadd(202, 385.5, 69, 1.3, sec = self.dend[85]) h.pt3dadd(203.5, 387, 69, 1.6, sec = self.dend[85]) h.pt3dadd(205, 388.5, 67.5, 2.1, sec = self.dend[85]) h.pt3dadd(206.5, 389.5, 66, 1.3, sec = self.dend[85]) h.pt3dadd(208, 389.5, 66, 1.1, sec = self.dend[85]) h.pt3dadd(208.5, 389.5, 66, 1.1, sec = self.dend[85]) h.pt3dadd(211, 391.5, 63, 1.2, sec = self.dend[85]) h.pt3dadd(212.5, 391.5, 63, 2, sec = self.dend[85]) h.pt3dadd(215, 393.5, 64.5, 0.9, sec = self.dend[85]) h.pt3dadd(216, 394, 64.5, 0.9, sec = self.dend[85]) h.pt3dadd(217, 395, 63, 2.1, sec = self.dend[85]) h.pt3dadd(218, 397, 64.5, 3.4, sec = self.dend[85]) h.pt3dadd(220, 397.5, 66, 1.2, sec = self.dend[85]) h.pt3dadd(222.5, 398, 67.5, 1.3, sec = self.dend[85]) h.pt3dadd(225, 398, 66, 1.8, sec = self.dend[85]) h.pt3dadd(227, 399.5, 66, 1.3, sec = self.dend[85]) h.pt3dadd(229, 400.5, 66, 1.1, sec = self.dend[85]) h.pt3dadd(230.5, 400.5, 66, 1.1, sec = self.dend[85]) h.pt3dadd(232.5, 401, 66, 2.1, sec = self.dend[85]) h.pt3dadd(234.5, 401.5, 64.5, 2.3, sec = self.dend[85]) h.pt3dadd(237, 401.5, 66, 1.2, sec = self.dend[85]) h.pt3dadd(239.5, 402, 67.5, 0.8, sec = self.dend[85]) h.pt3dadd(241.5, 402, 66, 0.8, sec = self.dend[85]) h.pt3dadd(245, 402.5, 66, 0.8, sec = self.dend[85]) h.pt3dadd(247.5, 404, 66, 0.8, sec = self.dend[85]) h.pt3dadd(252.5, 403.5, 66, 0.8, sec = self.dend[85]) h.pt3dadd(256, 405, 66, 0.8, sec = self.dend[85]) h.pt3dadd(259, 407.5, 66, 0.8, sec = self.dend[85]) h.pt3dadd(261.5, 409, 66, 0.8, sec = self.dend[85]) h.pt3dadd(264.5, 409, 66, 1.1, sec = self.dend[85]) h.pt3dadd(266.5, 408.5, 66, 1.3, sec = self.dend[85]) h.pt3dadd(269, 410, 67.5, 1.1, sec = self.dend[85]) h.pt3dadd(274, 410.5, 67.5, 1.2, sec = self.dend[85]) h.pt3dadd(279.5, 410, 67.5, 1.2, sec = self.dend[85]) h.pt3dadd(282.5, 410.5, 69, 0.7, sec = self.dend[85]) h.pt3dadd(286, 413.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(288.5, 416, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(291, 417, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(292.5, 418.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(295.5, 419.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(297.5, 420.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(299, 421.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(301.5, 421, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(302, 423.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(303.5, 425.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(304.5, 425.5, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(307, 424, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(309, 424, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(310.5, 425, 70.5, 0.7, sec = self.dend[85]) h.pt3dadd(310, 427, 70.5, 2, sec = self.dend[85]) h.pt3dadd(312, 428.5, 73.5, 2.5, sec = self.dend[85]) h.pt3dadd(313, 431.5, 73.5, 1.5, sec = self.dend[85]) h.pt3dadd(314, 433, 73.5, 0.3, sec = self.dend[85]) h.pt3dadd(318, 433.5, 72, 0.3, sec = self.dend[85]) h.pt3dadd(317.5, 435, 72, 0.3, sec = self.dend[85]) h.pt3dadd(322.5, 437, 70.5, 0.4, sec = self.dend[85]) h.pt3dadd(324.5, 436.5, 69, 1.1, sec = self.dend[85]) h.pt3dadd(326, 436, 66, 1.4, sec = self.dend[85]) h.pt3dadd(330, 436.5, 67.5, 0.3, sec = self.dend[85]) h.pt3dadd(334.5, 437.5, 67.5, 0.3, sec = self.dend[85]) h.pt3dadd(336.5, 436.5, 70.5, 0.9, sec = self.dend[85]) h.pt3dadd(339.5, 436, 70.5, 0.4, sec = self.dend[85]) h.pt3dadd(341.5, 436.5, 70.5, 0.4, sec = self.dend[85]) h.pt3dadd(342, 436.5, 70.5, 1.4, sec = self.dend[85]) h.pt3dadd(344.5, 436, 70.5, 2, sec = self.dend[85]) h.pt3dadd(347, 437, 70.5, 1, sec = self.dend[85]) h.pt3dadd(348, 437, 70.5, 1, sec = self.dend[85]) h.pt3dadd(350.5, 436.5, 70.5, 1.3, sec = self.dend[85]) h.pt3dadd(351, 435.5, 70.5, 1.9, sec = self.dend[85]) h.pt3dadd(355, 436, 72, 1.3, sec = self.dend[85]) h.pt3dadd(356, 437, 73.5, 0.9, sec = self.dend[85]) h.pt3dadd(357, 437, 73.5, 1.7, sec = self.dend[85]) h.pt3dadd(359.5, 437, 76.5, 3.2, sec = self.dend[85]) h.pt3dadd(363.5, 437.5, 72, 1.9, sec = self.dend[85]) h.pt3dadd(365, 437, 75, 0.8, sec = self.dend[85]) h.pt3dadd(366.5, 437, 75, 0.8, sec = self.dend[85]) h.pt3dadd(368.5, 437, 75, 1.4, sec = self.dend[85]) h.pt3dadd(369.5, 438, 75, 2, sec = self.dend[85]) h.pt3dadd(371, 438, 75, 1, sec = self.dend[85]) h.pt3dadd(372, 438, 75, 0.8, sec = self.dend[85]) h.pt3dadd(375, 437.5, 75, 0.8, sec = self.dend[85]) h.pt3dadd(377, 437, 75, 0.8, sec = self.dend[85]) h.pt3dadd(380, 437, 75, 0.8, sec = self.dend[85]) h.pt3dadd(380.5, 438, 75, 0.8, sec = self.dend[85]) h.pt3dadd(382, 438, 75, 1.7, sec = self.dend[85]) h.pt3dadd(384, 440, 75, 2.6, sec = self.dend[85]) h.pt3dadd(387, 439, 75, 1.3, sec = self.dend[85]) h.pt3dadd(390, 440, 75, 1.1, sec = self.dend[85]) h.pt3dadd(390.5, 440, 75, 0.9, sec = self.dend[85]) h.pt3dadd(392.5, 439.5, 75, 0.9, sec = self.dend[85]) h.pt3dadd(393.5, 440, 73.5, 1.7, sec = self.dend[85]) h.pt3dadd(394, 440, 75, 2.4, sec = self.dend[85]) h.pt3dadd(397, 439.5, 75, 0.9, sec = self.dend[85]) h.pt3dadd(399, 440.5, 75, 0.9, sec = self.dend[85]) h.pt3dadd(400, 441.5, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(403, 443, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(404.5, 443, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(406.5, 443, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(408, 444.5, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(409, 444.5, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(411, 446, 76.5, 1.8, sec = self.dend[85]) h.pt3dadd(411.5, 446, 76.5, 3.2, sec = self.dend[85]) h.pt3dadd(414, 447, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(416.5, 447, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(418.5, 449, 76.5, 0.6, sec = self.dend[85]) h.pt3dadd(421, 451.5, 76.5, 0.3, sec = self.dend[85]) h.pt3dadd(422.5, 451, 66, 0.2, sec = self.dend[85]) h.pt3dadd(426.5, 451, 70.5, 0.8, sec = self.dend[85]) h.pt3dadd(429.5, 450, 60, 2.3, sec = self.dend[85]) h.pt3dclear(sec = self.dend[86]) h.pt3dadd(429.5, 450, 60, 2.3, sec = self.dend[86]) h.pt3dadd(433.5, 449, 61.5, 1.4, sec = self.dend[86]) h.pt3dadd(437, 449.5, 61.5, 1.4, sec = self.dend[86]) h.pt3dadd(441, 452, 61.5, 1.4, sec = self.dend[86]) h.pt3dadd(444, 454, 61.5, 1.4, sec = self.dend[86]) h.pt3dclear(sec = self.dend[87]) h.pt3dadd(429.5, 450, 60, 2.3, sec = self.dend[87]) h.pt3dadd(434.5, 449.5, 64.5, 0.6, sec = self.dend[87]) h.pt3dadd(435.5, 451.5, 63, 0.6, sec = self.dend[87]) h.pt3dadd(437.5, 454, 64.5, 0.6, sec = self.dend[87]) h.pt3dadd(438, 451.5, 64.5, 0.6, sec = self.dend[87]) h.pt3dadd(438.5, 450, 64.5, 0.6, sec = self.dend[87]) h.pt3dadd(439.5, 449, 66, 0.6, sec = self.dend[87]) h.pt3dadd(440.5, 449, 66, 0.6, sec = self.dend[87]) h.pt3dadd(444, 449, 61.5, 1.7, sec = self.dend[87]) h.pt3dadd(445, 451, 63, 0.9, sec = self.dend[87]) h.pt3dclear(sec = self.dend[88]) h.pt3dadd(157, 88, 22.5, 8.1, sec = self.dend[88]) h.pt3dadd(164.5, 88, 22.5, 4.8, sec = self.dend[88]) h.pt3dadd(167, 88, 22.5, 5.1, sec = self.dend[88]) h.pt3dadd(170, 89, 22.5, 4.7, sec = self.dend[88]) h.pt3dadd(172, 91, 22.5, 4.7, sec = self.dend[88]) h.pt3dadd(174, 93.5, 24, 4.7, sec = self.dend[88]) h.pt3dadd(174.5, 96, 24, 4.7, sec = self.dend[88]) h.pt3dadd(177, 98, 30, 5, sec = self.dend[88]) h.pt3dadd(180.5, 99.5, 30, 5.2, sec = self.dend[88]) h.pt3dadd(182.5, 100.5, 30, 5.3, sec = self.dend[88]) h.pt3dadd(186.5, 104, 28.5, 3.6, sec = self.dend[88]) h.pt3dadd(189.5, 105, 30, 3.3, sec = self.dend[88]) h.pt3dadd(191.5, 107, 30, 3.3, sec = self.dend[88]) h.pt3dadd(194, 107, 30, 3.8, sec = self.dend[88]) h.pt3dadd(197, 107, 30, 4.3, sec = self.dend[88]) h.pt3dadd(200, 108.5, 33.5, 4, sec = self.dend[88]) h.pt3dadd(204.5, 108.5, 33.5, 4, sec = self.dend[88]) h.pt3dadd(207, 109, 32, 3.8, sec = self.dend[88]) h.pt3dadd(210.5, 111.5, 30, 3.8, sec = self.dend[88]) h.pt3dadd(213, 111.5, 37, 3.8, sec = self.dend[88]) h.pt3dadd(216, 112.5, 37, 4.6, sec = self.dend[88]) h.pt3dadd(219.5, 113, 35.5, 4.7, sec = self.dend[88]) h.pt3dadd(222, 113, 35.5, 4.8, sec = self.dend[88]) h.pt3dadd(224.5, 113, 39, 5.3, sec = self.dend[88]) h.pt3dclear(sec = self.dend[89]) h.pt3dadd(224.5, 113, 39, 5.3, sec = self.dend[89]) h.pt3dadd(226.5, 113, 37, 1.3, sec = self.dend[89]) h.pt3dadd(228, 113, 37, 1.3, sec = self.dend[89]) h.pt3dadd(229.5, 113, 37, 2.1, sec = self.dend[89]) h.pt3dadd(231, 113, 37, 2.1, sec = self.dend[89]) h.pt3dadd(232, 112, 37, 1.6, sec = self.dend[89]) h.pt3dadd(233, 110.5, 37, 1.8, sec = self.dend[89]) h.pt3dadd(234.5, 110.5, 37, 1.8, sec = self.dend[89]) h.pt3dadd(237, 109, 37, 1.9, sec = self.dend[89]) h.pt3dadd(238.5, 108.5, 37, 2.5, sec = self.dend[89]) h.pt3dadd(240.5, 107, 37, 2.2, sec = self.dend[89]) h.pt3dadd(242, 104.5, 39, 1.9, sec = self.dend[89]) h.pt3dadd(244.5, 103, 39, 2.2, sec = self.dend[89]) h.pt3dadd(246, 102.5, 37, 2.5, sec = self.dend[89]) h.pt3dadd(248, 101, 37, 2.8, sec = self.dend[89]) h.pt3dadd(250, 101, 37, 2.4, sec = self.dend[89]) h.pt3dadd(253, 100.5, 39, 2, sec = self.dend[89]) h.pt3dadd(253.5, 100, 39, 1.7, sec = self.dend[89]) h.pt3dadd(256, 100, 39, 1.7, sec = self.dend[89]) h.pt3dadd(258, 98, 46, 1.4, sec = self.dend[89]) h.pt3dadd(260, 97.5, 46, 1.2, sec = self.dend[89]) h.pt3dadd(261.5, 95.5, 46, 1.1, sec = self.dend[89]) h.pt3dadd(263, 94, 46, 1.1, sec = self.dend[89]) h.pt3dadd(263.5, 92.5, 37, 1.7, sec = self.dend[89]) h.pt3dadd(266, 92.5, 37, 2.5, sec = self.dend[89]) h.pt3dadd(268, 92, 37, 2.5, sec = self.dend[89]) h.pt3dadd(270, 90.5, 35.5, 2.5, sec = self.dend[89]) h.pt3dadd(270.5, 89, 42.5, 2.4, sec = self.dend[89]) h.pt3dadd(272.5, 87.5, 42.5, 2.4, sec = self.dend[89]) h.pt3dadd(274.5, 87.5, 42.5, 2.5, sec = self.dend[89]) h.pt3dadd(277, 86, 42.5, 2.5, sec = self.dend[89]) h.pt3dadd(277, 83, 42.5, 0.9, sec = self.dend[89]) h.pt3dadd(277.5, 82.5, 42.5, 0.9, sec = self.dend[89]) h.pt3dadd(280, 80, 42.5, 1.1, sec = self.dend[89]) h.pt3dadd(282, 79.5, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(283.5, 77.5, 42.5, 2.3, sec = self.dend[89]) h.pt3dadd(285, 75.5, 42.5, 2.4, sec = self.dend[89]) h.pt3dadd(285, 73, 42.5, 2.2, sec = self.dend[89]) h.pt3dadd(286.5, 71.5, 42.5, 1.8, sec = self.dend[89]) h.pt3dadd(288.5, 70.5, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(290.5, 69.5, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(294, 67.5, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(296, 66, 42.5, 1.5, sec = self.dend[89]) h.pt3dadd(298, 66, 42.5, 1.4, sec = self.dend[89]) h.pt3dadd(301, 65.5, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(303, 64, 42.5, 1.6, sec = self.dend[89]) h.pt3dadd(304.5, 65, 48, 1.6, sec = self.dend[89]) h.pt3dclear(sec = self.dend[90]) h.pt3dadd(224.5, 113, 39, 5.3, sec = self.dend[90]) h.pt3dadd(227.5, 114.5, 37, 3.9, sec = self.dend[90]) h.pt3dadd(230, 115.5, 41, 3.6, sec = self.dend[90]) h.pt3dadd(233.5, 116.5, 41, 3.3, sec = self.dend[90]) h.pt3dadd(235.5, 118, 41, 3.8, sec = self.dend[90]) h.pt3dadd(237.5, 120, 41, 4.4, sec = self.dend[90]) h.pt3dadd(239, 121, 42.5, 4.8, sec = self.dend[90]) h.pt3dadd(241, 123, 42.5, 4.1, sec = self.dend[90]) h.pt3dadd(244.5, 124, 41, 3.8, sec = self.dend[90]) h.pt3dadd(246, 125.5, 39, 3.8, sec = self.dend[90]) h.pt3dadd(249.5, 127, 41, 4, sec = self.dend[90]) h.pt3dadd(251.5, 129, 41, 4, sec = self.dend[90]) h.pt3dadd(253, 130, 41, 4, sec = self.dend[90]) h.pt3dadd(254, 131, 41, 4.3, sec = self.dend[90]) h.pt3dadd(255, 134, 42.5, 3.6, sec = self.dend[90]) h.pt3dadd(256.5, 137, 41, 2.8, sec = self.dend[90]) h.pt3dadd(259.5, 138, 42.5, 2.9, sec = self.dend[90]) h.pt3dadd(261.5, 139.5, 42.5, 3.1, sec = self.dend[90]) h.pt3dadd(264, 141.5, 42.5, 2.8, sec = self.dend[90]) h.pt3dadd(266, 143.5, 44.5, 2.6, sec = self.dend[90]) h.pt3dadd(268.5, 145, 41, 2.8, sec = self.dend[90]) h.pt3dadd(270, 147.5, 41, 3.4, sec = self.dend[90]) h.pt3dadd(271, 150, 42.5, 4.7, sec = self.dend[90]) h.pt3dadd(272, 152, 42.5, 5.9, sec = self.dend[90]) h.pt3dclear(sec = self.dend[91]) h.pt3dadd(272, 152, 42.5, 5.9, sec = self.dend[91]) h.pt3dadd(275, 155.5, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(277, 155.5, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(279, 157, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(281.5, 158, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(284, 158, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(286.5, 157.5, 42.5, 2.4, sec = self.dend[91]) h.pt3dadd(289, 157, 42.5, 1.9, sec = self.dend[91]) h.pt3dadd(291.5, 157, 42.5, 1.8, sec = self.dend[91]) h.pt3dadd(293.5, 156, 42.5, 1.6, sec = self.dend[91]) h.pt3dadd(295.5, 155.5, 42.5, 1.4, sec = self.dend[91]) h.pt3dadd(296.5, 155.5, 42.5, 1.4, sec = self.dend[91]) h.pt3dadd(298.5, 155, 41, 1.5, sec = self.dend[91]) h.pt3dadd(300.5, 154, 41, 1.9, sec = self.dend[91]) h.pt3dadd(302.5, 154, 41, 2, sec = self.dend[91]) h.pt3dadd(303.5, 154, 41, 2.4, sec = self.dend[91]) h.pt3dadd(306, 154, 41, 2.8, sec = self.dend[91]) h.pt3dadd(309, 154.5, 39, 2, sec = self.dend[91]) h.pt3dadd(311, 155, 39, 1.7, sec = self.dend[91]) h.pt3dadd(312.5, 155, 46, 1.7, sec = self.dend[91]) h.pt3dadd(314, 156, 46, 1.7, sec = self.dend[91]) h.pt3dadd(318, 156, 46, 1.7, sec = self.dend[91]) h.pt3dadd(323, 157, 49, 2.4, sec = self.dend[91]) h.pt3dadd(325.5, 156, 49, 2.4, sec = self.dend[91]) h.pt3dadd(326, 156.5, 49, 1.5, sec = self.dend[91]) h.pt3dadd(326.5, 156.5, 50.5, 2.1, sec = self.dend[91]) h.pt3dadd(329.5, 157.5, 50.5, 2.1, sec = self.dend[91]) h.pt3dadd(330.5, 157.5, 50.5, 1.6, sec = self.dend[91]) h.pt3dadd(332.5, 158, 50.5, 1.3, sec = self.dend[91]) h.pt3dadd(333, 158, 50.5, 0.8, sec = self.dend[91]) h.pt3dadd(335.5, 157.5, 49, 1.2, sec = self.dend[91]) h.pt3dadd(336.5, 157.5, 49, 2, sec = self.dend[91]) h.pt3dadd(340, 157, 49, 2.6, sec = self.dend[91]) h.pt3dadd(342.5, 158, 50.5, 2, sec = self.dend[91]) h.pt3dadd(345, 158, 50.5, 1.8, sec = self.dend[91]) h.pt3dadd(347.5, 159.5, 49, 1.4, sec = self.dend[91]) h.pt3dadd(350.5, 160, 49, 1.4, sec = self.dend[91]) h.pt3dadd(354, 162, 47.5, 2.2, sec = self.dend[91]) h.pt3dadd(355.5, 162.5, 47.5, 2.5, sec = self.dend[91]) h.pt3dadd(357.5, 164.5, 47.5, 3.4, sec = self.dend[91]) h.pt3dadd(360.5, 165.5, 44.5, 1.8, sec = self.dend[91]) h.pt3dadd(362, 165.5, 50.5, 1.6, sec = self.dend[91]) h.pt3dadd(364, 166.5, 50.5, 1.3, sec = self.dend[91]) h.pt3dadd(364, 169, 50.5, 1.7, sec = self.dend[91]) h.pt3dadd(366, 169.5, 50.5, 2.5, sec = self.dend[91]) h.pt3dadd(366.5, 172, 52, 3.6, sec = self.dend[91]) h.pt3dadd(368.5, 173.5, 52, 2.5, sec = self.dend[91]) h.pt3dadd(369, 175, 52, 2, sec = self.dend[91]) h.pt3dadd(370.5, 176.5, 53.5, 2, sec = self.dend[91]) h.pt3dadd(372, 177, 55, 2.7, sec = self.dend[91]) h.pt3dadd(373.5, 178.5, 55, 3.1, sec = self.dend[91]) h.pt3dadd(374, 182, 55, 2.2, sec = self.dend[91]) h.pt3dadd(374, 183, 56.5, 1.2, sec = self.dend[91]) h.pt3dadd(374, 185, 59.5, 0.9, sec = self.dend[91]) h.pt3dadd(375.5, 185.5, 52, 2.7, sec = self.dend[91]) h.pt3dadd(377.5, 187.5, 55, 4, sec = self.dend[91]) h.pt3dadd(379, 188.5, 55, 2.6, sec = self.dend[91]) h.pt3dadd(380, 189.5, 53.5, 1.8, sec = self.dend[91]) h.pt3dadd(381.5, 188.5, 55, 1.3, sec = self.dend[91]) h.pt3dadd(382.5, 189, 56.5, 0.6, sec = self.dend[91]) h.pt3dadd(385, 191.5, 56.5, 0.6, sec = self.dend[91]) h.pt3dadd(385, 193, 52, 1.4, sec = self.dend[91]) h.pt3dadd(386.5, 194, 55, 2.1, sec = self.dend[91]) h.pt3dadd(387, 196, 55, 2.1, sec = self.dend[91]) h.pt3dadd(387.5, 198, 55, 1.6, sec = self.dend[91]) h.pt3dadd(388.5, 200.5, 55, 1.4, sec = self.dend[91]) h.pt3dadd(389, 203, 55, 1.2, sec = self.dend[91]) h.pt3dadd(390.5, 202.5, 56.5, 1.2, sec = self.dend[91]) h.pt3dadd(391.5, 203.5, 56.5, 1.7, sec = self.dend[91]) h.pt3dadd(392, 205, 56.5, 2.4, sec = self.dend[91]) h.pt3dadd(393, 206, 58, 3.8, sec = self.dend[91]) h.pt3dadd(394.5, 208, 58, 3.4, sec = self.dend[91]) h.pt3dadd(394.5, 210.5, 53.5, 2.1, sec = self.dend[91]) h.pt3dadd(396.5, 212.5, 55, 2.1, sec = self.dend[91]) h.pt3dadd(398.5, 216.5, 55, 2.1, sec = self.dend[91]) h.pt3dadd(400, 217, 55, 1.5, sec = self.dend[91]) h.pt3dadd(402, 219.5, 55, 1.2, sec = self.dend[91]) h.pt3dadd(402.5, 221, 55, 1.9, sec = self.dend[91]) h.pt3dadd(402.5, 223, 53.5, 2.4, sec = self.dend[91]) h.pt3dadd(403.5, 226, 53.5, 3.2, sec = self.dend[91]) h.pt3dadd(403.5, 227.5, 55, 4.9, sec = self.dend[91]) h.pt3dadd(405.5, 233, 55, 2.8, sec = self.dend[91]) h.pt3dadd(407, 234, 56.5, 1.9, sec = self.dend[91]) h.pt3dadd(409, 237.5, 58, 1.2, sec = self.dend[91]) h.pt3dadd(409.5, 240, 58, 1.1, sec = self.dend[91]) h.pt3dadd(410.5, 241.5, 59.5, 1.7, sec = self.dend[91]) h.pt3dadd(410, 244.5, 61, 1.7, sec = self.dend[91]) h.pt3dadd(411, 246, 53.5, 1.7, sec = self.dend[91]) h.pt3dadd(411.5, 248.5, 53.5, 1.9, sec = self.dend[91]) h.pt3dadd(411.5, 251, 55, 2.1, sec = self.dend[91]) h.pt3dadd(412.5, 254, 55, 2.3, sec = self.dend[91]) h.pt3dadd(413.5, 255.5, 55, 3.3, sec = self.dend[91]) h.pt3dadd(414, 256, 55, 4.6, sec = self.dend[91]) h.pt3dadd(416.5, 259.5, 55, 3, sec = self.dend[91]) h.pt3dadd(418, 260.5, 56.5, 1.9, sec = self.dend[91]) h.pt3dadd(416.5, 264, 58, 1, sec = self.dend[91]) h.pt3dadd(417.5, 266, 58, 1.1, sec = self.dend[91]) h.pt3dadd(418.5, 267, 58, 1.3, sec = self.dend[91]) h.pt3dadd(421, 268.5, 58, 1.6, sec = self.dend[91]) h.pt3dadd(420.5, 270, 59.5, 1.9, sec = self.dend[91]) h.pt3dadd(421, 272, 61, 1.4, sec = self.dend[91]) h.pt3dadd(421, 272.5, 58, 1.4, sec = self.dend[91]) h.pt3dadd(421.5, 274, 58, 2, sec = self.dend[91]) h.pt3dadd(423, 276, 58, 3.1, sec = self.dend[91]) h.pt3dadd(423.5, 278, 58, 2.7, sec = self.dend[91]) h.pt3dadd(424.5, 280.5, 58, 2, sec = self.dend[91]) h.pt3dadd(424, 284.5, 58, 1.7, sec = self.dend[91]) h.pt3dadd(422.5, 287, 58, 2.2, sec = self.dend[91]) h.pt3dadd(424, 289.5, 58, 2.5, sec = self.dend[91]) h.pt3dadd(423.5, 291, 56.5, 2.4, sec = self.dend[91]) h.pt3dadd(425, 294, 55, 2.1, sec = self.dend[91]) h.pt3dadd(427, 295, 55, 2.2, sec = self.dend[91]) h.pt3dadd(427, 298, 55, 2, sec = self.dend[91]) h.pt3dadd(426.5, 300.5, 55, 1.8, sec = self.dend[91]) h.pt3dadd(425.5, 302, 55, 1.7, sec = self.dend[91]) h.pt3dadd(427.5, 303.5, 58, 2.1, sec = self.dend[91]) h.pt3dadd(428.5, 303.5, 58, 3, sec = self.dend[91]) h.pt3dadd(430.5, 302.5, 56.5, 1.3, sec = self.dend[91]) h.pt3dadd(431.5, 302, 56.5, 2.7, sec = self.dend[91]) h.pt3dadd(434, 303, 58, 2, sec = self.dend[91]) h.pt3dadd(435, 304.5, 58, 1.6, sec = self.dend[91]) h.pt3dadd(437, 306, 58, 1.3, sec = self.dend[91]) h.pt3dadd(438.5, 306, 58, 1, sec = self.dend[91]) h.pt3dadd(439, 308, 59.5, 0.6, sec = self.dend[91]) h.pt3dadd(440, 308, 59.5, 0.6, sec = self.dend[91]) h.pt3dadd(440.5, 310, 61, 0.9, sec = self.dend[91]) h.pt3dadd(442.5, 311, 62.5, 1.9, sec = self.dend[91]) h.pt3dadd(444, 312, 62.5, 2.1, sec = self.dend[91]) h.pt3dadd(446, 312.5, 62.5, 1.8, sec = self.dend[91]) h.pt3dadd(446.5, 314, 64, 1.6, sec = self.dend[91]) h.pt3dadd(448, 314.5, 64, 1.1, sec = self.dend[91]) h.pt3dadd(448, 316, 64, 1.6, sec = self.dend[91]) h.pt3dadd(450.5, 316.5, 65.5, 2.2, sec = self.dend[91]) h.pt3dadd(452, 320.5, 61, 1.4, sec = self.dend[91]) h.pt3dadd(453.5, 320.5, 61, 1.1, sec = self.dend[91]) h.pt3dadd(454, 320.5, 61, 1.1, sec = self.dend[91]) h.pt3dadd(455, 320.5, 58, 1.1, sec = self.dend[91]) h.pt3dadd(456, 320.5, 58, 0.5, sec = self.dend[91]) h.pt3dadd(457.5, 321.5, 58, 0.7, sec = self.dend[91]) h.pt3dadd(459.5, 323.5, 58, 0.7, sec = self.dend[91]) h.pt3dadd(460.5, 324, 59.5, 1.5, sec = self.dend[91]) h.pt3dadd(461, 324, 61, 2.8, sec = self.dend[91]) h.pt3dadd(462.5, 322.5, 61, 1, sec = self.dend[91]) h.pt3dadd(464.5, 322, 61, 0.6, sec = self.dend[91]) h.pt3dadd(466.5, 322, 61, 0.6, sec = self.dend[91]) h.pt3dadd(468, 324.5, 61, 0.8, sec = self.dend[91]) h.pt3dadd(469, 323, 61, 2, sec = self.dend[91]) h.pt3dadd(471, 322.5, 61, 2.1, sec = self.dend[91]) h.pt3dadd(473.5, 322, 61, 1.2, sec = self.dend[91]) h.pt3dadd(475.5, 321.5, 55, 0.7, sec = self.dend[91]) h.pt3dadd(477.5, 321.5, 55, 1.4, sec = self.dend[91]) h.pt3dadd(479.5, 323, 58, 2.5, sec = self.dend[91]) h.pt3dadd(482.5, 324, 56.5, 0.9, sec = self.dend[91]) h.pt3dadd(483.5, 324, 56.5, 0.6, sec = self.dend[91]) h.pt3dadd(486, 322, 58, 0.6, sec = self.dend[91]) h.pt3dadd(487, 321.5, 58, 0.6, sec = self.dend[91]) h.pt3dadd(489, 322, 58, 1.7, sec = self.dend[91]) h.pt3dadd(490.5, 321.5, 56.5, 2, sec = self.dend[91]) h.pt3dadd(491.5, 321.5, 56.5, 2, sec = self.dend[91]) h.pt3dadd(494, 321.5, 56.5, 2, sec = self.dend[91]) h.pt3dadd(495.5, 322, 56.5, 2.5, sec = self.dend[91]) h.pt3dadd(498.5, 324, 56.5, 2.3, sec = self.dend[91]) h.pt3dadd(500.5, 324, 58, 1.9, sec = self.dend[91]) h.pt3dadd(503.5, 324.5, 58, 1.3, sec = self.dend[91]) h.pt3dadd(504.5, 326, 59.5, 1.1, sec = self.dend[91]) h.pt3dadd(506.5, 327, 56.5, 1.1, sec = self.dend[91]) h.pt3dadd(509.5, 330.5, 56.5, 1.1, sec = self.dend[91]) h.pt3dadd(511.5, 330.5, 56.5, 1.1, sec = self.dend[91]) h.pt3dadd(514, 330, 56.5, 1.1, sec = self.dend[91]) h.pt3dadd(514.5, 330, 56.5, 2.6, sec = self.dend[91]) h.pt3dadd(516.5, 331, 56.5, 3.8, sec = self.dend[91]) h.pt3dadd(516.5, 335, 56.5, 2.5, sec = self.dend[91]) h.pt3dadd(516.5, 336, 56.5, 1.3, sec = self.dend[91]) h.pt3dadd(516, 338, 56.5, 1.1, sec = self.dend[91]) h.pt3dadd(516.5, 338, 58, 1.6, sec = self.dend[91]) h.pt3dadd(517.5, 338.5, 58, 2.2, sec = self.dend[91]) h.pt3dadd(519, 340, 56.5, 0.8, sec = self.dend[91]) h.pt3dadd(520, 340.5, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(521, 342.5, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(523, 343, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(525, 344, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(527.5, 345, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(529, 345, 56.5, 0.7, sec = self.dend[91]) h.pt3dadd(530, 343.5, 58, 0.6, sec = self.dend[91]) h.pt3dadd(531, 343.5, 64, 0.4, sec = self.dend[91]) h.pt3dadd(532, 343.5, 64, 0.5, sec = self.dend[91]) h.pt3dadd(532.5, 343.5, 65.5, 1.5, sec = self.dend[91]) h.pt3dadd(533, 343.5, 64, 1.9, sec = self.dend[91]) h.pt3dadd(534, 345, 62.5, 0.7, sec = self.dend[91]) h.pt3dadd(535.5, 345, 64, 0.6, sec = self.dend[91]) h.pt3dadd(537, 346, 64, 1.4, sec = self.dend[91]) h.pt3dadd(537.5, 344.5, 67, 2.6, sec = self.dend[91]) h.pt3dadd(540, 345, 61, 1.2, sec = self.dend[91]) h.pt3dadd(542.5, 344.5, 61, 1.1, sec = self.dend[91]) h.pt3dadd(544, 344, 64, 1.4, sec = self.dend[91]) h.pt3dadd(546.5, 345, 62.5, 1.7, sec = self.dend[91]) h.pt3dadd(549.5, 346, 62.5, 2.2, sec = self.dend[91]) h.pt3dadd(551, 346, 62.5, 1.9, sec = self.dend[91]) h.pt3dadd(554.5, 347.5, 65.5, 1.6, sec = self.dend[91]) h.pt3dclear(sec = self.dend[92]) h.pt3dadd(272, 152, 42.5, 5.9, sec = self.dend[92]) h.pt3dadd(272.5, 154.5, 35.5, 2.7, sec = self.dend[92]) h.pt3dadd(272.5, 156.5, 37, 1.9, sec = self.dend[92]) h.pt3dadd(272.5, 158.5, 39, 1.7, sec = self.dend[92]) h.pt3dadd(274.5, 159.5, 39, 1.9, sec = self.dend[92]) h.pt3dadd(276, 161, 41, 2.7, sec = self.dend[92]) h.pt3dadd(278, 164.5, 41, 2.7, sec = self.dend[92]) h.pt3dadd(280, 166.5, 41, 2.5, sec = self.dend[92]) h.pt3dadd(281, 168.5, 41, 1.9, sec = self.dend[92]) h.pt3dadd(282, 171.5, 41, 2.5, sec = self.dend[92]) h.pt3dadd(285, 173, 39, 2.2, sec = self.dend[92]) h.pt3dadd(286.5, 177, 42.5, 3.4, sec = self.dend[92]) h.pt3dadd(288.5, 179, 42.5, 4.3, sec = self.dend[92]) h.pt3dadd(290, 181, 41, 3.4, sec = self.dend[92]) h.pt3dadd(292, 187, 42.5, 2.2, sec = self.dend[92]) h.pt3dadd(293.5, 189.5, 42.5, 1.9, sec = self.dend[92]) h.pt3dadd(299, 191.5, 42.5, 1.6, sec = self.dend[92]) h.pt3dadd(300, 193.5, 42.5, 1.9, sec = self.dend[92]) h.pt3dadd(303.5, 196.5, 42.5, 1.7, sec = self.dend[92]) h.pt3dadd(306, 198, 42.5, 1.7, sec = self.dend[92]) h.pt3dadd(311.5, 198.5, 41, 1.9, sec = self.dend[92]) h.pt3dadd(313.5, 201, 46, 2.3, sec = self.dend[92]) h.pt3dadd(316.5, 201.5, 46, 2.3, sec = self.dend[92]) h.pt3dadd(319.5, 201.5, 44.5, 2.2, sec = self.dend[92]) h.pt3dadd(320.5, 203.5, 44.5, 2.1, sec = self.dend[92]) h.pt3dadd(325, 205.5, 44.5, 2.1, sec = self.dend[92]) h.pt3dadd(327.5, 205.5, 42.5, 1.8, sec = self.dend[92]) h.pt3dadd(329, 208.5, 42.5, 1.3, sec = self.dend[92]) h.pt3dadd(331.5, 210, 41, 1.7, sec = self.dend[92]) h.pt3dadd(333, 213, 41, 2, sec = self.dend[92]) h.pt3dadd(335.5, 215.5, 41, 2, sec = self.dend[92]) h.pt3dadd(337.5, 215, 41, 1.8, sec = self.dend[92]) h.pt3dadd(341, 217.5, 41, 1.8, sec = self.dend[92]) h.pt3dadd(343, 219.5, 41, 1.4, sec = self.dend[92]) h.pt3dadd(345.5, 220, 41, 1.4, sec = self.dend[92]) h.pt3dadd(347.5, 222, 41, 1.4, sec = self.dend[92]) h.pt3dadd(349, 222, 41, 1.3, sec = self.dend[92]) h.pt3dadd(350.5, 222.5, 41, 1.6, sec = self.dend[92]) h.pt3dadd(352, 222.5, 41, 1.8, sec = self.dend[92]) h.pt3dadd(353.5, 224, 41, 1.8, sec = self.dend[92]) h.pt3dadd(355.5, 226, 41, 1.5, sec = self.dend[92]) h.pt3dadd(357, 229.5, 42.5, 1.3, sec = self.dend[92]) h.pt3dadd(359, 229.5, 42.5, 1.2, sec = self.dend[92]) h.pt3dadd(361.5, 231, 42.5, 1.4, sec = self.dend[92]) h.pt3dadd(362.5, 231, 45.5, 1.5, sec = self.dend[92]) h.pt3dadd(363.5, 231.5, 45.5, 1.6, sec = self.dend[92]) h.pt3dadd(364.5, 232.5, 45.5, 1.9, sec = self.dend[92]) h.pt3dadd(367.5, 232, 47, 2, sec = self.dend[92]) h.pt3dadd(370, 234, 47, 2, sec = self.dend[92]) h.pt3dadd(372, 235, 47, 2.5, sec = self.dend[92]) h.pt3dadd(374, 237.5, 45.5, 2.4, sec = self.dend[92]) h.pt3dadd(375.5, 238, 45.5, 1.9, sec = self.dend[92]) h.pt3dadd(379.5, 237, 45.5, 2.5, sec = self.dend[92]) h.pt3dadd(381, 239, 42.5, 3.2, sec = self.dend[92]) h.pt3dadd(382, 239, 42.5, 3.2, sec = self.dend[92]) h.pt3dadd(386.5, 240.5, 41, 2.4, sec = self.dend[92]) h.pt3dadd(387, 243, 44, 2.2, sec = self.dend[92]) h.pt3dadd(389, 243, 42.5, 1.5, sec = self.dend[92]) h.pt3dadd(390.5, 243.5, 41, 1.4, sec = self.dend[92]) h.pt3dadd(392, 244, 45.5, 1.8, sec = self.dend[92]) h.pt3dadd(394, 245, 45.5, 2, sec = self.dend[92]) h.pt3dadd(396, 246.5, 45.5, 2.7, sec = self.dend[92]) h.pt3dadd(397.5, 248.5, 45.5, 2.8, sec = self.dend[92]) h.pt3dadd(400, 251, 44, 3.4, sec = self.dend[92]) h.pt3dadd(403, 252.5, 44, 2.7, sec = self.dend[92]) h.pt3dadd(405, 253, 44, 2.4, sec = self.dend[92]) h.pt3dadd(408, 254, 44, 2.1, sec = self.dend[92]) h.pt3dadd(410, 255.5, 42.5, 1.9, sec = self.dend[92]) h.pt3dadd(413, 258.5, 47, 1.9, sec = self.dend[92]) h.pt3dadd(415.5, 261, 45.5, 1.9, sec = self.dend[92]) h.pt3dadd(414.5, 264, 45.5, 2.4, sec = self.dend[92]) h.pt3dadd(415, 268.5, 45.5, 2.6, sec = self.dend[92]) h.pt3dadd(415.5, 270, 45.5, 2.6, sec = self.dend[92]) h.pt3dadd(415.5, 273.5, 45.5, 2.6, sec = self.dend[92]) h.pt3dadd(416, 276.5, 45.5, 3.7, sec = self.dend[92]) h.pt3dadd(419, 280, 47, 2.8, sec = self.dend[92]) h.pt3dadd(419.5, 282.5, 47, 3.6, sec = self.dend[92]) h.pt3dadd(421, 286.5, 47, 4, sec = self.dend[92]) h.pt3dadd(422, 290, 45.5, 3.4, sec = self.dend[92]) h.pt3dadd(423, 295, 50, 2, sec = self.dend[92]) h.pt3dadd(423.5, 297.5, 50, 2.5, sec = self.dend[92]) h.pt3dadd(423.5, 299.5, 50, 3.7, sec = self.dend[92]) h.pt3dadd(423.5, 302, 51.5, 4, sec = self.dend[92]) h.pt3dadd(425, 305.5, 51.5, 3.9, sec = self.dend[92]) h.pt3dadd(427, 308, 51.5, 3.8, sec = self.dend[92]) h.pt3dadd(428, 308.5, 51.5, 3.8, sec = self.dend[92]) h.pt3dadd(429, 311, 51.5, 3.4, sec = self.dend[92]) h.pt3dadd(430.5, 311, 51.5, 2.8, sec = self.dend[92]) h.pt3dadd(431.5, 313.5, 51.5, 2.4, sec = self.dend[92]) h.pt3dadd(434, 315, 50, 2.2, sec = self.dend[92]) h.pt3dadd(433.5, 316.5, 54.5, 2.9, sec = self.dend[92]) h.pt3dadd(432.5, 320.5, 54.5, 3.7, sec = self.dend[92]) h.pt3dadd(434.5, 323, 54.5, 3.1, sec = self.dend[92]) h.pt3dadd(435.5, 326, 54.5, 2.8, sec = self.dend[92]) h.pt3dadd(436, 328, 53, 2.2, sec = self.dend[92]) h.pt3dadd(436.5, 329.5, 53, 2.5, sec = self.dend[92]) h.pt3dadd(437.5, 333, 53, 3, sec = self.dend[92]) h.pt3dadd(439.5, 336.5, 53, 3, sec = self.dend[92]) h.pt3dadd(440.5, 340, 60.5, 2.3, sec = self.dend[92]) h.pt3dadd(441, 341, 60.5, 2.3, sec = self.dend[92]) h.pt3dadd(442.5, 343.5, 60.5, 2.9, sec = self.dend[92]) h.pt3dadd(445, 348, 60.5, 2, sec = self.dend[92]) h.pt3dadd(446, 350.5, 60.5, 2.2, sec = self.dend[92]) h.pt3dadd(447.5, 351.5, 60.5, 2.2, sec = self.dend[92]) h.pt3dadd(448, 354.5, 60.5, 2.2, sec = self.dend[92]) h.pt3dadd(448, 357, 60.5, 2.8, sec = self.dend[92]) h.pt3dadd(447.5, 359.5, 60.5, 2.8, sec = self.dend[92]) h.pt3dadd(448, 360.5, 60.5, 2.8, sec = self.dend[92]) h.pt3dadd(449, 363, 62, 2.1, sec = self.dend[92]) h.pt3dadd(452.5, 365.5, 62, 2.3, sec = self.dend[92]) h.pt3dadd(453.5, 369.5, 60.5, 2.9, sec = self.dend[92]) h.pt3dadd(454.5, 371.5, 62, 3.2, sec = self.dend[92]) h.pt3dadd(456.5, 373, 62, 1.9, sec = self.dend[92]) h.pt3dadd(458.5, 375, 62, 1.9, sec = self.dend[92]) h.pt3dadd(459.5, 376, 60.5, 2.5, sec = self.dend[92]) h.pt3dadd(460, 377.5, 60.5, 3.2, sec = self.dend[92]) h.pt3dadd(462.5, 380.5, 60.5, 1.7, sec = self.dend[92]) h.pt3dadd(462.5, 382, 62, 1.4, sec = self.dend[92]) h.pt3dadd(462.5, 385, 62, 1.4, sec = self.dend[92]) h.pt3dadd(464, 387.5, 60.5, 2.2, sec = self.dend[92]) h.pt3dadd(466.5, 390.5, 59, 3.2, sec = self.dend[92]) h.pt3dadd(467, 393, 62, 1.7, sec = self.dend[92]) h.pt3dadd(468.5, 395, 63.5, 1.2, sec = self.dend[92]) h.pt3dadd(470.5, 395, 63.5, 1.8, sec = self.dend[92]) h.pt3dadd(471, 395.5, 63.5, 2.5, sec = self.dend[92]) h.pt3dadd(471.5, 397.5, 63.5, 2.4, sec = self.dend[92]) h.pt3dadd(473.5, 400, 63.5, 2.4, sec = self.dend[92]) h.pt3dadd(474.5, 401.5, 63.5, 2.4, sec = self.dend[92]) h.pt3dadd(476, 403.5, 65, 2.4, sec = self.dend[92]) h.pt3dadd(475, 407, 65, 2.4, sec = self.dend[92]) h.pt3dadd(477.5, 410, 65, 1.9, sec = self.dend[92]) h.pt3dadd(478.5, 412, 66.5, 1.3, sec = self.dend[92]) h.pt3dadd(478.5, 413.5, 66.5, 1.6, sec = self.dend[92]) h.pt3dadd(481, 416.5, 63.5, 1.6, sec = self.dend[92]) h.pt3dadd(481.5, 419, 65, 1.8, sec = self.dend[92]) h.pt3dadd(482, 422.5, 65, 1.8, sec = self.dend[92]) h.pt3dadd(483, 424, 65, 1.6, sec = self.dend[92]) h.pt3dadd(482.5, 428, 65, 1.6, sec = self.dend[92]) h.pt3dadd(483, 430, 63.5, 1.6, sec = self.dend[92]) h.pt3dadd(486.5, 431, 62, 2, sec = self.dend[92]) h.pt3dadd(488, 432, 65, 3.2, sec = self.dend[92]) h.pt3dadd(489, 432.5, 63.5, 3.8, sec = self.dend[92]) h.pt3dadd(491, 435.5, 68, 2, sec = self.dend[92]) h.pt3dadd(491, 436.5, 68, 1.6, sec = self.dend[92]) h.pt3dadd(493, 439, 68, 1.4, sec = self.dend[92]) h.pt3dadd(493.5, 439.5, 68, 1.4, sec = self.dend[92]) h.pt3dadd(494, 441, 62, 1.4, sec = self.dend[92]) h.pt3dadd(493.5, 443, 68, 2, sec = self.dend[92]) h.pt3dadd(495, 445, 63.5, 2.8, sec = self.dend[92]) h.pt3dadd(496.5, 448.5, 63.5, 1.6, sec = self.dend[92]) h.pt3dadd(499.5, 450, 62, 0.7, sec = self.dend[92]) h.pt3dadd(502, 450, 66, 0.4, sec = self.dend[92]) h.pt3dadd(503.5, 448.5, 66, 0.4, sec = self.dend[92]) h.pt3dadd(506, 450, 66, 0.4, sec = self.dend[92]) h.pt3dadd(507, 451, 68, 0.8, sec = self.dend[92]) h.pt3dadd(509.5, 451.5, 68, 1.2, sec = self.dend[92]) h.pt3dadd(512.5, 451.5, 68, 0.8, sec = self.dend[92]) h.pt3dadd(512.5, 454.5, 74, 0.1, sec = self.dend[92]) h.pt3dadd(513.5, 456, 74, 0.1, sec = self.dend[92]) h.pt3dadd(514, 458, 74, 1.9, sec = self.dend[92]) h.pt3dadd(516.5, 459, 74, 2.5, sec = self.dend[92]) h.pt3dadd(518.5, 461.5, 74, 1.4, sec = self.dend[92]) h.pt3dadd(520, 464, 74, 0.6, sec = self.dend[92]) h.pt3dadd(523, 464, 74, 0.9, sec = self.dend[92]) h.pt3dadd(524, 464.5, 72, 0.9, sec = self.dend[92]) h.pt3dadd(525, 465.5, 74, 1.7, sec = self.dend[92]) h.pt3dadd(525, 467, 78, 2.7, sec = self.dend[92]) h.pt3dadd(527, 467, 78, 1.5, sec = self.dend[92]) h.pt3dadd(529, 469, 76, 0.9, sec = self.dend[92]) h.pt3dadd(529, 471.5, 76, 0.9, sec = self.dend[92]) h.pt3dadd(532, 473, 76, 0.9, sec = self.dend[92]) h.pt3dadd(532.5, 474.5, 82, 0.7, sec = self.dend[92]) h.pt3dadd(534.5, 476.5, 84, 1.7, sec = self.dend[92]) h.pt3dadd(537.5, 477.5, 84, 2.5, sec = self.dend[92]) h.pt3dadd(540.5, 480, 84, 1.2, sec = self.dend[92]) h.pt3dadd(544.5, 485, 84, 0.3, sec = self.dend[92]) h.pt3dadd(547.5, 490, 84, 0.3, sec = self.dend[92]) h.pt3dadd(547.5, 492, 84, 0.3, sec = self.dend[92]) h.pt3dadd(548, 494, 84, 1.4, sec = self.dend[92]) h.pt3dadd(549.5, 494, 84, 1.7, sec = self.dend[92]) h.pt3dadd(549.5, 494, 80, 0.4, sec = self.dend[92]) h.pt3dadd(552.5, 496, 80, 0.5, sec = self.dend[92]) h.pt3dadd(555, 498, 80, 0.5, sec = self.dend[92]) h.pt3dadd(555.5, 498.5, 86, 1.4, sec = self.dend[92]) h.pt3dadd(556, 500.5, 88, 1.8, sec = self.dend[92]) h.pt3dadd(556.5, 501.5, 88, 2.2, sec = self.dend[92]) h.pt3dadd(557.5, 501.5, 88, 1.2, sec = self.dend[92]) h.pt3dadd(558, 502.5, 88, 0.1, sec = self.dend[92]) h.pt3dadd(562.5, 503, 88, 0.1, sec = self.dend[92]) h.pt3dadd(566, 506, 88, 0.1, sec = self.dend[92]) h.pt3dadd(569, 508.5, 88, 0.1, sec = self.dend[92]) h.pt3dadd(572, 509, 66, 0.1, sec = self.dend[92]) h.pt3dadd(576, 509.5, 62, 0.1, sec = self.dend[92]) h.pt3dadd(581.5, 509.5, 74, 0.1, sec = self.dend[92]) h.pt3dclear(sec = self.dend[93]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[93]) h.pt3dadd(36.5, 3, -3, 9, sec = self.dend[93]) h.pt3dadd(36.5, -1, -3, 9, sec = self.dend[93]) h.pt3dadd(36.5, -4.5, -3, 8.3, sec = self.dend[93]) h.pt3dadd(37.5, -9.5, -3, 8, sec = self.dend[93]) h.pt3dadd(37.5, -12.5, -3, 7.7, sec = self.dend[93]) h.pt3dadd(40, -15.5, -5, 7.4, sec = self.dend[93]) h.pt3dadd(40.5, -20, -2, 5.8, sec = self.dend[93]) h.pt3dadd(42, -22.5, 0.5, 8, sec = self.dend[93]) h.pt3dadd(43, -25, 9, 8.6, sec = self.dend[93]) h.pt3dadd(42.5, -29, 9, 7.6, sec = self.dend[93]) h.pt3dadd(43.5, -33, 9, 7.6, sec = self.dend[93]) h.pt3dadd(44, -37.5, 23, 8.1, sec = self.dend[93]) h.pt3dadd(46.5, -41, 24.5, 5.4, sec = self.dend[93]) h.pt3dadd(48, -44.5, 26, 7.6, sec = self.dend[93]) h.pt3dadd(49, -47, 26, 9.4, sec = self.dend[93]) h.pt3dclear(sec = self.dend[94]) h.pt3dadd(49, -47, 26, 9.4, sec = self.dend[94]) h.pt3dadd(58, -46, 24.5, 4.6, sec = self.dend[94]) h.pt3dadd(62, -46, 27.5, 4.6, sec = self.dend[94]) h.pt3dadd(64, -45.5, 27.5, 4.2, sec = self.dend[94]) h.pt3dadd(66.5, -45.5, 27.5, 4.2, sec = self.dend[94]) h.pt3dadd(65.5, -42.5, 27.5, 4.3, sec = self.dend[94]) h.pt3dadd(69.5, -41, 29, 3.2, sec = self.dend[94]) h.pt3dadd(70.5, -42.5, 29, 3.8, sec = self.dend[94]) h.pt3dadd(73, -44, 29, 4.9, sec = self.dend[94]) h.pt3dadd(75.5, -44, 29, 4.6, sec = self.dend[94]) h.pt3dadd(77, -45.5, 29, 5.4, sec = self.dend[94]) h.pt3dadd(78.5, -46.5, 31.5, 4.6, sec = self.dend[94]) h.pt3dadd(80.5, -46.5, 31.5, 4.5, sec = self.dend[94]) h.pt3dadd(83, -46.5, 31.5, 4.3, sec = self.dend[94]) h.pt3dadd(85, -46.5, 31.5, 5.2, sec = self.dend[94]) h.pt3dadd(87, -46, 31.5, 6.2, sec = self.dend[94]) h.pt3dadd(89, -44, 33, 6.3, sec = self.dend[94]) h.pt3dadd(92, -44, 34.5, 5.6, sec = self.dend[94]) h.pt3dadd(93.5, -46.5, 36, 5.6, sec = self.dend[94]) h.pt3dadd(96.5, -46.5, 36, 6, sec = self.dend[94]) h.pt3dadd(99, -48, 36, 5.6, sec = self.dend[94]) h.pt3dadd(101.5, -48.5, 36, 4.9, sec = self.dend[94]) h.pt3dadd(103.5, -49.5, 34.5, 5.7, sec = self.dend[94]) h.pt3dadd(107, -49.5, 34.5, 5.7, sec = self.dend[94]) h.pt3dadd(109, -49.5, 34.5, 6.5, sec = self.dend[94]) h.pt3dadd(111, -50, 33, 7.4, sec = self.dend[94]) h.pt3dadd(113.5, -52, 33, 7.4, sec = self.dend[94]) h.pt3dadd(116.5, -54, 33, 6.3, sec = self.dend[94]) h.pt3dadd(119.5, -54.5, 33, 6.3, sec = self.dend[94]) h.pt3dadd(122.5, -56.5, 41.5, 6.8, sec = self.dend[94]) h.pt3dadd(124.5, -57.5, 41.5, 6.7, sec = self.dend[94]) h.pt3dadd(129.5, -58.5, 44.5, 6.6, sec = self.dend[94]) h.pt3dadd(134, -59.5, 46, 5.9, sec = self.dend[94]) h.pt3dadd(138.5, -60.5, 46, 7.3, sec = self.dend[94]) h.pt3dadd(142.5, -62, 46, 7.1, sec = self.dend[94]) h.pt3dadd(148, -62.5, 46, 7, sec = self.dend[94]) h.pt3dadd(154, -65.5, 46, 6.9, sec = self.dend[94]) h.pt3dadd(159.5, -65.5, 46, 6.7, sec = self.dend[94]) h.pt3dadd(163, -65.5, 46, 6.7, sec = self.dend[94]) h.pt3dadd(167.5, -65.5, 47.5, 6.5, sec = self.dend[94]) h.pt3dadd(176, -66.5, 51, 5.9, sec = self.dend[94]) h.pt3dadd(182, -67, 49.5, 5.9, sec = self.dend[94]) h.pt3dadd(186.5, -69, 47.5, 5.9, sec = self.dend[94]) h.pt3dadd(191, -69, 47.5, 6.3, sec = self.dend[94]) h.pt3dadd(195, -70, 47.5, 6.8, sec = self.dend[94]) h.pt3dadd(198.5, -71, 47.5, 7.2, sec = self.dend[94]) h.pt3dadd(206.5, -74.5, 58.5, 6.3, sec = self.dend[94]) h.pt3dadd(210.5, -74, 54.5, 6.3, sec = self.dend[94]) h.pt3dadd(215.5, -74, 58.5, 6, sec = self.dend[94]) h.pt3dadd(220, -75, 56.5, 6, sec = self.dend[94]) h.pt3dadd(222, -75, 56.5, 6.3, sec = self.dend[94]) h.pt3dadd(225.5, -76.5, 49.5, 6.7, sec = self.dend[94]) h.pt3dadd(228.5, -79, 51, 6.7, sec = self.dend[94]) h.pt3dadd(231, -79, 53, 7.3, sec = self.dend[94]) h.pt3dadd(235, -82.5, 53, 6.3, sec = self.dend[94]) h.pt3dadd(238.5, -84.5, 53, 5.1, sec = self.dend[94]) h.pt3dadd(241, -86, 53, 5.3, sec = self.dend[94]) h.pt3dadd(243, -88, 54.5, 6.5, sec = self.dend[94]) h.pt3dadd(245, -89.5, 54.5, 7.3, sec = self.dend[94]) h.pt3dadd(248.5, -92, 54.5, 8.3, sec = self.dend[94]) h.pt3dclear(sec = self.dend[95]) h.pt3dadd(248.5, -92, 54.5, 8.3, sec = self.dend[95]) h.pt3dadd(249.5, -97.5, 56.5, 5.2, sec = self.dend[95]) h.pt3dadd(251.5, -100, 56.5, 4.3, sec = self.dend[95]) h.pt3dadd(252.5, -103, 56.5, 3.7, sec = self.dend[95]) h.pt3dadd(255, -104.5, 56.5, 3.7, sec = self.dend[95]) h.pt3dadd(256.5, -105.5, 56.5, 4.4, sec = self.dend[95]) h.pt3dadd(259.5, -106.5, 56.5, 3.8, sec = self.dend[95]) h.pt3dadd(261.5, -109, 56.5, 4.1, sec = self.dend[95]) h.pt3dadd(265, -113, 56.5, 3.7, sec = self.dend[95]) h.pt3dadd(267.5, -114, 56.5, 3.5, sec = self.dend[95]) h.pt3dadd(269, -117, 56.5, 3.7, sec = self.dend[95]) h.pt3dadd(269, -119, 56.5, 3.9, sec = self.dend[95]) h.pt3dadd(269.5, -120.5, 54.5, 3.2, sec = self.dend[95]) h.pt3dadd(271.5, -121.5, 54.5, 4.1, sec = self.dend[95]) h.pt3dadd(272.5, -122.5, 54.5, 4.6, sec = self.dend[95]) h.pt3dadd(274, -124, 54.5, 4.9, sec = self.dend[95]) h.pt3dadd(276, -127.5, 54.5, 2.3, sec = self.dend[95]) h.pt3dadd(276.5, -129, 54.5, 2.6, sec = self.dend[95]) h.pt3dadd(278, -131, 54.5, 4.1, sec = self.dend[95]) h.pt3dadd(281, -134, 54.5, 4.6, sec = self.dend[95]) h.pt3dadd(289.5, -140.5, 57.5, 4, sec = self.dend[95]) h.pt3dadd(291.5, -143, 57.5, 4.1, sec = self.dend[95]) h.pt3dadd(294, -145, 60.5, 5, sec = self.dend[95]) h.pt3dadd(295, -146.5, 60.5, 4, sec = self.dend[95]) h.pt3dadd(297.5, -148, 60.5, 3.6, sec = self.dend[95]) h.pt3dadd(299.5, -149.5, 60.5, 3.8, sec = self.dend[95]) h.pt3dadd(301, -150, 60.5, 4.6, sec = self.dend[95]) h.pt3dadd(304, -156, 60.5, 4.3, sec = self.dend[95]) h.pt3dadd(306, -156.5, 65, 3.7, sec = self.dend[95]) h.pt3dadd(307.5, -158.5, 63.5, 4.3, sec = self.dend[95]) h.pt3dadd(307, -160, 63.5, 5.1, sec = self.dend[95]) h.pt3dadd(307.5, -162.5, 63.5, 3.3, sec = self.dend[95]) h.pt3dadd(307, -165.5, 63.5, 4.4, sec = self.dend[95]) h.pt3dadd(307.5, -166.5, 63.5, 4.6, sec = self.dend[95]) h.pt3dadd(310, -168.5, 60.5, 4.1, sec = self.dend[95]) h.pt3dadd(311, -170, 60.5, 3.4, sec = self.dend[95]) h.pt3dadd(312.5, -170.5, 60.5, 3.2, sec = self.dend[95]) h.pt3dadd(314.5, -171.5, 60.5, 3.5, sec = self.dend[95]) h.pt3dadd(316, -173.5, 60.5, 4.1, sec = self.dend[95]) h.pt3dadd(315.5, -175, 60.5, 3.4, sec = self.dend[95]) h.pt3dadd(316.5, -178, 62, 4.3, sec = self.dend[95]) h.pt3dadd(316.5, -183, 60.5, 4.1, sec = self.dend[95]) h.pt3dadd(318, -185, 60.5, 4.1, sec = self.dend[95]) h.pt3dadd(320.5, -187, 63.5, 3.3, sec = self.dend[95]) h.pt3dadd(322, -187, 63.5, 3.3, sec = self.dend[95]) h.pt3dadd(323.5, -187, 63.5, 3.6, sec = self.dend[95]) h.pt3dadd(325, -187.5, 62, 3.1, sec = self.dend[95]) h.pt3dadd(327.5, -187.5, 62, 2.6, sec = self.dend[95]) h.pt3dadd(330.5, -188, 62, 2.1, sec = self.dend[95]) h.pt3dadd(333, -188, 66.5, 2.7, sec = self.dend[95]) h.pt3dadd(334, -188, 66.5, 4.1, sec = self.dend[95]) h.pt3dadd(336, -189, 66.5, 3.3, sec = self.dend[95]) h.pt3dadd(338.5, -191, 65, 3.1, sec = self.dend[95]) h.pt3dadd(339.5, -192, 65, 3.8, sec = self.dend[95]) h.pt3dadd(342, -192.5, 63.5, 4.1, sec = self.dend[95]) h.pt3dadd(345.5, -194.5, 63.5, 3.7, sec = self.dend[95]) h.pt3dadd(348.5, -195, 72.5, 4.4, sec = self.dend[95]) h.pt3dadd(352.5, -195, 72.5, 4.6, sec = self.dend[95]) h.pt3dadd(353, -198, 72.5, 4.6, sec = self.dend[95]) h.pt3dadd(354, -200, 71, 4.9, sec = self.dend[95]) h.pt3dadd(356, -201.5, 71, 4.7, sec = self.dend[95]) h.pt3dadd(357.5, -202, 71, 4.3, sec = self.dend[95]) h.pt3dadd(360, -203.5, 69.5, 3.2, sec = self.dend[95]) h.pt3dadd(362.5, -203.5, 68, 3.7, sec = self.dend[95]) h.pt3dadd(365.5, -203.5, 68, 3.8, sec = self.dend[95]) h.pt3dadd(365, -206.5, 68, 3.8, sec = self.dend[95]) h.pt3dadd(362.5, -207, 68, 3.8, sec = self.dend[95]) h.pt3dadd(364, -209, 72.5, 3.8, sec = self.dend[95]) h.pt3dadd(367, -210, 72.5, 3.6, sec = self.dend[95]) h.pt3dadd(370, -211.5, 78.5, 3.1, sec = self.dend[95]) h.pt3dadd(372.5, -212.5, 78.5, 3.3, sec = self.dend[95]) h.pt3dadd(376, -213.5, 78.5, 3.3, sec = self.dend[95]) h.pt3dadd(379, -214, 77, 2.8, sec = self.dend[95]) h.pt3dadd(382.5, -214, 78.5, 2.8, sec = self.dend[95]) h.pt3dadd(385.5, -214.5, 78.5, 3.3, sec = self.dend[95]) h.pt3dadd(387, -216, 78.5, 4.9, sec = self.dend[95]) h.pt3dadd(389.5, -218, 78.5, 3.5, sec = self.dend[95]) h.pt3dadd(391.5, -218, 78.5, 3.5, sec = self.dend[95]) h.pt3dadd(393.5, -219, 78.5, 3.1, sec = self.dend[95]) h.pt3dadd(397, -218.5, 77, 3.4, sec = self.dend[95]) h.pt3dadd(400.5, -221.5, 77, 3.4, sec = self.dend[95]) h.pt3dadd(402.5, -225, 75.5, 3.9, sec = self.dend[95]) h.pt3dadd(403.5, -226.5, 78.5, 3.8, sec = self.dend[95]) h.pt3dadd(406.5, -228, 78.5, 3.4, sec = self.dend[95]) h.pt3dadd(410.5, -230, 78.5, 3.3, sec = self.dend[95]) h.pt3dadd(414, -232, 78.5, 4, sec = self.dend[95]) h.pt3dadd(415.5, -234.5, 78.5, 3.7, sec = self.dend[95]) h.pt3dadd(419, -236.5, 78.5, 3.4, sec = self.dend[95]) h.pt3dadd(421, -238.5, 83, 3.2, sec = self.dend[95]) h.pt3dadd(426, -240, 81.5, 3.6, sec = self.dend[95]) h.pt3dadd(430, -241.5, 81.5, 3.5, sec = self.dend[95]) h.pt3dadd(433, -242, 81.5, 3.3, sec = self.dend[95]) h.pt3dadd(435, -242, 81.5, 2.9, sec = self.dend[95]) h.pt3dadd(437.5, -241, 81.5, 3.8, sec = self.dend[95]) h.pt3dadd(440, -241.5, 84.5, 3.8, sec = self.dend[95]) h.pt3dadd(440.5, -245.5, 84.5, 3.3, sec = self.dend[95]) h.pt3dadd(440, -247.5, 83, 3.8, sec = self.dend[95]) h.pt3dadd(439, -248, 83, 3.7, sec = self.dend[95]) h.pt3dadd(440, -252, 80, 3.1, sec = self.dend[95]) h.pt3dadd(440.5, -254, 80, 2.7, sec = self.dend[95]) h.pt3dadd(441, -254, 78.5, 2.5, sec = self.dend[95]) h.pt3dadd(443, -256, 83, 3, sec = self.dend[95]) h.pt3dadd(443, -257, 83, 3.2, sec = self.dend[95]) h.pt3dadd(445, -259.5, 83, 3.4, sec = self.dend[95]) h.pt3dadd(443, -262, 83, 3.8, sec = self.dend[95]) h.pt3dadd(443, -263, 83, 4.3, sec = self.dend[95]) h.pt3dclear(sec = self.dend[96]) h.pt3dadd(443, -263, 83, 4.3, sec = self.dend[96]) h.pt3dadd(445, -265.5, 84.5, 1.3, sec = self.dend[96]) h.pt3dadd(447, -268.5, 84.5, 1.3, sec = self.dend[96]) h.pt3dadd(449.5, -271.5, 90.5, 2.7, sec = self.dend[96]) h.pt3dadd(449.5, -272, 88.5, 3.1, sec = self.dend[96]) h.pt3dadd(449.5, -275, 88.5, 1.8, sec = self.dend[96]) h.pt3dadd(449.5, -275.5, 90.5, 2.2, sec = self.dend[96]) h.pt3dadd(449, -278, 90.5, 2.5, sec = self.dend[96]) h.pt3dadd(448.5, -280.5, 90.5, 2.7, sec = self.dend[96]) h.pt3dadd(451, -278, 90.5, 3.4, sec = self.dend[96]) h.pt3dadd(453, -278, 90.5, 3.4, sec = self.dend[96]) h.pt3dadd(454.5, -280.5, 90.5, 2.3, sec = self.dend[96]) h.pt3dadd(455, -281, 90.5, 2, sec = self.dend[96]) h.pt3dadd(456.5, -282, 90.5, 2.3, sec = self.dend[96]) h.pt3dadd(457.5, -284, 100.5, 2.3, sec = self.dend[96]) h.pt3dadd(458.5, -284, 100.5, 2.4, sec = self.dend[96]) h.pt3dadd(460, -285, 100.5, 2.4, sec = self.dend[96]) h.pt3dadd(463.5, -287.5, 102.5, 2.7, sec = self.dend[96]) h.pt3dadd(469.5, -293, 98.5, 1.4, sec = self.dend[96]) h.pt3dadd(471, -292.5, 98.5, 1.4, sec = self.dend[96]) h.pt3dadd(472, -291.5, 94.5, 1.7, sec = self.dend[96]) h.pt3dadd(475.5, -292, 94.5, 1, sec = self.dend[96]) h.pt3dadd(475, -293.5, 94.5, 1.6, sec = self.dend[96]) h.pt3dadd(475.5, -295.5, 101, 2.2, sec = self.dend[96]) h.pt3dadd(477.5, -295.5, 98.5, 3.2, sec = self.dend[96]) h.pt3dadd(480.5, -298.5, 99.5, 2, sec = self.dend[96]) h.pt3dadd(481, -298.5, 99.5, 1.8, sec = self.dend[96]) h.pt3dadd(482, -300, 101, 1.8, sec = self.dend[96]) h.pt3dadd(483.5, -301.5, 103.5, 1.7, sec = self.dend[96]) h.pt3dadd(485, -301, 106.5, 1.4, sec = self.dend[96]) h.pt3dadd(485, -303.5, 106.5, 1.2, sec = self.dend[96]) h.pt3dadd(485, -304.5, 103.5, 1.4, sec = self.dend[96]) h.pt3dadd(486.5, -304.5, 103.5, 1.7, sec = self.dend[96]) h.pt3dadd(487.5, -305.5, 103.5, 2.1, sec = self.dend[96]) h.pt3dadd(488, -307.5, 105, 2.7, sec = self.dend[96]) h.pt3dadd(489, -308, 105, 2.3, sec = self.dend[96]) h.pt3dadd(491, -309, 105, 1, sec = self.dend[96]) h.pt3dadd(493, -309.5, 105, 1.4, sec = self.dend[96]) h.pt3dadd(495, -308.5, 105, 1.4, sec = self.dend[96]) h.pt3dadd(496, -312, 105, 1.4, sec = self.dend[96]) h.pt3dadd(497, -313.5, 105, 1.6, sec = self.dend[96]) h.pt3dadd(498.5, -314.5, 105, 1.6, sec = self.dend[96]) h.pt3dadd(499.5, -315.5, 105, 1.6, sec = self.dend[96]) h.pt3dadd(501, -315.5, 105, 1.5, sec = self.dend[96]) h.pt3dadd(502, -315.5, 105, 2, sec = self.dend[96]) h.pt3dadd(505.5, -315.5, 105, 2, sec = self.dend[96]) h.pt3dadd(507, -315.5, 105, 1.2, sec = self.dend[96]) h.pt3dadd(508, -317, 106.5, 1, sec = self.dend[96]) h.pt3dadd(510, -317, 106.5, 1.1, sec = self.dend[96]) h.pt3dadd(510, -318, 102.5, 1.4, sec = self.dend[96]) h.pt3dadd(511.5, -318, 102.5, 2.1, sec = self.dend[96]) h.pt3dadd(514, -318, 102.5, 2.2, sec = self.dend[96]) h.pt3dadd(515.5, -318, 102.5, 2.5, sec = self.dend[96]) h.pt3dadd(517, -317.5, 103.5, 2.9, sec = self.dend[96]) h.pt3dadd(519, -319, 109, 2.9, sec = self.dend[96]) h.pt3dadd(519.5, -322, 109, 2.9, sec = self.dend[96]) h.pt3dadd(517, -319, 109, 2.9, sec = self.dend[96]) h.pt3dadd(518, -322, 109, 2.9, sec = self.dend[96]) h.pt3dadd(518, -324.5, 109, 2.9, sec = self.dend[96]) h.pt3dadd(519.5, -324.5, 109, 2.9, sec = self.dend[96]) h.pt3dadd(518.5, -327, 107.5, 2.5, sec = self.dend[96]) h.pt3dadd(518.5, -329.5, 111.5, 1.3, sec = self.dend[96]) h.pt3dadd(517.5, -331, 111.5, 1.8, sec = self.dend[96]) h.pt3dadd(518, -332.5, 117, 2.1, sec = self.dend[96]) h.pt3dadd(518, -336, 119.5, 2.1, sec = self.dend[96]) h.pt3dadd(517, -337.5, 114, 1.7, sec = self.dend[96]) h.pt3dclear(sec = self.dend[97]) h.pt3dadd(443, -263, 83, 4.3, sec = self.dend[97]) h.pt3dadd(441.5, -265.5, 83, 1.5, sec = self.dend[97]) h.pt3dadd(442, -267.5, 83, 1.5, sec = self.dend[97]) h.pt3dadd(442.5, -269, 83, 1.5, sec = self.dend[97]) h.pt3dadd(441, -271.5, 83, 1.1, sec = self.dend[97]) h.pt3dadd(440.5, -272.5, 83, 1.1, sec = self.dend[97]) h.pt3dadd(440.5, -274, 83, 1.2, sec = self.dend[97]) h.pt3dadd(440.5, -276, 83, 1.1, sec = self.dend[97]) h.pt3dadd(442.5, -276, 84.5, 1.1, sec = self.dend[97]) h.pt3dadd(443.5, -276.5, 84.5, 1.1, sec = self.dend[97]) h.pt3dadd(443.5, -278.5, 81.5, 1.1, sec = self.dend[97]) h.pt3dadd(446, -277, 83.5, 1.3, sec = self.dend[97]) h.pt3dadd(447, -278.5, 85.5, 1, sec = self.dend[97]) h.pt3dadd(447.5, -280.5, 85.5, 1.8, sec = self.dend[97]) h.pt3dadd(448, -281, 85.5, 1.8, sec = self.dend[97]) h.pt3dadd(448, -283.5, 89.5, 2.1, sec = self.dend[97]) h.pt3dadd(447.5, -284.5, 89.5, 1.8, sec = self.dend[97]) h.pt3dadd(447.5, -287, 89.5, 1.5, sec = self.dend[97]) h.pt3dadd(448.5, -287.5, 89.5, 1.4, sec = self.dend[97]) h.pt3dadd(450, -288, 87.5, 1.4, sec = self.dend[97]) h.pt3dadd(451.5, -287, 89.5, 1.8, sec = self.dend[97]) h.pt3dadd(453, -284.5, 89.5, 1.8, sec = self.dend[97]) h.pt3dadd(452.5, -288.5, 89.5, 1.8, sec = self.dend[97]) h.pt3dadd(453.5, -289.5, 91.5, 1.6, sec = self.dend[97]) h.pt3dadd(455.5, -289.5, 91.5, 1.4, sec = self.dend[97]) h.pt3dadd(456.5, -290, 91.5, 1.4, sec = self.dend[97]) h.pt3dadd(456, -291.5, 91.5, 1.1, sec = self.dend[97]) h.pt3dadd(456, -293, 91.5, 1.1, sec = self.dend[97]) h.pt3dadd(456, -296, 93.5, 0.9, sec = self.dend[97]) h.pt3dadd(455, -300.5, 99, 1.1, sec = self.dend[97]) h.pt3dadd(457, -301, 100, 0.6, sec = self.dend[97]) h.pt3dadd(458, -302, 101.5, 0.8, sec = self.dend[97]) h.pt3dadd(456, -303, 101.5, 0.2, sec = self.dend[97]) h.pt3dadd(456, -305, 101.5, 0.2, sec = self.dend[97]) h.pt3dadd(456, -306, 101.5, 0.2, sec = self.dend[97]) h.pt3dadd(458, -308.5, 102.5, 0.2, sec = self.dend[97]) h.pt3dadd(458.5, -310, 102.5, 0.2, sec = self.dend[97]) h.pt3dadd(459, -312, 102.5, 1.8, sec = self.dend[97]) h.pt3dadd(461.5, -312, 101.5, 3.3, sec = self.dend[97]) h.pt3dadd(468.5, -316, 104, 3.4, sec = self.dend[97]) h.pt3dadd(475, -351.5, 113.5, 3.4, sec = self.dend[97]) h.pt3dadd(482.5, -353, 110.5, 2.1, sec = self.dend[97]) h.pt3dadd(484, -354, 113.5, 1.8, sec = self.dend[97]) h.pt3dadd(484.5, -357, 113.5, 1.8, sec = self.dend[97]) h.pt3dadd(482, -357, 114.5, 2.1, sec = self.dend[97]) h.pt3dadd(483.5, -352, 112, 2, sec = self.dend[97]) h.pt3dadd(484, -351, 114.5, 1.5, sec = self.dend[97]) h.pt3dadd(485, -348.5, 114.5, 1.9, sec = self.dend[97]) h.pt3dadd(486, -345.5, 114.5, 1.9, sec = self.dend[97]) h.pt3dadd(486, -342.5, 116, 2.1, sec = self.dend[97]) h.pt3dclear(sec = self.dend[98]) h.pt3dadd(248.5, -92, 54.5, 8.3, sec = self.dend[98]) h.pt3dadd(253.5, -91, 51, 3.8, sec = self.dend[98]) h.pt3dadd(257, -91, 51, 3.8, sec = self.dend[98]) h.pt3dadd(260, -90, 51, 4.2, sec = self.dend[98]) h.pt3dadd(263, -90, 51, 4.3, sec = self.dend[98]) h.pt3dadd(266.5, -90, 51, 4.1, sec = self.dend[98]) h.pt3dadd(269, -89, 51, 3.4, sec = self.dend[98]) h.pt3dadd(273, -87, 51, 3.4, sec = self.dend[98]) h.pt3dadd(276.5, -85, 51, 4.5, sec = self.dend[98]) h.pt3dadd(281, -82.5, 54.5, 4.5, sec = self.dend[98]) h.pt3dadd(284.5, -81.5, 54.5, 4.5, sec = self.dend[98]) h.pt3dadd(288, -81.5, 54.5, 4, sec = self.dend[98]) h.pt3dadd(291.5, -81.5, 54.5, 3.5, sec = self.dend[98]) h.pt3dadd(295, -80.5, 54.5, 3.7, sec = self.dend[98]) h.pt3dadd(298.5, -78, 54.5, 4.4, sec = self.dend[98]) h.pt3dadd(302.5, -75.5, 54.5, 4.6, sec = self.dend[98]) h.pt3dadd(307, -72.5, 54.5, 4.6, sec = self.dend[98]) h.pt3dadd(311, -71.5, 54.5, 4.6, sec = self.dend[98]) h.pt3dadd(315, -71.5, 54.5, 4.6, sec = self.dend[98]) h.pt3dadd(320, -71, 54.5, 6, sec = self.dend[98]) h.pt3dclear(sec = self.dend[99]) h.pt3dadd(320, -71, 54.5, 6, sec = self.dend[99]) h.pt3dadd(322.5, -73.5, 56.5, 3.4, sec = self.dend[99]) h.pt3dadd(325.5, -73.5, 51, 2.3, sec = self.dend[99]) h.pt3dadd(328.5, -76.5, 56.5, 2.1, sec = self.dend[99]) h.pt3dadd(331, -79.5, 53, 2, sec = self.dend[99]) h.pt3dadd(338.5, -82.5, 57.5, 5.4, sec = self.dend[99]) h.pt3dclear(sec = self.dend[100]) h.pt3dadd(338.5, -82.5, 57.5, 5.4, sec = self.dend[100]) h.pt3dadd(345, -82.5, 57.5, 2.9, sec = self.dend[100]) h.pt3dadd(349, -84.5, 47.5, 2.9, sec = self.dend[100]) h.pt3dadd(352.5, -85, 49, 3.5, sec = self.dend[100]) h.pt3dadd(357, -85.5, 49, 4.1, sec = self.dend[100]) h.pt3dadd(359, -86, 49, 4.1, sec = self.dend[100]) h.pt3dadd(361, -87, 49, 4, sec = self.dend[100]) h.pt3dadd(362.5, -87.5, 49, 3.3, sec = self.dend[100]) h.pt3dadd(366, -89, 49, 2.5, sec = self.dend[100]) h.pt3dadd(368, -89.5, 49, 2.7, sec = self.dend[100]) h.pt3dadd(371, -91, 47.5, 2.7, sec = self.dend[100]) h.pt3dadd(373.5, -93.5, 47.5, 2.9, sec = self.dend[100]) h.pt3dadd(376.5, -95, 47.5, 2.5, sec = self.dend[100]) h.pt3dadd(377.5, -96.5, 47.5, 1.9, sec = self.dend[100]) h.pt3dadd(379.5, -98.5, 49, 2.4, sec = self.dend[100]) h.pt3dadd(381, -101, 49, 2.5, sec = self.dend[100]) h.pt3dadd(381.5, -104, 49, 2.7, sec = self.dend[100]) h.pt3dadd(382.5, -107.5, 50.5, 2.8, sec = self.dend[100]) h.pt3dadd(384, -112, 50.5, 2.3, sec = self.dend[100]) h.pt3dadd(384.5, -113.5, 50.5, 2.1, sec = self.dend[100]) h.pt3dadd(385.5, -115, 50.5, 1.8, sec = self.dend[100]) h.pt3dadd(388, -117, 50.5, 1.6, sec = self.dend[100]) h.pt3dadd(388.5, -118, 50.5, 1.8, sec = self.dend[100]) h.pt3dadd(390.5, -122, 47.5, 1.6, sec = self.dend[100]) h.pt3dadd(393.5, -124.5, 47.5, 1.9, sec = self.dend[100]) h.pt3dadd(396, -125, 47.5, 2.5, sec = self.dend[100]) h.pt3dadd(397.5, -126.5, 47.5, 3.7, sec = self.dend[100]) h.pt3dadd(398.5, -128.5, 47.5, 3.7, sec = self.dend[100]) h.pt3dclear(sec = self.dend[101]) h.pt3dadd(398.5, -128.5, 47.5, 3.7, sec = self.dend[101]) h.pt3dadd(398.5, -123, 43, 0.2, sec = self.dend[101]) h.pt3dadd(396.5, -118.5, 47.5, 0.2, sec = self.dend[101]) h.pt3dadd(396.5, -111, 49, 0.1, sec = self.dend[101]) h.pt3dadd(391.5, -109, 49, 0.1, sec = self.dend[101]) h.pt3dadd(385, -106, 47.5, 0.1, sec = self.dend[101]) h.pt3dadd(381, -109.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(378, -113.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(377.5, -117.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(376.5, -122.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(376.5, -125, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(376.5, -130.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(372.5, -132, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(369, -134, 47.5, 0.1, sec = self.dend[101]) h.pt3dadd(365.5, -136.5, 50.5, 0.1, sec = self.dend[101]) h.pt3dadd(362, -138, 51.5, 0.1, sec = self.dend[101]) h.pt3dadd(359.5, -140, 53, 0.1, sec = self.dend[101]) h.pt3dadd(358, -141.5, 56, 1.2, sec = self.dend[101]) h.pt3dadd(358, -144, 56, 1.2, sec = self.dend[101]) h.pt3dadd(358.5, -146.5, 56, 1.2, sec = self.dend[101]) h.pt3dadd(361.5, -146.5, 56, 1.2, sec = self.dend[101]) h.pt3dadd(362.5, -146.5, 53, 1.2, sec = self.dend[101]) h.pt3dadd(365, -146, 53, 1.2, sec = self.dend[101]) h.pt3dadd(366.5, -146, 54.5, 0.9, sec = self.dend[101]) h.pt3dadd(366, -146.5, 40.5, 0.7, sec = self.dend[101]) h.pt3dadd(365.5, -148, 41.5, 0.7, sec = self.dend[101]) h.pt3dadd(369, -148, 41.5, 0.7, sec = self.dend[101]) h.pt3dadd(369, -150, 43, 0.4, sec = self.dend[101]) h.pt3dadd(371.5, -150, 39, 0.4, sec = self.dend[101]) h.pt3dadd(371.5, -151, 40.5, 0.4, sec = self.dend[101]) h.pt3dadd(371.5, -153, 40.5, 0.4, sec = self.dend[101]) h.pt3dadd(374, -153, 40.5, 0.4, sec = self.dend[101]) h.pt3dadd(376.5, -153.5, 40.5, 0.4, sec = self.dend[101]) h.pt3dadd(376.5, -154.5, 40.5, 0.4, sec = self.dend[101]) h.pt3dadd(380, -156, 40.5, 0.3, sec = self.dend[101]) h.pt3dadd(379.5, -155, 40.5, 0.3, sec = self.dend[101]) h.pt3dadd(381, -155, 40.5, 0.3, sec = self.dend[101]) h.pt3dadd(381, -152.5, 37.5, 0.3, sec = self.dend[101]) h.pt3dclear(sec = self.dend[102]) h.pt3dadd(398.5, -128.5, 47.5, 3.7, sec = self.dend[102]) h.pt3dadd(402, -131.5, 49, 1.5, sec = self.dend[102]) h.pt3dadd(405, -134, 50.5, 1.4, sec = self.dend[102]) h.pt3dadd(408, -136, 50.5, 1.4, sec = self.dend[102]) h.pt3dadd(409.5, -138.5, 40.5, 2, sec = self.dend[102]) h.pt3dadd(412.5, -140.5, 41.5, 2.2, sec = self.dend[102]) h.pt3dadd(414, -144, 41.5, 2.7, sec = self.dend[102]) h.pt3dadd(417.5, -146, 41.5, 2.9, sec = self.dend[102]) h.pt3dadd(419, -148.5, 41.5, 2.9, sec = self.dend[102]) h.pt3dadd(422, -149.5, 41.5, 2.9, sec = self.dend[102]) h.pt3dadd(425, -149.5, 41.5, 1.4, sec = self.dend[102]) h.pt3dadd(428, -151.5, 39, 1.4, sec = self.dend[102]) h.pt3dadd(431, -153, 37.5, 1.8, sec = self.dend[102]) h.pt3dadd(432, -155, 37.5, 1.8, sec = self.dend[102]) h.pt3dadd(434, -155, 37.5, 1.9, sec = self.dend[102]) h.pt3dadd(435, -157.5, 33, 1.7, sec = self.dend[102]) h.pt3dadd(436.5, -158, 34.5, 1.8, sec = self.dend[102]) h.pt3dadd(439, -158, 34.5, 1.6, sec = self.dend[102]) h.pt3dadd(440, -159.5, 34.5, 2.1, sec = self.dend[102]) h.pt3dadd(442, -160.5, 34.5, 1.2, sec = self.dend[102]) h.pt3dadd(443, -160.5, 34.5, 1.2, sec = self.dend[102]) h.pt3dadd(445, -164, 34.5, 1.3, sec = self.dend[102]) h.pt3dadd(444.5, -167, 34.5, 1, sec = self.dend[102]) h.pt3dadd(448, -168, 23.5, 2.5, sec = self.dend[102]) h.pt3dadd(450.5, -168.5, 20.5, 4.3, sec = self.dend[102]) h.pt3dadd(452.5, -169.5, 18, 3.7, sec = self.dend[102]) h.pt3dadd(454, -170, 18, 3.1, sec = self.dend[102]) h.pt3dadd(455.5, -170, 15, 2.2, sec = self.dend[102]) h.pt3dadd(457.5, -170, 12.5, 2.2, sec = self.dend[102]) h.pt3dadd(459, -170, 12.5, 1.6, sec = self.dend[102]) h.pt3dadd(461.5, -169.5, 9.5, 1.2, sec = self.dend[102]) h.pt3dadd(462.5, -169.5, 9.5, 1.2, sec = self.dend[102]) h.pt3dadd(464, -169.5, 9.5, 1.3, sec = self.dend[102]) h.pt3dadd(465, -170, 9.5, 2.1, sec = self.dend[102]) h.pt3dadd(467, -172, 9.5, 3.3, sec = self.dend[102]) h.pt3dadd(469.5, -172.5, 6.5, 3.3, sec = self.dend[102]) h.pt3dadd(470.5, -172.5, 6.5, 3.3, sec = self.dend[102]) h.pt3dadd(472.5, -173.5, 6.5, 3.3, sec = self.dend[102]) h.pt3dadd(475, -174, 4, 3.3, sec = self.dend[102]) h.pt3dclear(sec = self.dend[103]) h.pt3dadd(475, -174, 4, 3.3, sec = self.dend[103]) h.pt3dadd(476.5, -176.5, 1, 0.1, sec = self.dend[103]) h.pt3dadd(479, -177.5, 1, 0.1, sec = self.dend[103]) h.pt3dadd(480, -178, -4.5, 0.9, sec = self.dend[103]) h.pt3dadd(481, -179, -4.5, 0.6, sec = self.dend[103]) h.pt3dadd(483.5, -180, -4.5, 0.5, sec = self.dend[103]) h.pt3dadd(484.5, -182, -7, 0.5, sec = self.dend[103]) h.pt3dadd(486, -183.5, -7, 0.4, sec = self.dend[103]) h.pt3dadd(487, -185, -7, 1.1, sec = self.dend[103]) h.pt3dadd(490, -187, -7, 0.3, sec = self.dend[103]) h.pt3dadd(491, -187, -7, 0.3, sec = self.dend[103]) h.pt3dadd(492.5, -188, -10, 1.2, sec = self.dend[103]) h.pt3dadd(493.5, -188.5, -10, 1.3, sec = self.dend[103]) h.pt3dadd(495, -190, -4.5, 0.9, sec = self.dend[103]) h.pt3dadd(496, -190.5, -10, 0.3, sec = self.dend[103]) h.pt3dadd(497.5, -191.5, -1.5, 0.1, sec = self.dend[103]) h.pt3dadd(499.5, -193.5, -1.5, 0.1, sec = self.dend[103]) h.pt3dadd(499.5, -194.5, -1.5, 0.8, sec = self.dend[103]) h.pt3dadd(501, -195.5, -4.5, 1, sec = self.dend[103]) h.pt3dadd(501, -197.5, -4.5, 0.1, sec = self.dend[103]) h.pt3dadd(502, -197.5, -4.5, 0.1, sec = self.dend[103]) h.pt3dadd(503.5, -200, -4.5, 0.1, sec = self.dend[103]) h.pt3dadd(504.5, -201.5, -1.5, 1, sec = self.dend[103]) h.pt3dadd(505, -203.5, -7, 0.1, sec = self.dend[103]) h.pt3dadd(506, -205.5, -12.5, 0.1, sec = self.dend[103]) h.pt3dclear(sec = self.dend[104]) h.pt3dadd(475, -174, 4, 3.3, sec = self.dend[104]) h.pt3dadd(476.5, -174, 1, 2.8, sec = self.dend[104]) h.pt3dadd(479, -175, 1, 2, sec = self.dend[104]) h.pt3dadd(480.5, -175, 1, 1.3, sec = self.dend[104]) h.pt3dadd(483, -175, 1, 1.5, sec = self.dend[104]) h.pt3dadd(483.5, -175, 1, 1.6, sec = self.dend[104]) h.pt3dadd(484.5, -175, 1, 1.7, sec = self.dend[104]) h.pt3dadd(485.5, -175.5, -1.5, 1.7, sec = self.dend[104]) h.pt3dadd(487.5, -176.5, -1.5, 1.7, sec = self.dend[104]) h.pt3dadd(489.5, -176.5, -1.5, 1.9, sec = self.dend[104]) h.pt3dadd(491, -177, -1.5, 1.9, sec = self.dend[104]) h.pt3dadd(493, -177, -1.5, 1.7, sec = self.dend[104]) h.pt3dadd(494.5, -177, -1.5, 1.7, sec = self.dend[104]) h.pt3dadd(496, -177, -1.5, 1.6, sec = self.dend[104]) h.pt3dadd(498, -176.5, -1.5, 1.6, sec = self.dend[104]) h.pt3dadd(500, -176.5, -4.5, 1.8, sec = self.dend[104]) h.pt3dadd(501.5, -176, -7, 2.2, sec = self.dend[104]) h.pt3dadd(504.5, -175.5, -7, 2.7, sec = self.dend[104]) h.pt3dadd(507, -175, -10, 2.1, sec = self.dend[104]) h.pt3dadd(508.5, -173.5, 1, 1.9, sec = self.dend[104]) h.pt3dadd(510, -173, 4, 1.3, sec = self.dend[104]) h.pt3dadd(513, -174, 1, 1.7, sec = self.dend[104]) h.pt3dadd(515.5, -174.5, 1, 2.4, sec = self.dend[104]) h.pt3dadd(518, -174.5, 1, 3.4, sec = self.dend[104]) h.pt3dadd(520, -174.5, 1, 3.8, sec = self.dend[104]) h.pt3dadd(523, -174.5, -4.5, 1.7, sec = self.dend[104]) h.pt3dadd(525.5, -174.5, -1.5, 1.2, sec = self.dend[104]) h.pt3dadd(527.5, -174, -4.5, 1.2, sec = self.dend[104]) h.pt3dadd(531, -173.5, -1.5, 1.3, sec = self.dend[104]) h.pt3dclear(sec = self.dend[105]) h.pt3dadd(338.5, -82.5, 57.5, 5.4, sec = self.dend[105]) h.pt3dadd(337.5, -86, 57.5, 2.6, sec = self.dend[105]) h.pt3dadd(338, -89, 49, 2, sec = self.dend[105]) h.pt3dclear(sec = self.dend[106]) h.pt3dadd(320, -71, 54.5, 6, sec = self.dend[106]) h.pt3dadd(324.5, -69, 56.5, 2.6, sec = self.dend[106]) h.pt3dadd(327, -67, 56.5, 2.7, sec = self.dend[106]) h.pt3dadd(327.5, -67, 56.5, 3, sec = self.dend[106]) h.pt3dadd(328.5, -64.5, 58.5, 1.8, sec = self.dend[106]) h.pt3dadd(331, -64.5, 56.5, 1.3, sec = self.dend[106]) h.pt3dadd(332.5, -64.5, 56.5, 1.3, sec = self.dend[106]) h.pt3dadd(333.5, -63, 56.5, 2.6, sec = self.dend[106]) h.pt3dadd(335, -63, 60, 3.7, sec = self.dend[106]) h.pt3dadd(338, -63, 60, 2.6, sec = self.dend[106]) h.pt3dadd(340.5, -61, 60, 1.8, sec = self.dend[106]) h.pt3dadd(343, -61, 60, 1.5, sec = self.dend[106]) h.pt3dadd(346, -61, 60, 1.7, sec = self.dend[106]) h.pt3dadd(348, -61, 62, 2.3, sec = self.dend[106]) h.pt3dadd(350.5, -62, 58.5, 1.9, sec = self.dend[106]) h.pt3dadd(353, -62, 58.5, 1.4, sec = self.dend[106]) h.pt3dadd(355.5, -62, 58.5, 1.4, sec = self.dend[106]) h.pt3dadd(356.5, -62, 58.5, 1.5, sec = self.dend[106]) h.pt3dadd(358, -62, 58.5, 1.5, sec = self.dend[106]) h.pt3dadd(360.5, -62, 58.5, 1.5, sec = self.dend[106]) h.pt3dadd(363, -63, 58.5, 2, sec = self.dend[106]) h.pt3dadd(365, -63, 58.5, 2.6, sec = self.dend[106]) h.pt3dadd(367.5, -62.5, 58.5, 3.1, sec = self.dend[106]) h.pt3dadd(371.5, -62.5, 58.5, 3.2, sec = self.dend[106]) h.pt3dadd(374.5, -63.5, 58.5, 2.7, sec = self.dend[106]) h.pt3dadd(376, -64, 56.5, 2.1, sec = self.dend[106]) h.pt3dadd(379, -64, 56.5, 1.8, sec = self.dend[106]) h.pt3dadd(381.5, -64, 56.5, 2.4, sec = self.dend[106]) h.pt3dadd(385.5, -64, 56.5, 2.3, sec = self.dend[106]) h.pt3dadd(388, -63, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(390, -61, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(393, -61.5, 56.5, 1.7, sec = self.dend[106]) h.pt3dadd(397, -61.5, 56.5, 1.9, sec = self.dend[106]) h.pt3dadd(399, -61.5, 56.5, 2.7, sec = self.dend[106]) h.pt3dadd(402, -60, 56.5, 3.2, sec = self.dend[106]) h.pt3dadd(404.5, -60, 56.5, 2.1, sec = self.dend[106]) h.pt3dadd(406.5, -60, 56.5, 1.6, sec = self.dend[106]) h.pt3dadd(410, -60, 56.5, 1.8, sec = self.dend[106]) h.pt3dadd(413.5, -59.5, 56.5, 2, sec = self.dend[106]) h.pt3dadd(415.5, -57, 56.5, 2, sec = self.dend[106]) h.pt3dadd(417.5, -57, 56.5, 2, sec = self.dend[106]) h.pt3dadd(421.5, -57.5, 56.5, 2, sec = self.dend[106]) h.pt3dadd(423.5, -56, 56.5, 2.1, sec = self.dend[106]) h.pt3dadd(426.5, -56, 56.5, 2.1, sec = self.dend[106]) h.pt3dadd(428.5, -56, 56.5, 1.8, sec = self.dend[106]) h.pt3dadd(433, -56, 56.5, 1.8, sec = self.dend[106]) h.pt3dadd(434.5, -56, 54.5, 1.8, sec = self.dend[106]) h.pt3dadd(437, -55.5, 54.5, 1.8, sec = self.dend[106]) h.pt3dadd(441.5, -53.5, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(443, -52, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(445.5, -51.5, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(450.5, -49, 54.5, 1.8, sec = self.dend[106]) h.pt3dadd(454, -47.5, 53, 1.5, sec = self.dend[106]) h.pt3dadd(456.5, -47.5, 53, 1, sec = self.dend[106]) h.pt3dadd(458, -49, 53, 0.8, sec = self.dend[106]) h.pt3dadd(460.5, -49, 53, 0.8, sec = self.dend[106]) h.pt3dadd(463, -49, 51, 0.8, sec = self.dend[106]) h.pt3dadd(466, -48.5, 51, 2.1, sec = self.dend[106]) h.pt3dadd(468.5, -48, 51, 3.3, sec = self.dend[106]) h.pt3dadd(471, -47.5, 51, 3.3, sec = self.dend[106]) h.pt3dadd(474.5, -46.5, 51, 1.7, sec = self.dend[106]) h.pt3dadd(477, -46.5, 51, 1.7, sec = self.dend[106]) h.pt3dadd(479.5, -46.5, 51, 2.9, sec = self.dend[106]) h.pt3dadd(482, -46, 51, 3.2, sec = self.dend[106]) h.pt3dadd(487, -46, 51, 3.2, sec = self.dend[106]) h.pt3dadd(489.5, -44, 49.5, 1.5, sec = self.dend[106]) h.pt3dadd(492.5, -44, 49.5, 1.4, sec = self.dend[106]) h.pt3dadd(495.5, -44, 49.5, 1.4, sec = self.dend[106]) h.pt3dadd(498.5, -44, 49.5, 1.4, sec = self.dend[106]) h.pt3dadd(501, -44, 49.5, 1.4, sec = self.dend[106]) h.pt3dadd(502, -44, 49.5, 1.9, sec = self.dend[106]) h.pt3dadd(503, -45, 49.5, 2.5, sec = self.dend[106]) h.pt3dadd(505, -45.5, 49.5, 3.4, sec = self.dend[106]) h.pt3dadd(506.5, -47.5, 49.5, 1.8, sec = self.dend[106]) h.pt3dadd(509, -47.5, 49.5, 1.8, sec = self.dend[106]) h.pt3dadd(510.5, -47.5, 49.5, 2.5, sec = self.dend[106]) h.pt3dadd(512.5, -47.5, 49.5, 3.4, sec = self.dend[106]) h.pt3dadd(515.5, -48.5, 49.5, 2.3, sec = self.dend[106]) h.pt3dadd(517.5, -48.5, 49.5, 1.9, sec = self.dend[106]) h.pt3dadd(520, -49, 49.5, 2.4, sec = self.dend[106]) h.pt3dadd(523, -49, 49.5, 2.3, sec = self.dend[106]) h.pt3dadd(525, -49.5, 51, 2.6, sec = self.dend[106]) h.pt3dadd(528.5, -50, 51, 2, sec = self.dend[106]) h.pt3dadd(531, -50, 51, 1.6, sec = self.dend[106]) h.pt3dadd(535, -51.5, 51, 1.6, sec = self.dend[106]) h.pt3dadd(538.5, -51.5, 51, 1.3, sec = self.dend[106]) h.pt3dadd(543.5, -51.5, 51, 1.3, sec = self.dend[106]) h.pt3dadd(546.5, -51, 51, 1.3, sec = self.dend[106]) h.pt3dadd(548, -50.5, 51, 1.6, sec = self.dend[106]) h.pt3dadd(550, -49, 51, 2.2, sec = self.dend[106]) h.pt3dadd(552, -48.5, 51, 2.2, sec = self.dend[106]) h.pt3dadd(555, -46.5, 51, 2.2, sec = self.dend[106]) h.pt3dadd(557, -45.5, 51, 1.7, sec = self.dend[106]) h.pt3dadd(558, -44, 51, 1.2, sec = self.dend[106]) h.pt3dadd(562, -42, 51, 1.5, sec = self.dend[106]) h.pt3dadd(564.5, -40, 51, 1.5, sec = self.dend[106]) h.pt3dadd(568.5, -38.5, 49.5, 1.2, sec = self.dend[106]) h.pt3dadd(570, -36.5, 47.5, 0.9, sec = self.dend[106]) h.pt3dadd(571.5, -36.5, 47.5, 0.9, sec = self.dend[106]) h.pt3dadd(574, -36, 53, 1.6, sec = self.dend[106]) h.pt3dadd(577, -36, 54.5, 2, sec = self.dend[106]) h.pt3dadd(579.5, -35, 54.5, 2.5, sec = self.dend[106]) h.pt3dadd(583.5, -35, 51, 2.8, sec = self.dend[106]) h.pt3dadd(587, -35.5, 53, 1.6, sec = self.dend[106]) h.pt3dadd(588.5, -35.5, 53, 1.2, sec = self.dend[106]) h.pt3dadd(591, -35.5, 53, 1.1, sec = self.dend[106]) h.pt3dadd(592.5, -35.5, 53, 1.7, sec = self.dend[106]) h.pt3dadd(595.5, -35.5, 53, 1.3, sec = self.dend[106]) h.pt3dadd(598.5, -34.5, 53, 1.4, sec = self.dend[106]) h.pt3dadd(600.5, -34.5, 53, 1.8, sec = self.dend[106]) h.pt3dadd(603.5, -34.5, 53, 1.8, sec = self.dend[106]) h.pt3dadd(605.5, -33, 53, 2.4, sec = self.dend[106]) h.pt3dadd(608.5, -33, 53, 3.2, sec = self.dend[106]) h.pt3dadd(611.5, -31.5, 53, 1.8, sec = self.dend[106]) h.pt3dadd(613.5, -31.5, 49.5, 1.2, sec = self.dend[106]) h.pt3dadd(618.5, -31.5, 49.5, 1.2, sec = self.dend[106]) h.pt3dadd(623, -31.5, 56.5, 1.2, sec = self.dend[106]) h.pt3dadd(628.5, -31.5, 56.5, 1.2, sec = self.dend[106]) h.pt3dadd(633, -31.5, 54.5, 1.2, sec = self.dend[106]) h.pt3dadd(633.5, -30, 54.5, 2, sec = self.dend[106]) h.pt3dadd(636, -28, 54.5, 2, sec = self.dend[106]) h.pt3dadd(639.5, -27.5, 54.5, 1.9, sec = self.dend[106]) h.pt3dadd(641.5, -26.5, 54.5, 1.6, sec = self.dend[106]) h.pt3dadd(643, -25, 54.5, 0.8, sec = self.dend[106]) h.pt3dadd(646, -25, 54.5, 1.5, sec = self.dend[106]) h.pt3dadd(649, -25.5, 54.5, 1.4, sec = self.dend[106]) h.pt3dadd(651, -26, 54.5, 1.6, sec = self.dend[106]) h.pt3dadd(655, -26, 54.5, 1, sec = self.dend[106]) h.pt3dadd(657, -25.5, 54.5, 0.7, sec = self.dend[106]) h.pt3dadd(659.5, -25.5, 58.5, 0.7, sec = self.dend[106]) h.pt3dadd(661, -24, 58.5, 1.1, sec = self.dend[106]) h.pt3dadd(662.5, -22.5, 56.5, 1.8, sec = self.dend[106]) h.pt3dadd(664.5, -22.5, 56.5, 2.5, sec = self.dend[106]) h.pt3dadd(666, -20.5, 58.5, 2, sec = self.dend[106]) h.pt3dadd(672, -17, 60, 1.6, sec = self.dend[106]) h.pt3dadd(673, -14, 60, 1.5, sec = self.dend[106]) h.pt3dadd(674.5, -14, 60, 1.5, sec = self.dend[106]) h.pt3dadd(674.5, -12, 60, 1.5, sec = self.dend[106]) h.pt3dadd(676, -12.5, 60, 1.7, sec = self.dend[106]) h.pt3dadd(677, -13, 60, 2.5, sec = self.dend[106]) h.pt3dadd(679.5, -11, 60, 1.6, sec = self.dend[106]) h.pt3dadd(682, -7, 60, 1.6, sec = self.dend[106]) h.pt3dadd(685, -7, 58.5, 1.6, sec = self.dend[106]) h.pt3dadd(686.5, -8, 64.5, 1.6, sec = self.dend[106]) h.pt3dadd(687.5, -8, 64.5, 1.8, sec = self.dend[106]) h.pt3dadd(690, -8, 61.5, 1.6, sec = self.dend[106]) h.pt3dadd(691, -6.5, 61.5, 1.6, sec = self.dend[106]) h.pt3dadd(693, -4.5, 61.5, 1.6, sec = self.dend[106]) h.pt3dadd(694, -2, 64.5, 1.2, sec = self.dend[106]) h.pt3dadd(695.5, -1, 63, 1.7, sec = self.dend[106]) h.pt3dadd(696, -3, 64.5, 1.7, sec = self.dend[106]) h.pt3dadd(697.5, -1.5, 64.5, 1.2, sec = self.dend[106]) h.pt3dadd(698, 0.5, 64.5, 1.2, sec = self.dend[106]) h.pt3dadd(699.5, 2.5, 66, 1.2, sec = self.dend[106]) h.pt3dadd(701, 3.5, 64.5, 1.9, sec = self.dend[106]) h.pt3dadd(702.5, 4.5, 66, 1.9, sec = self.dend[106]) h.pt3dadd(702.5, 5, 66, 1.8, sec = self.dend[106]) h.pt3dadd(702, 8, 72, 1.9, sec = self.dend[106]) h.pt3dadd(702.5, 9, 72, 2.1, sec = self.dend[106]) h.pt3dadd(703.5, 11.5, 72, 2.2, sec = self.dend[106]) h.pt3dadd(704.5, 10, 72, 1.9, sec = self.dend[106]) h.pt3dadd(706, 9.5, 72, 1.7, sec = self.dend[106]) h.pt3dadd(708.5, 10.5, 72, 1.6, sec = self.dend[106]) h.pt3dadd(711, 11, 72, 1.8, sec = self.dend[106]) h.pt3dadd(713.5, 11, 75, 1.3, sec = self.dend[106]) h.pt3dadd(715.5, 10.5, 75, 1.3, sec = self.dend[106]) h.pt3dadd(722.5, 10.5, 78, 1.8, sec = self.dend[106]) h.pt3dadd(724, 10, 76.5, 1.2, sec = self.dend[106]) h.pt3dadd(725.5, 10, 84, 2.1, sec = self.dend[106]) h.pt3dadd(727, 9, 82.5, 1.2, sec = self.dend[106]) h.pt3dadd(727, 8.5, 84, 1.1, sec = self.dend[106]) h.pt3dadd(729.5, 7.5, 84, 1.1, sec = self.dend[106]) h.pt3dadd(731.5, 7, 84, 1.7, sec = self.dend[106]) h.pt3dadd(733.5, 3.5, 84, 2.5, sec = self.dend[106]) h.pt3dadd(735, 1.5, 84, 2.1, sec = self.dend[106]) h.pt3dadd(737, 1.5, 82.5, 1.2, sec = self.dend[106]) h.pt3dadd(738.5, 0.5, 82.5, 1.4, sec = self.dend[106]) h.pt3dadd(739.5, -0.5, 82.5, 1.6, sec = self.dend[106]) h.pt3dadd(742.5, -1, 82.5, 1.8, sec = self.dend[106]) h.pt3dadd(744, -1.5, 82.5, 1.4, sec = self.dend[106]) h.pt3dadd(746.5, -3, 91.5, 0.6, sec = self.dend[106]) h.pt3dadd(748.5, -3, 91.5, 0.7, sec = self.dend[106]) h.pt3dadd(751.5, -3.5, 91.5, 0.7, sec = self.dend[106]) h.pt3dadd(752.5, -3.5, 91.5, 1.3, sec = self.dend[106]) h.pt3dadd(752.5, -4, 91.5, 0.9, sec = self.dend[106]) h.pt3dadd(755.5, -3.5, 90, 0.6, sec = self.dend[106]) h.pt3dadd(759, -1.5, 90, 0.6, sec = self.dend[106]) h.pt3dadd(761, -1, 87, 0.6, sec = self.dend[106]) h.pt3dadd(762, -1.5, 88.5, 2.2, sec = self.dend[106]) h.pt3dadd(765, -1.5, 84, 0.6, sec = self.dend[106]) h.pt3dadd(768, 1.5, 88.5, 0.6, sec = self.dend[106]) h.pt3dadd(770.5, 1.5, 88.5, 0.6, sec = self.dend[106]) h.pt3dadd(775, 1, 88.5, 0.6, sec = self.dend[106]) h.pt3dadd(776.5, 1, 88.5, 0.6, sec = self.dend[106]) h.pt3dadd(777.5, -0.5, 85.5, 1.2, sec = self.dend[106]) h.pt3dadd(778.5, -1, 85.5, 0.7, sec = self.dend[106]) h.pt3dadd(780, -3.5, 87, 0.7, sec = self.dend[106]) h.pt3dadd(783.5, -4, 87, 1, sec = self.dend[106]) h.pt3dclear(sec = self.dend[107]) h.pt3dadd(49, -47, 26, 9.4, sec = self.dend[107]) h.pt3dadd(47.5, -53, 27.5, 5, sec = self.dend[107]) h.pt3dadd(46.5, -54.5, 30, 4.7, sec = self.dend[107]) h.pt3dadd(46.5, -56.5, 30, 4.9, sec = self.dend[107]) h.pt3dadd(45.5, -58, 31.5, 5.4, sec = self.dend[107]) h.pt3dadd(44.5, -59.5, 31.5, 4.9, sec = self.dend[107]) h.pt3dadd(43, -63.5, 33, 4.3, sec = self.dend[107]) h.pt3dadd(42.5, -65.5, 33, 4, sec = self.dend[107]) h.pt3dadd(41.5, -68, 33, 4.3, sec = self.dend[107]) h.pt3dadd(41.5, -70.5, 33, 4.3, sec = self.dend[107]) h.pt3dadd(40.5, -72.5, 33, 4.3, sec = self.dend[107]) h.pt3dadd(40.5, -73.5, 33, 4.3, sec = self.dend[107]) h.pt3dadd(39, -76, 33, 4, sec = self.dend[107]) h.pt3dadd(37.5, -78.5, 34.5, 4.7, sec = self.dend[107]) h.pt3dadd(37, -79, 34.5, 5.4, sec = self.dend[107]) h.pt3dadd(37, -81, 34.5, 6.8, sec = self.dend[107]) h.pt3dadd(34.5, -83, 34.5, 6.5, sec = self.dend[107]) h.pt3dadd(33, -87.5, 34.5, 6.5, sec = self.dend[107]) h.pt3dadd(34, -90, 34.5, 5.7, sec = self.dend[107]) h.pt3dadd(35, -93, 34.5, 5.2, sec = self.dend[107]) h.pt3dadd(35, -94, 34.5, 5.8, sec = self.dend[107]) h.pt3dadd(33.5, -95.5, 33, 4.6, sec = self.dend[107]) h.pt3dadd(31, -98, 33, 5, sec = self.dend[107]) h.pt3dadd(31, -100.5, 36, 4.1, sec = self.dend[107]) h.pt3dadd(31, -103.5, 36, 4.3, sec = self.dend[107]) h.pt3dadd(29.5, -107, 37.5, 4.3, sec = self.dend[107]) h.pt3dadd(29.5, -109.5, 37.5, 4.7, sec = self.dend[107]) h.pt3dadd(28.5, -112, 37.5, 4.8, sec = self.dend[107]) h.pt3dadd(28.5, -115, 37.5, 4.6, sec = self.dend[107]) h.pt3dadd(29.5, -117, 37.5, 5.4, sec = self.dend[107]) h.pt3dadd(28.5, -119.5, 37.5, 4.6, sec = self.dend[107]) h.pt3dadd(28.5, -122, 37.5, 4.6, sec = self.dend[107]) h.pt3dadd(27.5, -125, 37.5, 5.4, sec = self.dend[107]) h.pt3dadd(27.5, -128, 37.5, 6.7, sec = self.dend[107]) h.pt3dadd(27.5, -131, 37.5, 6.7, sec = self.dend[107]) h.pt3dadd(28.5, -133.5, 37.5, 5.7, sec = self.dend[107]) h.pt3dadd(29.5, -136.5, 37.5, 5.9, sec = self.dend[107]) h.pt3dadd(29.5, -139.5, 37.5, 5.9, sec = self.dend[107]) h.pt3dadd(29.5, -141.5, 37.5, 5.7, sec = self.dend[107]) h.pt3dadd(29.5, -144, 37.5, 5.4, sec = self.dend[107]) h.pt3dadd(29.5, -147.5, 39, 5.6, sec = self.dend[107]) h.pt3dadd(32.5, -148, 37.5, 5.6, sec = self.dend[107]) h.pt3dadd(32.5, -151, 39, 5.2, sec = self.dend[107]) h.pt3dadd(33.5, -154, 39, 4.9, sec = self.dend[107]) h.pt3dadd(35, -156, 39, 5, sec = self.dend[107]) h.pt3dadd(37, -156, 39, 5.2, sec = self.dend[107]) h.pt3dadd(38.5, -158, 39, 4.7, sec = self.dend[107]) h.pt3dadd(40.5, -161, 39, 5, sec = self.dend[107]) h.pt3dadd(41.5, -164, 39, 5.7, sec = self.dend[107]) h.pt3dadd(42.5, -168, 40, 6.5, sec = self.dend[107]) h.pt3dadd(44.5, -171, 43, 6.5, sec = self.dend[107]) h.pt3dadd(46.5, -174.5, 53, 5.8, sec = self.dend[107]) h.pt3dadd(49, -175.5, 54.5, 5.7, sec = self.dend[107]) h.pt3dadd(51, -179.5, 60, 4.9, sec = self.dend[107]) h.pt3dclear(sec = self.dend[108]) h.pt3dadd(51, -179.5, 60, 4.9, sec = self.dend[108]) h.pt3dadd(46, -179.5, 58, 1.6, sec = self.dend[108]) h.pt3dadd(42, -179.5, 58, 1.6, sec = self.dend[108]) h.pt3dadd(40.5, -180.5, 60, 1.6, sec = self.dend[108]) h.pt3dadd(39, -182, 60, 1.6, sec = self.dend[108]) h.pt3dadd(36, -184.5, 60, 1.6, sec = self.dend[108]) h.pt3dadd(34, -186, 60, 1.6, sec = self.dend[108]) h.pt3dadd(30.5, -187.5, 60, 1.6, sec = self.dend[108]) h.pt3dadd(28, -189.5, 60, 1.6, sec = self.dend[108]) h.pt3dadd(26, -190.5, 60, 1.6, sec = self.dend[108]) h.pt3dadd(23.5, -192, 60, 1.2, sec = self.dend[108]) h.pt3dadd(22, -192.5, 60, 1.2, sec = self.dend[108]) h.pt3dadd(22, -194.5, 60, 1.2, sec = self.dend[108]) h.pt3dadd(21, -196, 60, 1.2, sec = self.dend[108]) h.pt3dadd(19, -198, 60, 1.3, sec = self.dend[108]) h.pt3dadd(19, -199.5, 60, 1.3, sec = self.dend[108]) h.pt3dadd(17.5, -200.5, 60, 1.2, sec = self.dend[108]) h.pt3dadd(15.5, -200.5, 60, 1.3, sec = self.dend[108]) h.pt3dadd(12.5, -202, 65.5, 1.6, sec = self.dend[108]) h.pt3dadd(10, -205, 65.5, 1.6, sec = self.dend[108]) h.pt3dadd(7.5, -205, 67, 1.6, sec = self.dend[108]) h.pt3dadd(5, -205, 72.5, 1.2, sec = self.dend[108]) h.pt3dadd(2, -207, 70.5, 1.2, sec = self.dend[108]) h.pt3dadd(0, -208.5, 70.5, 1.4, sec = self.dend[108]) h.pt3dadd(-4.5, -211.5, 70.5, 1.5, sec = self.dend[108]) h.pt3dadd(-5.5, -214, 60, 0.1, sec = self.dend[108]) h.pt3dadd(-7, -215, 61.5, 0.1, sec = self.dend[108]) h.pt3dadd(-8.5, -214.5, 69, 0.9, sec = self.dend[108]) h.pt3dadd(-10.5, -213.5, 69, 0.9, sec = self.dend[108]) h.pt3dadd(-9, -215.5, 70.5, 0.9, sec = self.dend[108]) h.pt3dadd(-8, -216.5, 72, 0.9, sec = self.dend[108]) h.pt3dadd(-10.5, -217, 72, 0.9, sec = self.dend[108]) h.pt3dadd(-10.5, -219.5, 72, 0.9, sec = self.dend[108]) h.pt3dadd(-8, -218.5, 72, 1.1, sec = self.dend[108]) h.pt3dadd(-5.5, -217.5, 72, 1.4, sec = self.dend[108]) h.pt3dadd(-5, -220.5, 73.5, 1.4, sec = self.dend[108]) h.pt3dadd(-6.5, -222, 73.5, 1.8, sec = self.dend[108]) h.pt3dadd(-7.5, -221, 73.5, 1.9, sec = self.dend[108]) h.pt3dadd(-9.5, -221, 73.5, 1.4, sec = self.dend[108]) h.pt3dadd(-10.5, -221, 73.5, 1.3, sec = self.dend[108]) h.pt3dadd(-11.5, -219, 75, 1.1, sec = self.dend[108]) h.pt3dadd(-13, -218, 75, 1.2, sec = self.dend[108]) h.pt3dadd(-13.5, -221, 75, 0.9, sec = self.dend[108]) h.pt3dadd(-13.5, -222, 75, 1, sec = self.dend[108]) h.pt3dadd(-12.5, -223.5, 76.5, 1.6, sec = self.dend[108]) h.pt3dadd(-14.5, -224, 73.5, 1.6, sec = self.dend[108]) h.pt3dadd(-14, -225.5, 76.5, 2.5, sec = self.dend[108]) h.pt3dadd(-14.5, -227, 75, 1.5, sec = self.dend[108]) h.pt3dadd(-14, -229.5, 75, 1.2, sec = self.dend[108]) h.pt3dadd(-14, -231.5, 75, 1.2, sec = self.dend[108]) h.pt3dadd(-14, -233, 75, 1.2, sec = self.dend[108]) h.pt3dadd(-14.5, -234, 78, 1.2, sec = self.dend[108]) h.pt3dadd(-15, -237, 78, 1.4, sec = self.dend[108]) h.pt3dadd(-15, -237.5, 78, 1.7, sec = self.dend[108]) h.pt3dadd(-15, -239, 81, 2, sec = self.dend[108]) h.pt3dadd(-14.5, -241.5, 81, 2, sec = self.dend[108]) h.pt3dadd(-14, -241.5, 85.5, 2.1, sec = self.dend[108]) h.pt3dadd(-13.5, -245, 85.5, 1.4, sec = self.dend[108]) h.pt3dadd(-12, -245.5, 87, 1.7, sec = self.dend[108]) h.pt3dadd(-12, -247, 84, 1.6, sec = self.dend[108]) h.pt3dadd(-11, -249.5, 85.5, 1.3, sec = self.dend[108]) h.pt3dadd(-11, -251, 85.5, 1.4, sec = self.dend[108]) h.pt3dadd(-11, -252.5, 85.5, 1.6, sec = self.dend[108]) h.pt3dadd(-10, -254.5, 87, 1.3, sec = self.dend[108]) h.pt3dadd(-13, -257.5, 95, 1, sec = self.dend[108]) h.pt3dadd(-14.5, -259.5, 93, 0.7, sec = self.dend[108]) h.pt3dadd(-16, -261, 95, 1.2, sec = self.dend[108]) h.pt3dadd(-17.5, -263.5, 89, 1.1, sec = self.dend[108]) h.pt3dadd(-21, -265.5, 91, 1.1, sec = self.dend[108]) h.pt3dadd(-23.5, -265.5, 93, 0.9, sec = self.dend[108]) h.pt3dadd(-25.5, -267.5, 91, 0.9, sec = self.dend[108]) h.pt3dadd(-27.5, -269, 93, 1, sec = self.dend[108]) h.pt3dadd(-29.5, -270, 93, 1.1, sec = self.dend[108]) h.pt3dadd(-30.5, -271.5, 93, 1.3, sec = self.dend[108]) h.pt3dadd(-29.5, -273, 89, 1, sec = self.dend[108]) h.pt3dadd(-28, -273, 89, 1.2, sec = self.dend[108]) h.pt3dadd(-28.5, -275, 97, 0.9, sec = self.dend[108]) h.pt3dadd(-29.5, -276, 97, 1.5, sec = self.dend[108]) h.pt3dadd(-28.5, -278.5, 101, 1.9, sec = self.dend[108]) h.pt3dadd(-30.5, -278.5, 99, 0.9, sec = self.dend[108]) h.pt3dadd(-32, -280, 107, 0.6, sec = self.dend[108]) h.pt3dadd(-34, -282, 115, 0.6, sec = self.dend[108]) h.pt3dadd(-35, -283.5, 116.5, 2.4, sec = self.dend[108]) h.pt3dadd(-36, -289, 118, 1.9, sec = self.dend[108]) h.pt3dadd(-36.5, -291.5, 120.5, 1.2, sec = self.dend[108]) h.pt3dadd(-41, -294.5, 120.5, 1.6, sec = self.dend[108]) h.pt3dadd(-44, -296, 120.5, 1.8, sec = self.dend[108]) h.pt3dadd(-46, -296, 120.5, 1.7, sec = self.dend[108]) h.pt3dadd(-46, -292.5, 119, 1.7, sec = self.dend[108]) h.pt3dadd(-46, -292, 122, 1.3, sec = self.dend[108]) h.pt3dadd(-46, -288.5, 120.5, 0.1, sec = self.dend[108]) h.pt3dadd(-48.5, -291.5, 122, 0.1, sec = self.dend[108]) h.pt3dadd(-50.5, -295, 128.5, 0.1, sec = self.dend[108]) h.pt3dadd(-51.5, -294.5, 127, 0.1, sec = self.dend[108]) h.pt3dadd(-53.5, -292.5, 129.5, 0.1, sec = self.dend[108]) h.pt3dadd(-54.5, -293.5, 132.5, 0.1, sec = self.dend[108]) h.pt3dadd(-55, -294.5, 132.5, 0.1, sec = self.dend[108]) h.pt3dadd(-56, -296, 135, 0.1, sec = self.dend[108]) h.pt3dclear(sec = self.dend[109]) h.pt3dadd(-56, -296, 135, 0.1, sec = self.dend[109]) h.pt3dadd(-54.5, -298, 129.5, 0.2, sec = self.dend[109]) h.pt3dadd(-52.5, -298, 129.5, 0.2, sec = self.dend[109]) h.pt3dadd(-53, -298, 132.5, 0.2, sec = self.dend[109]) h.pt3dadd(-54, -300.5, 131, 0.2, sec = self.dend[109]) h.pt3dadd(-53.5, -300.5, 136.5, 0.2, sec = self.dend[109]) h.pt3dadd(-53.5, -304, 139, 2.8, sec = self.dend[109]) h.pt3dadd(-52, -303.5, 133.5, 2.4, sec = self.dend[109]) h.pt3dadd(-53.5, -306, 137.5, 1.6, sec = self.dend[109]) h.pt3dadd(-54, -306, 137.5, 0.6, sec = self.dend[109]) h.pt3dadd(-57, -302.5, 136.5, 0.6, sec = self.dend[109]) h.pt3dadd(-59.5, -302.5, 137.5, 0.6, sec = self.dend[109]) h.pt3dadd(-57.5, -306, 141.5, 0.8, sec = self.dend[109]) h.pt3dadd(-55.5, -308.5, 141.5, 0.6, sec = self.dend[109]) h.pt3dadd(-57.5, -310, 141.5, 0.4, sec = self.dend[109]) h.pt3dadd(-56.5, -312.5, 143, 0.4, sec = self.dend[109]) h.pt3dadd(-59.5, -312, 152, 0.4, sec = self.dend[109]) h.pt3dadd(-60.5, -309, 143, 0.5, sec = self.dend[109]) h.pt3dadd(-65, -309, 144, 0.4, sec = self.dend[109]) h.pt3dclear(sec = self.dend[110]) h.pt3dadd(-56, -296, 135, 0.1, sec = self.dend[110]) h.pt3dadd(-59, -296, 136.5, 0.1, sec = self.dend[110]) h.pt3dadd(-63, -298, 131, 0.1, sec = self.dend[110]) h.pt3dadd(-66, -300.5, 136.5, 0.3, sec = self.dend[110]) h.pt3dadd(-69, -299, 133.5, 0.2, sec = self.dend[110]) h.pt3dclear(sec = self.dend[111]) h.pt3dadd(51, -179.5, 60, 4.9, sec = self.dend[111]) h.pt3dadd(54, -180, 60, 3.4, sec = self.dend[111]) h.pt3dadd(56, -180, 58, 3.8, sec = self.dend[111]) h.pt3dadd(57, -181, 58, 5.8, sec = self.dend[111]) h.pt3dadd(60, -183.5, 56.5, 3.3, sec = self.dend[111]) h.pt3dadd(61.5, -185.5, 56.5, 4.1, sec = self.dend[111]) h.pt3dadd(61.5, -187.5, 56.5, 4.6, sec = self.dend[111]) h.pt3dadd(62.5, -189, 63.5, 4.3, sec = self.dend[111]) h.pt3dadd(65, -189.5, 61.5, 3.5, sec = self.dend[111]) h.pt3dadd(67.5, -191, 61.5, 4, sec = self.dend[111]) h.pt3dadd(69, -192, 60, 4.1, sec = self.dend[111]) h.pt3dadd(71, -193, 60, 4.9, sec = self.dend[111]) h.pt3dadd(72.5, -194.5, 60, 5, sec = self.dend[111]) h.pt3dadd(74.5, -194.5, 60, 5, sec = self.dend[111]) h.pt3dadd(74.5, -196.5, 60, 5, sec = self.dend[111]) h.pt3dadd(77, -199.5, 60, 5, sec = self.dend[111]) h.pt3dadd(80, -200.5, 70.5, 4.6, sec = self.dend[111]) h.pt3dadd(83, -201.5, 67, 4.3, sec = self.dend[111]) h.pt3dadd(84.5, -202.5, 67, 4.9, sec = self.dend[111]) h.pt3dadd(85.5, -203, 67, 5.2, sec = self.dend[111]) h.pt3dadd(86.5, -205.5, 67, 6.3, sec = self.dend[111]) h.pt3dadd(89, -207.5, 67, 5.6, sec = self.dend[111]) h.pt3dadd(92, -209, 67, 4.6, sec = self.dend[111]) h.pt3dadd(93, -210, 67, 5.4, sec = self.dend[111]) h.pt3dadd(96.5, -211.5, 67, 5.1, sec = self.dend[111]) h.pt3dadd(99.5, -218, 67, 6.2, sec = self.dend[111]) h.pt3dadd(101.5, -221, 67, 6.1, sec = self.dend[111]) h.pt3dadd(104.5, -222, 63.5, 5.6, sec = self.dend[111]) h.pt3dadd(106, -228, 63.5, 5.6, sec = self.dend[111]) h.pt3dadd(107.5, -231.5, 63.5, 5.6, sec = self.dend[111]) h.pt3dadd(109, -234, 70.5, 4.7, sec = self.dend[111]) h.pt3dadd(110.5, -236.5, 72.5, 4.6, sec = self.dend[111]) h.pt3dadd(110.5, -239, 69, 4.6, sec = self.dend[111]) h.pt3dadd(111.5, -247, 67, 5.4, sec = self.dend[111]) h.pt3dadd(112.5, -250, 69, 5.7, sec = self.dend[111]) h.pt3dadd(112.5, -253.5, 69, 5.6, sec = self.dend[111]) h.pt3dadd(113, -257.5, 69, 4.9, sec = self.dend[111]) h.pt3dadd(113, -259.5, 69, 4.9, sec = self.dend[111]) h.pt3dadd(114, -263, 69, 4.9, sec = self.dend[111]) h.pt3dadd(115, -267, 69, 4.9, sec = self.dend[111]) h.pt3dadd(115.5, -270, 69, 4.4, sec = self.dend[111]) h.pt3dadd(116.5, -272, 69, 4.4, sec = self.dend[111]) h.pt3dadd(116.5, -275, 69, 4.9, sec = self.dend[111]) h.pt3dadd(116.5, -277.5, 69, 4.9, sec = self.dend[111]) h.pt3dadd(116.5, -279.5, 69, 4.6, sec = self.dend[111]) h.pt3dadd(118.5, -283, 67, 4.4, sec = self.dend[111]) h.pt3dadd(119.5, -286, 67, 4.3, sec = self.dend[111]) h.pt3dadd(121, -290, 67, 4.3, sec = self.dend[111]) h.pt3dadd(123, -292, 67, 5.9, sec = self.dend[111]) h.pt3dadd(124, -292.5, 67, 6.2, sec = self.dend[111]) h.pt3dadd(124.5, -296.5, 67, 6.2, sec = self.dend[111]) h.pt3dadd(124.5, -298, 67, 4.9, sec = self.dend[111]) h.pt3dadd(124.5, -300.5, 67, 4.6, sec = self.dend[111]) h.pt3dadd(124.5, -304, 67, 5, sec = self.dend[111]) h.pt3dadd(126, -305.5, 72.5, 4.8, sec = self.dend[111]) h.pt3dadd(127, -307, 72.5, 4.9, sec = self.dend[111]) h.pt3dadd(127, -311, 70.5, 4.9, sec = self.dend[111]) h.pt3dadd(127, -314, 70.5, 4.9, sec = self.dend[111]) h.pt3dadd(127, -316.5, 70.5, 4.9, sec = self.dend[111]) h.pt3dadd(125, -319.5, 72.5, 5.2, sec = self.dend[111]) h.pt3dadd(127, -323, 77, 3.6, sec = self.dend[111]) h.pt3dadd(129.5, -324, 77, 3.3, sec = self.dend[111]) h.pt3dadd(131, -324.5, 77, 3.3, sec = self.dend[111]) h.pt3dadd(132.5, -327.5, 77, 3.8, sec = self.dend[111]) h.pt3dadd(133.5, -331, 77, 3.8, sec = self.dend[111]) h.pt3dadd(135.5, -333.5, 77, 4, sec = self.dend[111]) h.pt3dadd(137, -335.5, 77, 4, sec = self.dend[111]) h.pt3dadd(137.5, -338.5, 77, 4, sec = self.dend[111]) h.pt3dadd(137.5, -340, 77, 3.4, sec = self.dend[111]) h.pt3dadd(137.5, -342.5, 77, 3.8, sec = self.dend[111]) h.pt3dadd(139.5, -345, 77, 4, sec = self.dend[111]) h.pt3dadd(141, -348, 77, 4, sec = self.dend[111]) h.pt3dadd(141.5, -351, 77, 4, sec = self.dend[111]) h.pt3dadd(138.5, -353, 78.5, 5.5, sec = self.dend[111]) h.pt3dadd(138.5, -357, 78.5, 5.5, sec = self.dend[111]) h.pt3dadd(139, -361.5, 78.5, 4.9, sec = self.dend[111]) h.pt3dadd(137.5, -364, 77, 4.1, sec = self.dend[111]) h.pt3dadd(137, -366.5, 77, 4.1, sec = self.dend[111]) h.pt3dadd(136.5, -369, 77, 5.3, sec = self.dend[111]) h.pt3dadd(136.5, -370.5, 77, 4.9, sec = self.dend[111]) h.pt3dadd(137.5, -373, 77, 4.4, sec = self.dend[111]) h.pt3dadd(140, -375.5, 83, 4, sec = self.dend[111]) h.pt3dadd(139.5, -377.5, 84.5, 4.3, sec = self.dend[111]) h.pt3dadd(137, -381.5, 86, 4, sec = self.dend[111]) h.pt3dadd(137.5, -385.5, 86, 4, sec = self.dend[111]) h.pt3dadd(139.5, -385.5, 86, 4.9, sec = self.dend[111]) h.pt3dadd(140.5, -388.5, 86, 5.8, sec = self.dend[111]) h.pt3dadd(140, -391.5, 86, 4.6, sec = self.dend[111]) h.pt3dadd(141, -394, 86, 3.4, sec = self.dend[111]) h.pt3dadd(140, -396.5, 86, 3.2, sec = self.dend[111]) h.pt3dadd(140, -399, 86, 3.1, sec = self.dend[111]) h.pt3dadd(139.5, -402, 86, 3.7, sec = self.dend[111]) h.pt3dadd(140, -404, 86, 4.6, sec = self.dend[111]) h.pt3dadd(141.5, -406, 86, 6.3, sec = self.dend[111]) h.pt3dadd(143.5, -406.5, 86, 5.8, sec = self.dend[111]) h.pt3dadd(144.5, -409.5, 86, 4, sec = self.dend[111]) h.pt3dadd(145, -411.5, 86, 5.2, sec = self.dend[111]) h.pt3dadd(145.5, -413.5, 86, 6.5, sec = self.dend[111]) h.pt3dclear(sec = self.dend[112]) h.pt3dadd(145.5, -413.5, 86, 6.5, sec = self.dend[112]) h.pt3dadd(150.5, -414, 89, 1.2, sec = self.dend[112]) h.pt3dadd(151, -414, 89, 1.2, sec = self.dend[112]) h.pt3dadd(154, -414.5, 89, 0.7, sec = self.dend[112]) h.pt3dadd(154.5, -417, 89, 1, sec = self.dend[112]) h.pt3dadd(156.5, -417.5, 89, 1.2, sec = self.dend[112]) h.pt3dadd(159.5, -417, 89, 0.9, sec = self.dend[112]) h.pt3dadd(160, -419, 89, 0.9, sec = self.dend[112]) h.pt3dadd(160.5, -420.5, 87.5, 0.9, sec = self.dend[112]) h.pt3dadd(162.5, -420.5, 87.5, 0.9, sec = self.dend[112]) h.pt3dadd(166.5, -419.5, 87.5, 0.7, sec = self.dend[112]) h.pt3dadd(168.5, -422.5, 87.5, 0.7, sec = self.dend[112]) h.pt3dadd(169.5, -423, 87.5, 0.9, sec = self.dend[112]) h.pt3dadd(170, -424, 87.5, 1.1, sec = self.dend[112]) h.pt3dadd(172, -425, 87.5, 1.8, sec = self.dend[112]) h.pt3dadd(173, -427.5, 87.5, 1.3, sec = self.dend[112]) h.pt3dadd(174.5, -428, 86, 0.7, sec = self.dend[112]) h.pt3dadd(175.5, -429.5, 86, 0.8, sec = self.dend[112]) h.pt3dadd(177, -430, 86, 1.3, sec = self.dend[112]) h.pt3dadd(179, -430.5, 86, 1.8, sec = self.dend[112]) h.pt3dadd(180.5, -432.5, 84.5, 1, sec = self.dend[112]) h.pt3dadd(182, -432, 84.5, 0.9, sec = self.dend[112]) h.pt3dadd(182, -433, 84.5, 0.8, sec = self.dend[112]) h.pt3dadd(184.5, -434.5, 84.5, 0.9, sec = self.dend[112]) h.pt3dadd(184.5, -436.5, 84.5, 1.3, sec = self.dend[112]) h.pt3dadd(186.5, -440, 84.5, 1.4, sec = self.dend[112]) h.pt3dadd(189.5, -440.5, 83, 1.4, sec = self.dend[112]) h.pt3dadd(190.5, -441, 83, 1.4, sec = self.dend[112]) h.pt3dadd(192, -442, 83, 1.5, sec = self.dend[112]) h.pt3dadd(192.5, -443, 83, 1.5, sec = self.dend[112]) h.pt3dadd(195, -443.5, 83, 0.5, sec = self.dend[112]) h.pt3dadd(196.5, -443, 83, 0.5, sec = self.dend[112]) h.pt3dadd(197, -445.5, 90.5, 1.2, sec = self.dend[112]) h.pt3dadd(196.5, -446.5, 89, 2, sec = self.dend[112]) h.pt3dadd(198, -449.5, 89, 0.8, sec = self.dend[112]) h.pt3dadd(200, -452, 89, 1.1, sec = self.dend[112]) h.pt3dadd(200.5, -453.5, 89, 1.4, sec = self.dend[112]) h.pt3dadd(203, -453, 89, 1.7, sec = self.dend[112]) h.pt3dadd(204.5, -452.5, 89, 1.7, sec = self.dend[112]) h.pt3dadd(206, -454, 89, 0.9, sec = self.dend[112]) h.pt3dadd(206.5, -455.5, 89, 1.4, sec = self.dend[112]) h.pt3dadd(209, -457.5, 89, 1.4, sec = self.dend[112]) h.pt3dadd(211, -456.5, 87.5, 1.2, sec = self.dend[112]) h.pt3dadd(213, -458, 95, 1.2, sec = self.dend[112]) h.pt3dadd(215, -460.5, 93.5, 1.3, sec = self.dend[112]) h.pt3dadd(216, -462.5, 93.5, 1.3, sec = self.dend[112]) h.pt3dadd(214, -464, 93.5, 0.6, sec = self.dend[112]) h.pt3dadd(215, -462.5, 93.5, 0.6, sec = self.dend[112]) h.pt3dadd(217.5, -461.5, 102.5, 1.7, sec = self.dend[112]) h.pt3dadd(219.5, -463, 105.5, 2.1, sec = self.dend[112]) h.pt3dadd(221, -464, 105.5, 1.9, sec = self.dend[112]) h.pt3dadd(222.5, -463.5, 105.5, 1.6, sec = self.dend[112]) h.pt3dadd(222, -465.5, 105.5, 1.6, sec = self.dend[112]) h.pt3dadd(223, -466.5, 105.5, 2.5, sec = self.dend[112]) h.pt3dadd(226, -467, 105.5, 0.6, sec = self.dend[112]) h.pt3dadd(228, -468, 104, 0.6, sec = self.dend[112]) h.pt3dadd(231.5, -467.5, 104, 0.6, sec = self.dend[112]) h.pt3dadd(235, -468.5, 104, 1.3, sec = self.dend[112]) h.pt3dadd(237.5, -470.5, 105.5, 0.8, sec = self.dend[112]) h.pt3dadd(241.5, -470.5, 115, 1.3, sec = self.dend[112]) h.pt3dadd(243, -471, 115, 0.7, sec = self.dend[112]) h.pt3dadd(244, -470.5, 115, 0.2, sec = self.dend[112]) h.pt3dadd(244.5, -468, 115, 0.2, sec = self.dend[112]) h.pt3dadd(245.5, -466, 119, 0.2, sec = self.dend[112]) h.pt3dadd(246, -466.5, 121, 0.3, sec = self.dend[112]) h.pt3dadd(247.5, -466.5, 119, 0.3, sec = self.dend[112]) h.pt3dadd(248.5, -464.5, 119, 0.3, sec = self.dend[112]) h.pt3dadd(249.5, -464.5, 121, 0.1, sec = self.dend[112]) h.pt3dadd(249.5, -466.5, 119, 0.1, sec = self.dend[112]) h.pt3dadd(252.5, -466.5, 119, 0.1, sec = self.dend[112]) h.pt3dadd(254, -466.5, 119, 0.1, sec = self.dend[112]) h.pt3dadd(255.5, -467.5, 117, 0.1, sec = self.dend[112]) h.pt3dadd(259.5, -467.5, 117, 0.1, sec = self.dend[112]) h.pt3dadd(259.5, -468.5, 117, 0.1, sec = self.dend[112]) h.pt3dadd(264, -470, 119, 0.1, sec = self.dend[112]) h.pt3dadd(265.5, -470, 121, 0.7, sec = self.dend[112]) h.pt3dadd(267, -470.5, 123, 1.5, sec = self.dend[112]) h.pt3dadd(269, -470.5, 121, 1.5, sec = self.dend[112]) h.pt3dadd(269.5, -472, 129, 1.2, sec = self.dend[112]) h.pt3dadd(271.5, -472.5, 119, 0.7, sec = self.dend[112]) h.pt3dadd(273, -472.5, 123, 1.1, sec = self.dend[112]) h.pt3dadd(274.5, -472, 123, 0.5, sec = self.dend[112]) h.pt3dadd(277, -472, 123, 0.5, sec = self.dend[112]) h.pt3dadd(279, -472.5, 123, 0.5, sec = self.dend[112]) h.pt3dadd(281, -473.5, 123, 0.5, sec = self.dend[112]) h.pt3dadd(281.5, -473.5, 123, 0.3, sec = self.dend[112]) h.pt3dadd(282.5, -475, 121, 0.2, sec = self.dend[112]) h.pt3dadd(283, -476, 121, 0.2, sec = self.dend[112]) h.pt3dadd(285, -476, 121, 0.2, sec = self.dend[112]) h.pt3dadd(285.5, -476.5, 121, 0.2, sec = self.dend[112]) h.pt3dadd(286, -476, 121, 0.2, sec = self.dend[112]) h.pt3dadd(288.5, -476, 121, 0.6, sec = self.dend[112]) h.pt3dadd(290, -476.5, 121, 0.6, sec = self.dend[112]) h.pt3dadd(290, -477, 121, 0.6, sec = self.dend[112]) h.pt3dadd(291.5, -479.5, 121, 0.7, sec = self.dend[112]) h.pt3dadd(294, -478.5, 121, 0.4, sec = self.dend[112]) h.pt3dadd(296, -478.5, 127, 0.4, sec = self.dend[112]) h.pt3dadd(298.5, -480, 127, 0.8, sec = self.dend[112]) h.pt3dclear(sec = self.dend[113]) h.pt3dadd(145.5, -413.5, 86, 6.5, sec = self.dend[113]) h.pt3dadd(144, -418.5, 86, 3.5, sec = self.dend[113]) h.pt3dadd(142, -422, 86, 4.3, sec = self.dend[113]) h.pt3dadd(141.5, -424.5, 86, 4.9, sec = self.dend[113]) h.pt3dadd(140.5, -428, 86, 4.9, sec = self.dend[113]) h.pt3dadd(141, -429.5, 86, 4.6, sec = self.dend[113]) h.pt3dadd(142, -433.5, 86, 4.9, sec = self.dend[113]) h.pt3dadd(141.5, -437.5, 86, 5.2, sec = self.dend[113]) h.pt3dadd(141.5, -441.5, 86, 5.4, sec = self.dend[113]) h.pt3dadd(144, -443.5, 86, 5.5, sec = self.dend[113]) h.pt3dadd(143, -449, 86, 4.9, sec = self.dend[113]) h.pt3dadd(143.5, -453, 86, 4.5, sec = self.dend[113]) h.pt3dadd(144, -457, 86, 5.2, sec = self.dend[113]) h.pt3dadd(146, -459, 86, 5.2, sec = self.dend[113]) h.pt3dadd(148, -463.5, 86, 4.7, sec = self.dend[113]) h.pt3dadd(145.5, -469, 86, 4.7, sec = self.dend[113]) h.pt3dadd(145.5, -472, 86, 5.3, sec = self.dend[113]) h.pt3dadd(145.5, -476, 86, 6.3, sec = self.dend[113]) h.pt3dadd(145, -478.5, 86, 6.4, sec = self.dend[113]) h.pt3dclear(sec = self.dend[114]) h.pt3dadd(145, -478.5, 86, 6.4, sec = self.dend[114]) h.pt3dadd(140.5, -481.5, 87.5, 1.8, sec = self.dend[114]) h.pt3dadd(137, -482.5, 87.5, 1.8, sec = self.dend[114]) h.pt3dadd(135.5, -485, 87.5, 1.8, sec = self.dend[114]) h.pt3dadd(131.5, -486, 86, 2.1, sec = self.dend[114]) h.pt3dadd(129, -487.5, 86, 1.8, sec = self.dend[114]) h.pt3dadd(126.5, -489, 86, 1.9, sec = self.dend[114]) h.pt3dadd(124.5, -492.5, 86, 1.9, sec = self.dend[114]) h.pt3dadd(123.5, -493, 86, 1.9, sec = self.dend[114]) h.pt3dadd(121.5, -494.5, 86, 1.9, sec = self.dend[114]) h.pt3dadd(121, -497, 86, 2.4, sec = self.dend[114]) h.pt3dadd(121.5, -497.5, 86, 1.9, sec = self.dend[114]) h.pt3dadd(120.5, -499, 86, 1.8, sec = self.dend[114]) h.pt3dadd(120.5, -500.5, 86, 1.9, sec = self.dend[114]) h.pt3dadd(120, -502.5, 86, 1.9, sec = self.dend[114]) h.pt3dadd(119, -504, 86, 1.7, sec = self.dend[114]) h.pt3dadd(116.5, -506, 92, 1.5, sec = self.dend[114]) h.pt3dadd(117, -508.5, 92, 1.5, sec = self.dend[114]) h.pt3dadd(116.5, -509.5, 92, 1.4, sec = self.dend[114]) h.pt3dadd(116.5, -511.5, 92, 1.6, sec = self.dend[114]) h.pt3dadd(115, -512.5, 92, 1.6, sec = self.dend[114]) h.pt3dadd(116.5, -514, 96, 1.6, sec = self.dend[114]) h.pt3dadd(116.5, -516.5, 96, 2.3, sec = self.dend[114]) h.pt3dadd(115.5, -519, 96, 1.4, sec = self.dend[114]) h.pt3dadd(116.5, -520.5, 98, 1.7, sec = self.dend[114]) h.pt3dadd(116.5, -522, 103.5, 1, sec = self.dend[114]) h.pt3dadd(116.5, -524.5, 103.5, 1.2, sec = self.dend[114]) h.pt3dadd(116.5, -526.5, 103.5, 0.9, sec = self.dend[114]) h.pt3dadd(114, -528.5, 108.5, 1.1, sec = self.dend[114]) h.pt3dadd(113, -530.5, 108.5, 1.8, sec = self.dend[114]) h.pt3dadd(111.5, -534, 108.5, 1.4, sec = self.dend[114]) h.pt3dadd(111.5, -536.5, 110, 2.1, sec = self.dend[114]) h.pt3dadd(110, -538.5, 110, 2.8, sec = self.dend[114]) h.pt3dadd(110.5, -542.5, 110, 1.6, sec = self.dend[114]) h.pt3dadd(109.5, -543, 110, 2.4, sec = self.dend[114]) h.pt3dadd(107, -546.5, 110, 2.5, sec = self.dend[114]) h.pt3dclear(sec = self.dend[115]) h.pt3dadd(107, -546.5, 110, 2.5, sec = self.dend[115]) h.pt3dadd(104.5, -547, 103.5, 0.1, sec = self.dend[115]) h.pt3dadd(100.5, -546.5, 110, 0.1, sec = self.dend[115]) h.pt3dadd(100.5, -548, 110, 0.3, sec = self.dend[115]) h.pt3dadd(98.5, -550.5, 110, 0.3, sec = self.dend[115]) h.pt3dadd(96.5, -552, 111.5, 0.3, sec = self.dend[115]) h.pt3dadd(97, -552, 112.5, 1.6, sec = self.dend[115]) h.pt3dadd(95.5, -554, 114, 2.5, sec = self.dend[115]) h.pt3dadd(93.5, -556, 114, 1.5, sec = self.dend[115]) h.pt3dadd(90.5, -556, 112.5, 0.7, sec = self.dend[115]) h.pt3dadd(94.5, -560.5, 112.5, 1.2, sec = self.dend[115]) h.pt3dadd(92, -562, 112.5, 1.2, sec = self.dend[115]) h.pt3dadd(90, -563, 112.5, 2.2, sec = self.dend[115]) h.pt3dadd(87.5, -563.5, 112.5, 1.4, sec = self.dend[115]) h.pt3dadd(84.5, -563.5, 120.5, 1.9, sec = self.dend[115]) h.pt3dadd(82, -563.5, 120.5, 1.9, sec = self.dend[115]) h.pt3dadd(82, -567, 122, 2.1, sec = self.dend[115]) h.pt3dadd(81.5, -570, 120.5, 2, sec = self.dend[115]) h.pt3dadd(80.5, -570, 120.5, 0.2, sec = self.dend[115]) h.pt3dadd(79.5, -572.5, 128.5, 1.3, sec = self.dend[115]) h.pt3dadd(78.5, -575, 128.5, 2, sec = self.dend[115]) h.pt3dadd(77, -577.5, 130, 4.3, sec = self.dend[115]) h.pt3dadd(73.5, -581, 131, 1.5, sec = self.dend[115]) h.pt3dadd(73, -584, 131, 0.9, sec = self.dend[115]) h.pt3dadd(73, -586, 131, 0.1, sec = self.dend[115]) h.pt3dadd(73, -587.5, 131, 1.3, sec = self.dend[115]) h.pt3dadd(72.5, -589, 130, 0.1, sec = self.dend[115]) h.pt3dclear(sec = self.dend[116]) h.pt3dadd(107, -546.5, 110, 2.5, sec = self.dend[116]) h.pt3dadd(110, -547.5, 108.5, 1.5, sec = self.dend[116]) h.pt3dadd(110.5, -549, 108.5, 1.5, sec = self.dend[116]) h.pt3dadd(112, -553, 108.5, 1.6, sec = self.dend[116]) h.pt3dadd(112, -554.5, 108.5, 1.6, sec = self.dend[116]) h.pt3dadd(111, -557.5, 115.5, 1.6, sec = self.dend[116]) h.pt3dadd(109.5, -561.5, 115.5, 1.2, sec = self.dend[116]) h.pt3dadd(107.5, -561.5, 115.5, 1.2, sec = self.dend[116]) h.pt3dadd(103.5, -561.5, 116.5, 1.2, sec = self.dend[116]) h.pt3dadd(103, -565.5, 120.5, 1.9, sec = self.dend[116]) h.pt3dadd(102.5, -568, 119.5, 1.5, sec = self.dend[116]) h.pt3dadd(100.5, -571, 122, 1.3, sec = self.dend[116]) h.pt3dadd(99.5, -573, 122, 1.3, sec = self.dend[116]) h.pt3dadd(99.5, -576, 122, 1.1, sec = self.dend[116]) h.pt3dadd(100, -577.5, 120.5, 1.6, sec = self.dend[116]) h.pt3dadd(100, -579, 120.5, 1.5, sec = self.dend[116]) h.pt3dadd(98.5, -583, 122, 1.5, sec = self.dend[116]) h.pt3dadd(96.5, -585.5, 122, 1.5, sec = self.dend[116]) h.pt3dadd(96, -588, 122, 1.5, sec = self.dend[116]) h.pt3dadd(94.5, -592, 115.5, 2, sec = self.dend[116]) h.pt3dadd(93, -596.5, 116.5, 2.2, sec = self.dend[116]) h.pt3dadd(91, -598, 118, 1.4, sec = self.dend[116]) h.pt3dadd(89, -598.5, 118, 1.4, sec = self.dend[116]) h.pt3dadd(88.5, -601.5, 118, 1.7, sec = self.dend[116]) h.pt3dadd(88.5, -604, 118, 1.6, sec = self.dend[116]) h.pt3dadd(87, -606, 124.5, 1.6, sec = self.dend[116]) h.pt3dadd(84.5, -607, 126, 2.3, sec = self.dend[116]) h.pt3dadd(83, -610, 135, 3.6, sec = self.dend[116]) h.pt3dadd(80.5, -612.5, 122, 1.9, sec = self.dend[116]) h.pt3dadd(80, -615.5, 122, 0.6, sec = self.dend[116]) h.pt3dadd(80.5, -617.5, 122, 0.3, sec = self.dend[116]) h.pt3dadd(80.5, -619, 122, 0.3, sec = self.dend[116]) h.pt3dadd(82, -620, 122, 0.2, sec = self.dend[116]) h.pt3dadd(81.5, -621.5, 130, 2.9, sec = self.dend[116]) h.pt3dadd(79.5, -624.5, 131, 2.2, sec = self.dend[116]) h.pt3dadd(79, -627.5, 132.5, 1.7, sec = self.dend[116]) h.pt3dadd(78, -629.5, 132.5, 1.7, sec = self.dend[116]) h.pt3dadd(76, -633.5, 130, 2.1, sec = self.dend[116]) h.pt3dadd(74.5, -636.5, 130, 1.5, sec = self.dend[116]) h.pt3dadd(73.5, -639.5, 131, 1.9, sec = self.dend[116]) h.pt3dadd(72.5, -643, 135, 1.5, sec = self.dend[116]) h.pt3dadd(71, -646, 136.5, 1.1, sec = self.dend[116]) h.pt3dadd(70, -650.5, 136.5, 1.5, sec = self.dend[116]) h.pt3dadd(70, -653.5, 136.5, 1.5, sec = self.dend[116]) h.pt3dadd(69.5, -657.5, 136.5, 1.8, sec = self.dend[116]) h.pt3dadd(68.5, -660, 136.5, 1.8, sec = self.dend[116]) h.pt3dadd(67.5, -663.5, 136.5, 1.7, sec = self.dend[116]) h.pt3dadd(65.5, -665.5, 136.5, 1.7, sec = self.dend[116]) h.pt3dadd(63, -668, 137.5, 1.7, sec = self.dend[116]) h.pt3dadd(63, -670, 139, 2.5, sec = self.dend[116]) h.pt3dadd(60, -672.5, 139, 2.5, sec = self.dend[116]) h.pt3dadd(59, -675.5, 139, 1.9, sec = self.dend[116]) h.pt3dadd(58, -677, 139, 1.5, sec = self.dend[116]) h.pt3dadd(55, -677, 139, 1.4, sec = self.dend[116]) h.pt3dadd(54.5, -677, 137.5, 0.8, sec = self.dend[116]) h.pt3dadd(53, -677, 139, 1.1, sec = self.dend[116]) h.pt3dadd(51.5, -678, 143, 1.4, sec = self.dend[116]) h.pt3dadd(51, -679.5, 144.5, 0.7, sec = self.dend[116]) h.pt3dadd(49.5, -681.5, 131, 1.6, sec = self.dend[116]) h.pt3dclear(sec = self.dend[117]) h.pt3dadd(145, -478.5, 86, 6.4, sec = self.dend[117]) h.pt3dadd(149, -480.5, 84.5, 3.6, sec = self.dend[117]) h.pt3dadd(149.5, -482, 84.5, 3.8, sec = self.dend[117]) h.pt3dadd(151, -485, 84.5, 3.2, sec = self.dend[117]) h.pt3dadd(152, -486.5, 87.5, 2.1, sec = self.dend[117]) h.pt3dadd(153, -488, 87.5, 2.8, sec = self.dend[117]) h.pt3dadd(154, -492, 87.5, 3.4, sec = self.dend[117]) h.pt3dadd(154.5, -494, 92, 3.4, sec = self.dend[117]) h.pt3dadd(156, -494.5, 90.5, 3.4, sec = self.dend[117]) h.pt3dadd(157.5, -499, 92, 3.2, sec = self.dend[117]) h.pt3dadd(158.5, -502, 84, 2.2, sec = self.dend[117]) h.pt3dadd(160, -504.5, 84, 2.2, sec = self.dend[117]) h.pt3dadd(160, -506, 86, 2.4, sec = self.dend[117]) h.pt3dadd(160.5, -508.5, 86, 2.4, sec = self.dend[117]) h.pt3dadd(161.5, -509, 86, 2.4, sec = self.dend[117]) h.pt3dadd(162, -511.5, 94, 3.5, sec = self.dend[117]) h.pt3dadd(161, -513.5, 94, 2.3, sec = self.dend[117]) h.pt3dadd(161, -516.5, 94, 2.7, sec = self.dend[117]) h.pt3dadd(160.5, -518.5, 82, 2.7, sec = self.dend[117]) h.pt3dadd(160, -521, 86, 2.7, sec = self.dend[117]) h.pt3dadd(160, -523.5, 86, 2.7, sec = self.dend[117]) h.pt3dadd(160.5, -524, 84, 1.3, sec = self.dend[117]) h.pt3dadd(161.5, -525.5, 84, 2.5, sec = self.dend[117]) h.pt3dadd(160.5, -528, 84, 2.8, sec = self.dend[117]) h.pt3dadd(159.5, -529, 90, 1.8, sec = self.dend[117]) h.pt3dadd(160, -532, 90, 1.7, sec = self.dend[117]) h.pt3dadd(160.5, -533.5, 90, 1.8, sec = self.dend[117]) h.pt3dadd(161, -534.5, 90, 1.5, sec = self.dend[117]) h.pt3dadd(161, -540.5, 90, 2.4, sec = self.dend[117]) h.pt3dadd(162, -543.5, 88.5, 2.4, sec = self.dend[117]) h.pt3dadd(162, -547, 88.5, 2.5, sec = self.dend[117]) h.pt3dadd(163.5, -548.5, 87.5, 1.6, sec = self.dend[117]) h.pt3dadd(164.5, -551.5, 87.5, 2.6, sec = self.dend[117]) h.pt3dadd(162, -553.5, 87.5, 2.9, sec = self.dend[117]) h.pt3dadd(164, -556.5, 87.5, 3.3, sec = self.dend[117]) h.pt3dadd(165.5, -559, 87.5, 3.6, sec = self.dend[117]) h.pt3dadd(167, -561.5, 87.5, 3.7, sec = self.dend[117]) h.pt3dadd(163, -561.5, 87.5, 3.7, sec = self.dend[117]) h.pt3dadd(163.5, -566, 92.5, 2.7, sec = self.dend[117]) h.pt3dadd(165.5, -567.5, 91, 2.8, sec = self.dend[117]) h.pt3dadd(165.5, -571.5, 91, 2.9, sec = self.dend[117]) h.pt3dadd(164.5, -575.5, 91, 3.4, sec = self.dend[117]) h.pt3dadd(164.5, -578, 91, 2.8, sec = self.dend[117]) h.pt3dadd(164.5, -582.5, 94, 2.7, sec = self.dend[117]) h.pt3dadd(164.5, -585, 94, 2.7, sec = self.dend[117]) h.pt3dadd(164.5, -588.5, 94, 2.7, sec = self.dend[117]) h.pt3dadd(165, -591.5, 100.5, 2.8, sec = self.dend[117]) h.pt3dadd(165, -594, 100.5, 3.4, sec = self.dend[117]) h.pt3dadd(165.5, -595, 100.5, 2.7, sec = self.dend[117]) h.pt3dadd(166, -598, 99, 2.4, sec = self.dend[117]) h.pt3dadd(167, -602, 99, 2.5, sec = self.dend[117]) h.pt3dadd(168.5, -603.5, 99, 2.6, sec = self.dend[117]) h.pt3dadd(168.5, -606.5, 102, 6.3, sec = self.dend[117]) h.pt3dclear(sec = self.dend[118]) h.pt3dadd(168.5, -606.5, 102, 6.3, sec = self.dend[118]) h.pt3dadd(165.5, -608, 99, 0.8, sec = self.dend[118]) h.pt3dadd(163, -609.5, 100.5, 0.6, sec = self.dend[118]) h.pt3dadd(162, -612.5, 100.5, 0.7, sec = self.dend[118]) h.pt3dadd(162.5, -614.5, 102, 1.6, sec = self.dend[118]) h.pt3dadd(161.5, -615.5, 102, 1.9, sec = self.dend[118]) h.pt3dadd(161, -615.5, 103, 1.4, sec = self.dend[118]) h.pt3dadd(160, -617.5, 103, 0.3, sec = self.dend[118]) h.pt3dadd(160, -618, 103, 0.3, sec = self.dend[118]) h.pt3dadd(161, -620.5, 103, 2.9, sec = self.dend[118]) h.pt3dadd(161.5, -621, 119, 1.1, sec = self.dend[118]) h.pt3dadd(162.5, -623, 119, 0.8, sec = self.dend[118]) h.pt3dadd(162.5, -624.5, 117.5, 0.8, sec = self.dend[118]) h.pt3dadd(165, -625, 116, 0.8, sec = self.dend[118]) h.pt3dadd(162.5, -628, 108.5, 0.7, sec = self.dend[118]) h.pt3dclear(sec = self.dend[119]) h.pt3dadd(168.5, -606.5, 102, 6.3, sec = self.dend[119]) h.pt3dadd(169, -606.5, 100.5, 6.3, sec = self.dend[119]) h.pt3dadd(171.5, -607.5, 100.5, 3.8, sec = self.dend[119]) h.pt3dadd(174, -607.5, 102, 0.8, sec = self.dend[119]) h.pt3dadd(174.5, -609, 102, 1.5, sec = self.dend[119]) h.pt3dadd(177.5, -612, 100.5, 2, sec = self.dend[119]) h.pt3dadd(180, -611.5, 99, 1.8, sec = self.dend[119]) h.pt3dadd(182.5, -611.5, 99, 1.7, sec = self.dend[119]) h.pt3dadd(184.5, -611.5, 99, 2.6, sec = self.dend[119]) h.pt3dadd(186.5, -612.5, 99, 2.6, sec = self.dend[119]) h.pt3dadd(189.5, -612, 100.5, 2.3, sec = self.dend[119]) h.pt3dadd(192.5, -612, 100.5, 1.4, sec = self.dend[119]) h.pt3dadd(193.5, -613, 100.5, 1.4, sec = self.dend[119]) h.pt3dadd(196, -613.5, 100.5, 1.4, sec = self.dend[119]) h.pt3dadd(197.5, -614, 100.5, 1.6, sec = self.dend[119]) h.pt3dadd(199, -618, 100.5, 2, sec = self.dend[119]) h.pt3dadd(198.5, -618, 103, 2, sec = self.dend[119]) h.pt3dadd(198, -619.5, 100.5, 2.3, sec = self.dend[119]) h.pt3dadd(198, -621.5, 100.5, 1.8, sec = self.dend[119]) h.pt3dadd(198.5, -624, 100.5, 1.6, sec = self.dend[119]) h.pt3dadd(199.5, -627, 99, 2.1, sec = self.dend[119]) h.pt3dadd(200.5, -629, 102, 2, sec = self.dend[119]) h.pt3dadd(202, -631, 102, 2.2, sec = self.dend[119]) h.pt3dadd(203, -632.5, 105.5, 2.5, sec = self.dend[119]) h.pt3dadd(203.5, -634.5, 104.5, 1.7, sec = self.dend[119]) h.pt3dadd(203, -636.5, 104.5, 1.7, sec = self.dend[119]) h.pt3dadd(203, -638, 104.5, 1.4, sec = self.dend[119]) h.pt3dadd(203.5, -640, 104.5, 2, sec = self.dend[119]) h.pt3dadd(204.5, -641.5, 104.5, 2, sec = self.dend[119]) h.pt3dadd(205, -643.5, 104.5, 2, sec = self.dend[119]) h.pt3dadd(205, -644.5, 104.5, 1.7, sec = self.dend[119]) h.pt3dadd(206, -646.5, 104.5, 2, sec = self.dend[119]) h.pt3dadd(206, -648.5, 104.5, 2, sec = self.dend[119]) h.pt3dadd(207.5, -652, 104.5, 1.9, sec = self.dend[119]) h.pt3dadd(207.5, -653, 104.5, 0.7, sec = self.dend[119]) h.pt3dadd(210, -654.5, 103, 0.7, sec = self.dend[119]) h.pt3dadd(210, -656.5, 103, 1.1, sec = self.dend[119]) h.pt3dadd(212, -661.5, 103, 1.3, sec = self.dend[119]) h.pt3dadd(212, -664, 103, 1.3, sec = self.dend[119]) h.pt3dadd(213, -666.5, 103, 1.1, sec = self.dend[119]) h.pt3dadd(213, -668, 104.5, 1.6, sec = self.dend[119]) h.pt3dadd(214, -671, 104.5, 1.8, sec = self.dend[119]) h.pt3dadd(215, -672.5, 104.5, 1.9, sec = self.dend[119]) h.pt3dadd(218, -677, 104.5, 1.1, sec = self.dend[119]) h.pt3dadd(218, -679, 104.5, 1.5, sec = self.dend[119]) h.pt3dadd(217, -681.5, 104.5, 1.8, sec = self.dend[119]) h.pt3dadd(217, -684, 104.5, 2.2, sec = self.dend[119]) h.pt3dadd(217.5, -686, 105.5, 2, sec = self.dend[119]) h.pt3dadd(217.5, -691, 105.5, 2.1, sec = self.dend[119]) h.pt3dadd(219, -691, 105.5, 3.4, sec = self.dend[119]) h.pt3dadd(222, -692.5, 104.5, 1.8, sec = self.dend[119]) h.pt3dadd(223, -694, 103, 1.5, sec = self.dend[119]) h.pt3dadd(224, -696.5, 104.5, 1.5, sec = self.dend[119]) h.pt3dadd(224, -700, 104.5, 1.3, sec = self.dend[119]) h.pt3dadd(227, -700, 104.5, 1.4, sec = self.dend[119]) h.pt3dadd(228, -700, 104.5, 1.8, sec = self.dend[119]) h.pt3dadd(230, -702.5, 104.5, 2.2, sec = self.dend[119]) h.pt3dadd(233.5, -703.5, 103, 1.4, sec = self.dend[119]) h.pt3dadd(236.5, -707, 103, 2.3, sec = self.dend[119]) h.pt3dadd(238, -709.5, 104.5, 1.9, sec = self.dend[119]) h.pt3dadd(240, -711.5, 104.5, 1.8, sec = self.dend[119]) h.pt3dadd(240.5, -714, 104.5, 1.5, sec = self.dend[119]) h.pt3dadd(242, -716.5, 104.5, 1.2, sec = self.dend[119]) h.pt3dadd(244, -719, 104.5, 1.6, sec = self.dend[119]) h.pt3dadd(245.5, -721, 104.5, 1.3, sec = self.dend[119]) h.pt3dadd(247, -723.5, 104.5, 1.4, sec = self.dend[119]) h.pt3dadd(249, -726, 99, 1.5, sec = self.dend[119]) h.pt3dadd(250.5, -727.5, 99, 2.1, sec = self.dend[119]) h.pt3dadd(251.5, -730, 99, 2.8, sec = self.dend[119]) h.pt3dadd(253.5, -732.5, 99, 2.8, sec = self.dend[119]) h.pt3dadd(252.5, -734.5, 99, 2.3, sec = self.dend[119]) h.pt3dadd(253, -736.5, 99, 1.2, sec = self.dend[119]) h.pt3dadd(253, -739, 99, 1.2, sec = self.dend[119]) h.pt3dadd(254, -740.5, 99, 1, sec = self.dend[119]) h.pt3dadd(256, -741.5, 99, 1.6, sec = self.dend[119]) h.pt3dadd(257.5, -742, 99, 2.7, sec = self.dend[119]) h.pt3dadd(260, -744, 99, 1.6, sec = self.dend[119]) h.pt3dadd(260, -746.5, 99, 1.2, sec = self.dend[119]) h.pt3dadd(262.5, -749.5, 99, 0.7, sec = self.dend[119]) h.pt3dadd(265.5, -751.5, 99, 0.5, sec = self.dend[119]) h.pt3dadd(268, -753.5, 99, 0.5, sec = self.dend[119]) h.pt3dadd(268.5, -757, 99, 0.4, sec = self.dend[119]) h.pt3dadd(270, -759.5, 99, 0.4, sec = self.dend[119]) h.pt3dadd(271, -762.5, 99, 1, sec = self.dend[119]) h.pt3dadd(272, -764.5, 99, 0.9, sec = self.dend[119]) h.pt3dadd(273, -766.5, 102, 1.3, sec = self.dend[119]) h.pt3dadd(276, -769.5, 105.5, 1.3, sec = self.dend[119]) h.pt3dadd(279, -770.5, 107, 2.5, sec = self.dend[119]) h.pt3dclear(sec = self.dend[120]) h.pt3dadd(279, -770.5, 107, 2.5, sec = self.dend[120]) h.pt3dadd(283, -772, 100.5, 0.1, sec = self.dend[120]) h.pt3dadd(287.5, -772, 100.5, 0.1, sec = self.dend[120]) h.pt3dadd(289.5, -773.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(293, -774.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(295, -774.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(297.5, -774.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(297.5, -773.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(300.5, -773, 102, 0.1, sec = self.dend[120]) h.pt3dadd(303.5, -774.5, 102, 0.1, sec = self.dend[120]) h.pt3dadd(305.5, -777.5, 94, 0.1, sec = self.dend[120]) h.pt3dclear(sec = self.dend[121]) h.pt3dadd(279, -770.5, 107, 2.5, sec = self.dend[121]) h.pt3dadd(281.5, -775.5, 102, 0.7, sec = self.dend[121]) h.pt3dadd(283.5, -777.5, 100.5, 1.6, sec = self.dend[121]) h.pt3dadd(286, -779, 103, 1.4, sec = self.dend[121]) h.pt3dadd(289, -781.5, 100.5, 1, sec = self.dend[121]) h.pt3dadd(290.5, -784, 100.5, 1.7, sec = self.dend[121]) h.pt3dadd(292.5, -785.5, 103, 1.7, sec = self.dend[121]) h.pt3dadd(295, -787, 103, 1.2, sec = self.dend[121]) h.pt3dadd(296.5, -789, 103, 0.6, sec = self.dend[121]) h.pt3dadd(299, -790, 104.5, 0.9, sec = self.dend[121]) h.pt3dadd(302, -790.5, 104.5, 1, sec = self.dend[121]) h.pt3dadd(303, -791, 104.5, 1.2, sec = self.dend[121]) h.pt3dadd(305.5, -792.5, 104.5, 1.1, sec = self.dend[121]) h.pt3dadd(307.5, -794, 104.5, 1.1, sec = self.dend[121]) h.pt3dadd(309, -793, 104.5, 1.1, sec = self.dend[121]) h.pt3dadd(309.5, -793, 104.5, 0.7, sec = self.dend[121]) h.pt3dadd(311, -793, 104.5, 0.4, sec = self.dend[121]) h.pt3dadd(314, -793, 104.5, 0.3, sec = self.dend[121]) h.pt3dadd(316, -793, 102, 0.2, sec = self.dend[121]) h.pt3dadd(320.5, -793, 100.5, 1, sec = self.dend[121]) h.pt3dadd(322, -793, 100.5, 1.5, sec = self.dend[121]) h.pt3dadd(325, -793, 100.5, 1.5, sec = self.dend[121]) h.pt3dadd(327.5, -794.5, 100.5, 1.5, sec = self.dend[121]) h.pt3dadd(331, -797, 100.5, 1.7, sec = self.dend[121]) h.pt3dadd(333, -799, 100.5, 1.7, sec = self.dend[121]) h.pt3dadd(336, -800.5, 100.5, 1.7, sec = self.dend[121]) h.pt3dadd(337.5, -803.5, 99, 0.9, sec = self.dend[121]) h.pt3dadd(337.5, -804.5, 99, 0.9, sec = self.dend[121]) h.pt3dadd(339, -807.5, 99, 1, sec = self.dend[121]) h.pt3dadd(340, -810, 99, 1, sec = self.dend[121]) h.pt3dadd(342, -813.5, 102, 1.5, sec = self.dend[121]) h.pt3dadd(344, -813.5, 102, 1.5, sec = self.dend[121]) h.pt3dadd(345.5, -815.5, 102, 1.4, sec = self.dend[121]) h.pt3dadd(347.5, -817, 100.5, 1.3, sec = self.dend[121]) h.pt3dadd(349, -818.5, 103, 1.4, sec = self.dend[121]) h.pt3dadd(351.5, -821, 103, 1.4, sec = self.dend[121]) h.pt3dadd(352.5, -822, 104.5, 2, sec = self.dend[121]) h.pt3dadd(354.5, -825.5, 104.5, 2.5, sec = self.dend[121]) h.pt3dadd(355, -827.5, 104.5, 2.4, sec = self.dend[121]) h.pt3dadd(357.5, -829.5, 104.5, 2.2, sec = self.dend[121]) h.pt3dadd(359, -831, 104.5, 2.6, sec = self.dend[121]) h.pt3dadd(359.5, -834, 105.5, 4, sec = self.dend[121]) h.pt3dclear(sec = self.dend[122]) h.pt3dadd(359.5, -834, 105.5, 4, sec = self.dend[122]) h.pt3dadd(358.5, -835.5, 104.5, 1.1, sec = self.dend[122]) h.pt3dadd(357, -839, 104.5, 0.7, sec = self.dend[122]) h.pt3dclear(sec = self.dend[123]) h.pt3dadd(359.5, -834, 105.5, 4, sec = self.dend[123]) h.pt3dadd(364, -837.5, 100.5, 1.4, sec = self.dend[123]) h.pt3dadd(366, -837.5, 100.5, 1.4, sec = self.dend[123]) h.pt3dadd(367.5, -837.5, 100.5, 2.4, sec = self.dend[123]) h.pt3dadd(370.5, -837.5, 104.5, 1.7, sec = self.dend[123]) h.pt3dadd(372, -839.5, 104.5, 1.4, sec = self.dend[123]) h.pt3dadd(373.5, -839.5, 109.5, 1.4, sec = self.dend[123]) h.pt3dadd(375, -840, 109.5, 1.2, sec = self.dend[123]) h.pt3dadd(375, -841.5, 109.5, 1.2, sec = self.dend[123]) h.pt3dadd(377.5, -841.5, 103, 0.4, sec = self.dend[123]) h.pt3dadd(377.5, -842.5, 104.5, 0.4, sec = self.dend[123]) h.pt3dadd(377.5, -845.5, 112.5, 0.4, sec = self.dend[123]) h.pt3dclear(sec = self.dend[124]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[124]) h.pt3dadd(4.5, 10.5, -7.5, 11.7, sec = self.dend[124]) h.pt3dadd(3, 6.5, -4, 13.2, sec = self.dend[124]) h.pt3dclear(sec = self.dend[125]) h.pt3dadd(3, 6.5, -4, 13.2, sec = self.dend[125]) h.pt3dadd(4.5, 1, -3, 6.4, sec = self.dend[125]) h.pt3dadd(4.5, -3, -3, 6.4, sec = self.dend[125]) h.pt3dadd(4.5, -6, -2, 5.1, sec = self.dend[125]) h.pt3dadd(4.5, -8.5, -2, 4.4, sec = self.dend[125]) h.pt3dadd(4.5, -12, -2, 5.1, sec = self.dend[125]) h.pt3dadd(5, -14.5, -4, 4.9, sec = self.dend[125]) h.pt3dadd(5, -16.5, -4, 4.9, sec = self.dend[125]) h.pt3dadd(5, -19, -3, 3.9, sec = self.dend[125]) h.pt3dadd(5, -23, -5.5, 3.8, sec = self.dend[125]) h.pt3dadd(5, -26.5, -5.5, 4, sec = self.dend[125]) h.pt3dadd(3, -30.5, -5, 4.6, sec = self.dend[125]) h.pt3dadd(3, -34, -5, 4.8, sec = self.dend[125]) h.pt3dadd(2.5, -41, -8.5, 5, sec = self.dend[125]) h.pt3dadd(2.5, -48, -11, 5, sec = self.dend[125]) h.pt3dadd(1, -52.5, -12, 4.3, sec = self.dend[125]) h.pt3dadd(1, -56, -9.5, 4.5, sec = self.dend[125]) h.pt3dadd(1.5, -60.5, -11, 4.6, sec = self.dend[125]) h.pt3dadd(3.5, -66, -11, 4.6, sec = self.dend[125]) h.pt3dadd(3.5, -69.5, -13, 4.1, sec = self.dend[125]) h.pt3dadd(4, -73.5, -13, 4, sec = self.dend[125]) h.pt3dadd(4.5, -76, -14, 3.6, sec = self.dend[125]) h.pt3dadd(5.5, -77, -14, 3.9, sec = self.dend[125]) h.pt3dadd(10, -87, -14, 3.8, sec = self.dend[125]) h.pt3dadd(11.5, -87, -15.5, 2.5, sec = self.dend[125]) h.pt3dadd(14, -89, -15.5, 2.5, sec = self.dend[125]) h.pt3dadd(16.5, -91, -15.5, 3.2, sec = self.dend[125]) h.pt3dadd(17.5, -93, -15.5, 3.6, sec = self.dend[125]) h.pt3dadd(19, -97.5, -16.5, 4, sec = self.dend[125]) h.pt3dadd(17, -104, -16.5, 4.3, sec = self.dend[125]) h.pt3dadd(17, -106, -15.5, 4.9, sec = self.dend[125]) h.pt3dadd(17, -109.5, -15, 5.9, sec = self.dend[125]) h.pt3dadd(17, -112, -15, 6.3, sec = self.dend[125]) h.pt3dadd(17.5, -114.5, -15, 5.6, sec = self.dend[125]) h.pt3dadd(19, -117, -16.5, 5.2, sec = self.dend[125]) h.pt3dadd(20, -121, -16.5, 4, sec = self.dend[125]) h.pt3dadd(21, -122, -16.5, 3.2, sec = self.dend[125]) h.pt3dadd(21.5, -122, -17.5, 2.6, sec = self.dend[125]) h.pt3dadd(23.5, -124.5, -17.5, 3.1, sec = self.dend[125]) h.pt3dadd(24.5, -126.5, -17.5, 3.7, sec = self.dend[125]) h.pt3dadd(27, -129.5, -17.5, 3.7, sec = self.dend[125]) h.pt3dadd(28.5, -131.5, -19, 3.3, sec = self.dend[125]) h.pt3dadd(30.5, -133, -18.5, 3.3, sec = self.dend[125]) h.pt3dadd(33, -135.5, -19, 3.3, sec = self.dend[125]) h.pt3dadd(34, -139, -19.5, 3.3, sec = self.dend[125]) h.pt3dadd(36.5, -140, -18.5, 3.8, sec = self.dend[125]) h.pt3dadd(38.5, -143.5, -20.5, 3.8, sec = self.dend[125]) h.pt3dadd(40, -145.5, -20.5, 3.4, sec = self.dend[125]) h.pt3dadd(42.5, -146.5, -19.5, 4.9, sec = self.dend[125]) h.pt3dadd(43.5, -149, -21.5, 4.9, sec = self.dend[125]) h.pt3dadd(47, -151, -22.5, 5.1, sec = self.dend[125]) h.pt3dadd(52.5, -155.5, -22.5, 3.7, sec = self.dend[125]) h.pt3dadd(54, -155.5, -22.5, 3.4, sec = self.dend[125]) h.pt3dadd(56.5, -157.5, -29, 3.4, sec = self.dend[125]) h.pt3dadd(59, -158, -29, 3.4, sec = self.dend[125]) h.pt3dadd(60, -160, -29, 3.4, sec = self.dend[125]) h.pt3dadd(61.5, -161, -29, 4, sec = self.dend[125]) h.pt3dadd(62.5, -163.5, -29, 3.8, sec = self.dend[125]) h.pt3dadd(64, -165, -29, 4.5, sec = self.dend[125]) h.pt3dadd(65, -166.5, -29, 4.4, sec = self.dend[125]) h.pt3dadd(67, -167.5, -29, 4.9, sec = self.dend[125]) h.pt3dadd(68.5, -168, -35, 4.6, sec = self.dend[125]) h.pt3dadd(70.5, -169, -35, 4.3, sec = self.dend[125]) h.pt3dadd(71.5, -170, -35, 3.6, sec = self.dend[125]) h.pt3dadd(73, -171.5, -35, 2.9, sec = self.dend[125]) h.pt3dadd(74, -171.5, -41.5, 2.3, sec = self.dend[125]) h.pt3dadd(76.5, -172.5, -41.5, 3.7, sec = self.dend[125]) h.pt3dadd(78, -174, -35, 3.8, sec = self.dend[125]) h.pt3dadd(79.5, -174.5, -41.5, 4.6, sec = self.dend[125]) h.pt3dadd(81.5, -177.5, -41.5, 5.2, sec = self.dend[125]) h.pt3dadd(82, -179, -41.5, 5.3, sec = self.dend[125]) h.pt3dclear(sec = self.dend[126]) h.pt3dadd(82, -179, -41.5, 5.3, sec = self.dend[126]) h.pt3dadd(84, -178.5, -54, 1.3, sec = self.dend[126]) h.pt3dadd(84, -177, -47.5, 1, sec = self.dend[126]) h.pt3dadd(87, -176.5, -47.5, 1, sec = self.dend[126]) h.pt3dadd(88.5, -176.5, -47.5, 0.7, sec = self.dend[126]) h.pt3dadd(89.5, -177.5, -47.5, 1.1, sec = self.dend[126]) h.pt3dadd(90, -178.5, -47.5, 1.1, sec = self.dend[126]) h.pt3dadd(90, -180, -47.5, 1.4, sec = self.dend[126]) h.pt3dadd(91, -181, -47.5, 1.2, sec = self.dend[126]) h.pt3dadd(92.5, -181.5, -47.5, 1.2, sec = self.dend[126]) h.pt3dadd(93.5, -182.5, -47.5, 1.7, sec = self.dend[126]) h.pt3dadd(94, -183, -54, 2.2, sec = self.dend[126]) h.pt3dadd(94.5, -187, -47.5, 1.9, sec = self.dend[126]) h.pt3dadd(98.5, -191.5, -43.5, 1.2, sec = self.dend[126]) h.pt3dadd(100.5, -192.5, -45.5, 1.1, sec = self.dend[126]) h.pt3dadd(101.5, -194.5, -51, 1.6, sec = self.dend[126]) h.pt3dadd(102, -196.5, -49, 1.6, sec = self.dend[126]) h.pt3dadd(103.5, -196.5, -49, 3.4, sec = self.dend[126]) h.pt3dadd(105, -197.5, -45.5, 2.8, sec = self.dend[126]) h.pt3dadd(106, -198, -47.5, 1.9, sec = self.dend[126]) h.pt3dadd(107, -198, -49, 1.1, sec = self.dend[126]) h.pt3dadd(108.5, -199.5, -53, 1.2, sec = self.dend[126]) h.pt3dadd(108.5, -201, -51, 1.2, sec = self.dend[126]) h.pt3dadd(109.5, -201.5, -53, 1.6, sec = self.dend[126]) h.pt3dadd(110, -201.5, -53, 2.2, sec = self.dend[126]) h.pt3dadd(111.5, -201.5, -53, 2.8, sec = self.dend[126]) h.pt3dadd(114, -203, -53, 1, sec = self.dend[126]) h.pt3dadd(114, -204, -53, 0.5, sec = self.dend[126]) h.pt3dadd(115.5, -205.5, -53, 0.5, sec = self.dend[126]) h.pt3dadd(116, -206.5, -51, 2.2, sec = self.dend[126]) h.pt3dadd(117.5, -208.5, -51, 2.7, sec = self.dend[126]) h.pt3dadd(118.5, -210, -55, 1.3, sec = self.dend[126]) h.pt3dadd(119.5, -212, -57, 0.5, sec = self.dend[126]) h.pt3dadd(120.5, -214, -57, 1, sec = self.dend[126]) h.pt3dadd(121.5, -214, -60, 2.2, sec = self.dend[126]) h.pt3dadd(122.5, -214.5, -60, 1.3, sec = self.dend[126]) h.pt3dadd(123.5, -215, -63, 0.1, sec = self.dend[126]) h.pt3dadd(124.5, -215, -63, 0.1, sec = self.dend[126]) h.pt3dadd(128, -214.5, -66, 0.1, sec = self.dend[126]) h.pt3dadd(126.5, -216, -63, 0.1, sec = self.dend[126]) h.pt3dadd(127, -216.5, -63, 1.3, sec = self.dend[126]) h.pt3dadd(129, -218, -63, 1.7, sec = self.dend[126]) h.pt3dadd(129.5, -219, -60, 2.4, sec = self.dend[126]) h.pt3dadd(131, -219, -63, 1.6, sec = self.dend[126]) h.pt3dadd(131, -221, -69, 0.9, sec = self.dend[126]) h.pt3dadd(132, -223, -69, 0.6, sec = self.dend[126]) h.pt3dadd(133, -224.5, -69, 0.7, sec = self.dend[126]) h.pt3dadd(132, -225.5, -66, 0.6, sec = self.dend[126]) h.pt3dadd(134, -226.5, -69, 1, sec = self.dend[126]) h.pt3dadd(134.5, -226.5, -69, 2.4, sec = self.dend[126]) h.pt3dadd(135, -227, -71.5, 3.1, sec = self.dend[126]) h.pt3dadd(135.5, -228.5, -71.5, 2, sec = self.dend[126]) h.pt3dadd(136, -229.5, -74.5, 0.6, sec = self.dend[126]) h.pt3dadd(136, -232, -77.5, 0.6, sec = self.dend[126]) h.pt3dadd(137, -232.5, -77.5, 0.6, sec = self.dend[126]) h.pt3dadd(137.5, -233.5, -77.5, 1.4, sec = self.dend[126]) h.pt3dadd(137.5, -235.5, -77.5, 2.3, sec = self.dend[126]) h.pt3dadd(138.5, -236.5, -77.5, 1.3, sec = self.dend[126]) h.pt3dadd(139, -238, -80.5, 1, sec = self.dend[126]) h.pt3dadd(139.5, -240, -80.5, 0.8, sec = self.dend[126]) h.pt3dadd(139.5, -240.5, -80.5, 0.9, sec = self.dend[126]) h.pt3dadd(139.5, -243.5, -80.5, 0.9, sec = self.dend[126]) h.pt3dadd(140, -244.5, -86.5, 1.4, sec = self.dend[126]) h.pt3dadd(140, -245.5, -77.5, 1.8, sec = self.dend[126]) h.pt3dadd(140.5, -246.5, -80.5, 1.6, sec = self.dend[126]) h.pt3dadd(143, -250, -78.5, 0.3, sec = self.dend[126]) h.pt3dadd(144, -250.5, -78.5, 0.3, sec = self.dend[126]) h.pt3dadd(145, -252, -85.5, 0.1, sec = self.dend[126]) h.pt3dadd(147, -253.5, -85.5, 0.1, sec = self.dend[126]) h.pt3dadd(148.5, -255, -85.5, 0.1, sec = self.dend[126]) h.pt3dadd(150, -256.5, -85.5, 0.1, sec = self.dend[126]) h.pt3dadd(150, -258.5, -85.5, 2.2, sec = self.dend[126]) h.pt3dadd(150, -259.5, -85.5, 2.8, sec = self.dend[126]) h.pt3dadd(149.5, -261.5, -85.5, 1.6, sec = self.dend[126]) h.pt3dadd(149, -263, -90, 0.1, sec = self.dend[126]) h.pt3dadd(149, -264, -85.5, 0.1, sec = self.dend[126]) h.pt3dadd(149, -265.5, -83, 1.3, sec = self.dend[126]) h.pt3dadd(149, -266, -88, 2.5, sec = self.dend[126]) h.pt3dadd(148.5, -268, -88, 1.2, sec = self.dend[126]) h.pt3dadd(148, -270.5, -88, 0.3, sec = self.dend[126]) h.pt3dadd(148, -270.5, -90, 0.1, sec = self.dend[126]) h.pt3dadd(149, -272, -90, 0.1, sec = self.dend[126]) h.pt3dadd(149, -273, -90, 1.5, sec = self.dend[126]) h.pt3dadd(150.5, -274, -92.5, 2.1, sec = self.dend[126]) h.pt3dadd(152, -276, -92.5, 1.1, sec = self.dend[126]) h.pt3dadd(153, -277.5, -92.5, 0.3, sec = self.dend[126]) h.pt3dadd(154.5, -280.5, -95, 0.3, sec = self.dend[126]) h.pt3dadd(155, -281, -95, 0.3, sec = self.dend[126]) h.pt3dadd(155, -283, -92.5, 1.6, sec = self.dend[126]) h.pt3dadd(156, -285, -97.5, 2.8, sec = self.dend[126]) h.pt3dadd(156, -285.5, -97.5, 0.7, sec = self.dend[126]) h.pt3dadd(156.5, -288, -97.5, 0.8, sec = self.dend[126]) h.pt3dadd(157, -289.5, -99.5, 0.8, sec = self.dend[126]) h.pt3dadd(158, -291.5, -99.5, 1.4, sec = self.dend[126]) h.pt3dadd(158.5, -291.5, -99.5, 0.4, sec = self.dend[126]) h.pt3dadd(158, -292.5, -102, 0.1, sec = self.dend[126]) h.pt3dadd(158, -294.5, -102, 0.1, sec = self.dend[126]) h.pt3dadd(159, -294.5, -99.5, 1, sec = self.dend[126]) h.pt3dadd(160, -297.5, -107, 2.5, sec = self.dend[126]) h.pt3dadd(161, -298, -107, 1.2, sec = self.dend[126]) h.pt3dadd(161.5, -299, -107, 0.1, sec = self.dend[126]) h.pt3dadd(164.5, -300, -111.5, 0.1, sec = self.dend[126]) h.pt3dclear(sec = self.dend[127]) h.pt3dadd(82, -179, -41.5, 5.3, sec = self.dend[127]) h.pt3dadd(84, -184, -41.5, 2.8, sec = self.dend[127]) h.pt3dadd(85, -186.5, -41.5, 2.8, sec = self.dend[127]) h.pt3dadd(86.5, -188.5, -47.5, 2.8, sec = self.dend[127]) h.pt3dadd(88, -190.5, -41.5, 2.9, sec = self.dend[127]) h.pt3dadd(88, -191.5, -47.5, 2.2, sec = self.dend[127]) h.pt3dadd(89.5, -193.5, -47.5, 2.1, sec = self.dend[127]) h.pt3dadd(91, -197.5, -41.5, 2.5, sec = self.dend[127]) h.pt3dadd(92.5, -199.5, -47.5, 2.7, sec = self.dend[127]) h.pt3dadd(93, -202.5, -41.5, 2.8, sec = self.dend[127]) h.pt3dadd(93.5, -204.5, -41.5, 3.3, sec = self.dend[127]) h.pt3dadd(95, -206, -47.5, 3.8, sec = self.dend[127]) h.pt3dadd(95.5, -207, -54, 3.6, sec = self.dend[127]) h.pt3dadd(97, -208, -47.5, 4.3, sec = self.dend[127]) h.pt3dadd(97.5, -211, -47.5, 4.3, sec = self.dend[127]) h.pt3dadd(97.5, -212.5, -47.5, 4.3, sec = self.dend[127]) h.pt3dadd(97.5, -213.5, -47.5, 3.4, sec = self.dend[127]) h.pt3dadd(98, -215.5, -60, 3.9, sec = self.dend[127]) h.pt3dadd(99, -218.5, -60, 3.4, sec = self.dend[127]) h.pt3dadd(102.5, -224, -65.5, 2.6, sec = self.dend[127]) h.pt3dadd(104, -226.5, -63.5, 3, sec = self.dend[127]) h.pt3dadd(106.5, -230.5, -63.5, 3.6, sec = self.dend[127]) h.pt3dadd(107.5, -230.5, -61.5, 4.3, sec = self.dend[127]) h.pt3dadd(108.5, -232.5, -65.5, 4.8, sec = self.dend[127]) h.pt3dadd(110.5, -234, -67.5, 3.9, sec = self.dend[127]) h.pt3dadd(112, -236.5, -67.5, 3.3, sec = self.dend[127]) h.pt3dadd(114, -238.5, -67.5, 2.7, sec = self.dend[127]) h.pt3dadd(115.5, -240.5, -67.5, 2.3, sec = self.dend[127]) h.pt3dadd(115.5, -242.5, -67.5, 2.3, sec = self.dend[127]) h.pt3dadd(117, -243, -67.5, 2.4, sec = self.dend[127]) h.pt3dadd(117.5, -245, -67.5, 3.2, sec = self.dend[127]) h.pt3dadd(118, -247, -65.5, 3.2, sec = self.dend[127]) h.pt3dadd(119, -249.5, -67.5, 4.2, sec = self.dend[127]) h.pt3dadd(119.5, -252, -67.5, 3.8, sec = self.dend[127]) h.pt3dadd(122, -254, -67.5, 3.3, sec = self.dend[127]) h.pt3dadd(123, -256, -69.5, 2.7, sec = self.dend[127]) h.pt3dadd(123, -258, -69.5, 2.4, sec = self.dend[127]) h.pt3dadd(124.5, -261, -69.5, 2.7, sec = self.dend[127]) h.pt3dadd(125, -261.5, -69.5, 2.2, sec = self.dend[127]) h.pt3dadd(126.5, -263, -69.5, 2.2, sec = self.dend[127]) h.pt3dadd(128, -265.5, -71.5, 3.4, sec = self.dend[127]) h.pt3dadd(128.5, -265.5, -71.5, 3.4, sec = self.dend[127]) h.pt3dadd(129, -267.5, -69.5, 3.4, sec = self.dend[127]) h.pt3dadd(129, -270, -71.5, 3.7, sec = self.dend[127]) h.pt3dadd(131, -271, -71.5, 2.6, sec = self.dend[127]) h.pt3dadd(131, -273, -73.5, 2.2, sec = self.dend[127]) h.pt3dadd(132, -275, -73.5, 2.6, sec = self.dend[127]) h.pt3dadd(132.5, -276.5, -75, 2.5, sec = self.dend[127]) h.pt3dadd(134, -280.5, -72, 3.5, sec = self.dend[127]) h.pt3dadd(135.5, -283, -69, 3.5, sec = self.dend[127]) h.pt3dadd(137.5, -283, -72, 3.8, sec = self.dend[127]) h.pt3dclear(sec = self.dend[128]) h.pt3dadd(137.5, -283, -72, 3.8, sec = self.dend[128]) h.pt3dadd(135.5, -286, -66, 1.2, sec = self.dend[128]) h.pt3dadd(136.5, -286.5, -75, 1.2, sec = self.dend[128]) h.pt3dadd(134, -287, -75, 1.2, sec = self.dend[128]) h.pt3dadd(136.5, -288.5, -75, 0.9, sec = self.dend[128]) h.pt3dadd(137.5, -291.5, -75, 0.9, sec = self.dend[128]) h.pt3dadd(138.5, -293, -78, 0.9, sec = self.dend[128]) h.pt3dadd(139.5, -293.5, -81, 0.9, sec = self.dend[128]) h.pt3dadd(140.5, -294, -78, 1.4, sec = self.dend[128]) h.pt3dadd(140, -295.5, -78, 3.1, sec = self.dend[128]) h.pt3dadd(141.5, -298, -78, 3.3, sec = self.dend[128]) h.pt3dadd(141.5, -300, -84, 2.6, sec = self.dend[128]) h.pt3dadd(141.5, -300, -81, 1.4, sec = self.dend[128]) h.pt3dadd(141.5, -302.5, -86.5, 0.9, sec = self.dend[128]) h.pt3dadd(143, -303.5, -86.5, 1.1, sec = self.dend[128]) h.pt3dadd(143.5, -305, -86.5, 1.1, sec = self.dend[128]) h.pt3dadd(145, -306.5, -86.5, 0.6, sec = self.dend[128]) h.pt3dadd(144, -308, -86.5, 0.6, sec = self.dend[128]) h.pt3dadd(147, -309.5, -89.5, 1.4, sec = self.dend[128]) h.pt3dadd(147.5, -310, -92.5, 3.4, sec = self.dend[128]) h.pt3dadd(148.5, -313, -86.5, 1.6, sec = self.dend[128]) h.pt3dadd(149.5, -315.5, -89.5, 1.1, sec = self.dend[128]) h.pt3dadd(150.5, -316, -89.5, 0.9, sec = self.dend[128]) h.pt3dadd(153, -319, -92.5, 0.9, sec = self.dend[128]) h.pt3dadd(153, -320.5, -92.5, 0.9, sec = self.dend[128]) h.pt3dadd(155, -323.5, -92.5, 0.8, sec = self.dend[128]) h.pt3dadd(156, -325.5, -94.5, 1.7, sec = self.dend[128]) h.pt3dadd(156.5, -325.5, -90, 1.7, sec = self.dend[128]) h.pt3dadd(156.5, -327, -90, 0.3, sec = self.dend[128]) h.pt3dadd(156.5, -328.5, -90, 0.3, sec = self.dend[128]) h.pt3dadd(157, -329, -92.5, 0.5, sec = self.dend[128]) h.pt3dadd(157.5, -329.5, -90, 0.9, sec = self.dend[128]) h.pt3dadd(159, -330.5, -94.5, 0.1, sec = self.dend[128]) h.pt3dadd(157.5, -331.5, -94.5, 0.1, sec = self.dend[128]) h.pt3dadd(156, -332.5, -94.5, 0.1, sec = self.dend[128]) h.pt3dadd(156.5, -334.5, -90, 1.3, sec = self.dend[128]) h.pt3dadd(156.5, -336, -90, 3.1, sec = self.dend[128]) h.pt3dadd(157, -337, -94.5, 2.1, sec = self.dend[128]) h.pt3dadd(159, -338.5, -94.5, 1.3, sec = self.dend[128]) h.pt3dadd(159, -340, -97, 0.7, sec = self.dend[128]) h.pt3dadd(159.5, -340, -97, 0.7, sec = self.dend[128]) h.pt3dadd(159.5, -342.5, -97, 1.2, sec = self.dend[128]) h.pt3dadd(159.5, -343.5, -97, 1.6, sec = self.dend[128]) h.pt3dadd(159.5, -344, -97, 2.9, sec = self.dend[128]) h.pt3dadd(159, -346, -97, 1.6, sec = self.dend[128]) h.pt3dadd(160, -347.5, -99.5, 1.2, sec = self.dend[128]) h.pt3dadd(159.5, -348, -99.5, 0.9, sec = self.dend[128]) h.pt3dadd(159, -349, -102, 1.4, sec = self.dend[128]) h.pt3dadd(161, -351, -106.5, 1.4, sec = self.dend[128]) h.pt3dadd(161, -351, -111.5, 1.8, sec = self.dend[128]) h.pt3dadd(161, -352.5, -106.5, 1.1, sec = self.dend[128]) h.pt3dadd(162, -354, -106.5, 0.9, sec = self.dend[128]) h.pt3dadd(162, -354.5, -109, 1.3, sec = self.dend[128]) h.pt3dadd(161.5, -356, -106.5, 2.4, sec = self.dend[128]) h.pt3dadd(162, -358, -106.5, 2.8, sec = self.dend[128]) h.pt3dadd(160, -359.5, -109, 1.6, sec = self.dend[128]) h.pt3dadd(158.5, -359.5, -106.5, 0.7, sec = self.dend[128]) h.pt3dadd(158, -361, -106.5, 0.7, sec = self.dend[128]) h.pt3dadd(157, -362.5, -106.5, 1.7, sec = self.dend[128]) h.pt3dadd(156.5, -363.5, -106.5, 2.4, sec = self.dend[128]) h.pt3dadd(155.5, -364.5, -106.5, 3.3, sec = self.dend[128]) h.pt3dadd(153.5, -366, -111.5, 1.4, sec = self.dend[128]) h.pt3dadd(153, -367, -111.5, 0.6, sec = self.dend[128]) h.pt3dadd(151, -368.5, -109, 0.7, sec = self.dend[128]) h.pt3dadd(149.5, -369, -109, 2.1, sec = self.dend[128]) h.pt3dadd(148.5, -371.5, -109, 3.1, sec = self.dend[128]) h.pt3dadd(146.5, -372.5, -109, 1.5, sec = self.dend[128]) h.pt3dadd(146.5, -374.5, -113.5, 0.3, sec = self.dend[128]) h.pt3dadd(145, -377, -113.5, 0.6, sec = self.dend[128]) h.pt3dclear(sec = self.dend[129]) h.pt3dadd(137.5, -283, -72, 3.8, sec = self.dend[129]) h.pt3dadd(139.5, -285, -66, 1.6, sec = self.dend[129]) h.pt3dadd(141, -287, -69, 1.6, sec = self.dend[129]) h.pt3dadd(143.5, -290, -72, 1.6, sec = self.dend[129]) h.pt3dadd(144.5, -290, -72, 1.9, sec = self.dend[129]) h.pt3dadd(144.5, -290.5, -72, 2, sec = self.dend[129]) h.pt3dadd(146, -291.5, -72, 1.5, sec = self.dend[129]) h.pt3dadd(146, -293, -75, 1.1, sec = self.dend[129]) h.pt3dadd(147.5, -294.5, -75, 1.2, sec = self.dend[129]) h.pt3dadd(148, -296, -75, 1.1, sec = self.dend[129]) h.pt3dadd(150, -297, -75, 1.2, sec = self.dend[129]) h.pt3dadd(151.5, -299, -78, 1.8, sec = self.dend[129]) h.pt3dadd(154, -300, -81, 2.2, sec = self.dend[129]) h.pt3dadd(156, -301.5, -81, 3.1, sec = self.dend[129]) h.pt3dadd(157, -302.5, -78, 2.7, sec = self.dend[129]) h.pt3dadd(159, -303, -78, 1.3, sec = self.dend[129]) h.pt3dadd(160, -303, -78, 1, sec = self.dend[129]) h.pt3dadd(162, -304, -78, 0.7, sec = self.dend[129]) h.pt3dadd(163, -306, -81, 1.3, sec = self.dend[129]) h.pt3dadd(162.5, -306.5, -84, 1.8, sec = self.dend[129]) h.pt3dadd(163, -308.5, -81, 2.8, sec = self.dend[129]) h.pt3dadd(166, -309.5, -81, 3.8, sec = self.dend[129]) h.pt3dadd(166, -311.5, -84, 2.3, sec = self.dend[129]) h.pt3dadd(167, -313.5, -84, 1.2, sec = self.dend[129]) h.pt3dadd(169, -313.5, -84, 1.2, sec = self.dend[129]) h.pt3dadd(171.5, -314.5, -84, 1.3, sec = self.dend[129]) h.pt3dadd(172.5, -316, -84, 1.3, sec = self.dend[129]) h.pt3dadd(174, -317, -86.5, 1.6, sec = self.dend[129]) h.pt3dadd(174.5, -319, -84, 2.7, sec = self.dend[129]) h.pt3dadd(175, -321.5, -86.5, 3.2, sec = self.dend[129]) h.pt3dadd(176.5, -323, -89.5, 2.8, sec = self.dend[129]) h.pt3dadd(177, -325, -89.5, 1.9, sec = self.dend[129]) h.pt3dadd(178.5, -325, -89.5, 1.4, sec = self.dend[129]) h.pt3dadd(179.5, -326, -89.5, 1.4, sec = self.dend[129]) h.pt3dadd(182.5, -329, -95.5, 1.4, sec = self.dend[129]) h.pt3dadd(184.5, -333, -93, 2, sec = self.dend[129]) h.pt3dadd(184, -334.5, -100, 1.5, sec = self.dend[129]) h.pt3dadd(185, -335.5, -97.5, 0.6, sec = self.dend[129]) h.pt3dadd(185.5, -337.5, -100, 0.6, sec = self.dend[129]) h.pt3dadd(188, -337.5, -100, 1, sec = self.dend[129]) h.pt3dadd(189, -338.5, -100, 1.4, sec = self.dend[129]) h.pt3dadd(189.5, -340.5, -100, 1.5, sec = self.dend[129]) h.pt3dadd(189.5, -342.5, -105, 3.8, sec = self.dend[129]) h.pt3dadd(191, -349, -105, 1.7, sec = self.dend[129]) h.pt3dadd(191, -351, -107, 1.6, sec = self.dend[129]) h.pt3dadd(192, -351.5, -107, 1.1, sec = self.dend[129]) h.pt3dadd(193.5, -353, -109.5, 0.9, sec = self.dend[129]) h.pt3dadd(194.5, -353.5, -107, 0.9, sec = self.dend[129]) h.pt3dadd(195, -355, -109.5, 0.8, sec = self.dend[129]) h.pt3dadd(195.5, -355.5, -109.5, 0.4, sec = self.dend[129]) h.pt3dadd(196, -356, -109.5, 0.4, sec = self.dend[129]) h.pt3dadd(196.5, -357.5, -107, 0.6, sec = self.dend[129]) h.pt3dadd(197, -359, -109.5, 1.2, sec = self.dend[129]) h.pt3dadd(199, -361.5, -112, 1, sec = self.dend[129]) h.pt3dadd(199.5, -362, -109.5, 2, sec = self.dend[129]) h.pt3dadd(201, -368, -114.5, 4.7, sec = self.dend[129]) h.pt3dadd(202, -371, -112, 2.5, sec = self.dend[129]) h.pt3dadd(203, -374, -114.5, 1, sec = self.dend[129]) h.pt3dadd(203, -374.5, -114.5, 1.2, sec = self.dend[129]) h.pt3dadd(203, -376, -114.5, 0.7, sec = self.dend[129]) h.pt3dadd(203, -377.5, -114.5, 0.4, sec = self.dend[129]) h.pt3dadd(203, -379, -114.5, 1.6, sec = self.dend[129]) h.pt3dadd(203.5, -381.5, -112, 2.1, sec = self.dend[129]) h.pt3dadd(204.5, -382.5, -119, 3.3, sec = self.dend[129]) h.pt3dclear(sec = self.dend[130]) h.pt3dadd(204.5, -382.5, -119, 3.3, sec = self.dend[130]) h.pt3dadd(206, -383, -119, 0.1, sec = self.dend[130]) h.pt3dadd(207, -384, -119, 0.7, sec = self.dend[130]) h.pt3dadd(208, -385, -116.5, 0.8, sec = self.dend[130]) h.pt3dadd(208.5, -385.5, -116.5, 0.5, sec = self.dend[130]) h.pt3dadd(209.5, -386, -116.5, 0.1, sec = self.dend[130]) h.pt3dadd(210.5, -386, -116.5, 0.1, sec = self.dend[130]) h.pt3dadd(211.5, -387.5, -119, 1.5, sec = self.dend[130]) h.pt3dadd(212.5, -387.5, -119, 1.8, sec = self.dend[130]) h.pt3dadd(213.5, -388, -119, 0.1, sec = self.dend[130]) h.pt3dadd(214.5, -388, -119, 0.1, sec = self.dend[130]) h.pt3dadd(215.5, -391.5, -119, 0.1, sec = self.dend[130]) h.pt3dadd(217.5, -391.5, -119, 0.1, sec = self.dend[130]) h.pt3dadd(218, -391.5, -119, 1.6, sec = self.dend[130]) h.pt3dadd(218.5, -391.5, -119, 1.6, sec = self.dend[130]) h.pt3dadd(219, -392, -121.5, 1.4, sec = self.dend[130]) h.pt3dadd(221, -393.5, -121.5, 0.1, sec = self.dend[130]) h.pt3dadd(225.5, -394, -124, 0.1, sec = self.dend[130]) h.pt3dclear(sec = self.dend[131]) h.pt3dadd(204.5, -382.5, -119, 3.3, sec = self.dend[131]) h.pt3dadd(204, -386, -119, 0.2, sec = self.dend[131]) h.pt3dadd(204.5, -387, -116.5, 0.2, sec = self.dend[131]) h.pt3dadd(204.5, -389.5, -116.5, 0.4, sec = self.dend[131]) h.pt3dadd(205, -391, -119, 1.8, sec = self.dend[131]) h.pt3dadd(205, -392, -116.5, 2.9, sec = self.dend[131]) h.pt3dadd(205, -392.5, -116.5, 2.9, sec = self.dend[131]) h.pt3dadd(204.5, -393.5, -116.5, 2.1, sec = self.dend[131]) h.pt3dadd(205.5, -396, -119, 1, sec = self.dend[131]) h.pt3dadd(204.5, -397, -116.5, 1.4, sec = self.dend[131]) h.pt3dadd(204.5, -398, -119, 1.8, sec = self.dend[131]) h.pt3dadd(205, -400.5, -119, 1.8, sec = self.dend[131]) h.pt3dadd(204, -402.5, -119, 1, sec = self.dend[131]) h.pt3dadd(203.5, -403, -119, 1, sec = self.dend[131]) h.pt3dadd(202, -405, -116.5, 1, sec = self.dend[131]) h.pt3dadd(200, -406.5, -116.5, 1, sec = self.dend[131]) h.pt3dadd(199, -407.5, -114.5, 1.2, sec = self.dend[131]) h.pt3dadd(198, -408.5, -112, 1.6, sec = self.dend[131]) h.pt3dadd(198, -411, -116.5, 2.5, sec = self.dend[131]) h.pt3dadd(196, -411, -116.5, 3.4, sec = self.dend[131]) h.pt3dadd(195.5, -413, -119, 4, sec = self.dend[131]) h.pt3dadd(194, -415, -116.5, 2.8, sec = self.dend[131]) h.pt3dadd(191.5, -415, -116.5, 1.8, sec = self.dend[131]) h.pt3dadd(191.5, -417.5, -116.5, 0.7, sec = self.dend[131]) h.pt3dadd(189, -418.5, -116.5, 1.1, sec = self.dend[131]) h.pt3dadd(188, -420, -116.5, 1.2, sec = self.dend[131]) h.pt3dadd(185.5, -421, -116.5, 0.6, sec = self.dend[131]) h.pt3dadd(185.5, -424, -116.5, 0.7, sec = self.dend[131]) h.pt3dadd(185, -424.5, -116.5, 2.4, sec = self.dend[131]) h.pt3dadd(185, -426, -116.5, 3, sec = self.dend[131]) h.pt3dadd(185, -428, -116.5, 1.8, sec = self.dend[131]) h.pt3dadd(185.5, -430.5, -121.5, 0.8, sec = self.dend[131]) h.pt3dadd(185, -432, -116.5, 0.1, sec = self.dend[131]) h.pt3dadd(185.5, -434.5, -116.5, 0.3, sec = self.dend[131]) h.pt3dadd(184, -435.5, -116.5, 0.9, sec = self.dend[131]) h.pt3dadd(182.5, -437.5, -116.5, 1.5, sec = self.dend[131]) h.pt3dadd(182, -439.5, -116.5, 2.1, sec = self.dend[131]) h.pt3dadd(182, -441, -116.5, 2.8, sec = self.dend[131]) h.pt3dadd(182, -444.5, -116.5, 3.6, sec = self.dend[131]) h.pt3dadd(180, -446, -116.5, 2.3, sec = self.dend[131]) h.pt3dadd(177.5, -447.5, -116.5, 1.4, sec = self.dend[131]) h.pt3dadd(177, -449, -116.5, 0.3, sec = self.dend[131]) h.pt3dadd(174.5, -449.5, -116.5, 0.3, sec = self.dend[131]) h.pt3dadd(174, -451.5, -116.5, 1.1, sec = self.dend[131]) h.pt3dadd(173.5, -453, -116.5, 2, sec = self.dend[131]) h.pt3dadd(172, -454.5, -114.5, 1.2, sec = self.dend[131]) h.pt3dadd(172.5, -456, -116.5, 0.5, sec = self.dend[131]) h.pt3dadd(172.5, -458.5, -116.5, 0.5, sec = self.dend[131]) h.pt3dadd(172.5, -459.5, -114.5, 1.4, sec = self.dend[131]) h.pt3dadd(172.5, -462, -119, 1.2, sec = self.dend[131]) h.pt3dadd(172, -466, -119, 0.4, sec = self.dend[131]) h.pt3dadd(170.5, -468, -119, 1.7, sec = self.dend[131]) h.pt3dadd(169.5, -470.5, -116.5, 2.3, sec = self.dend[131]) h.pt3dadd(169, -472, -119, 1.2, sec = self.dend[131]) h.pt3dadd(168, -475, -119, 0.7, sec = self.dend[131]) h.pt3dadd(166.5, -477, -119, 1.1, sec = self.dend[131]) h.pt3dadd(164.5, -483, -121.5, 0.8, sec = self.dend[131]) h.pt3dadd(163, -486.5, -121.5, 0.8, sec = self.dend[131]) h.pt3dadd(161, -491.5, -119, 0.8, sec = self.dend[131]) h.pt3dadd(160.5, -494, -119, 0.1, sec = self.dend[131]) h.pt3dadd(157.5, -495.5, -119, 0.1, sec = self.dend[131]) h.pt3dadd(156.5, -499, -119, 2.4, sec = self.dend[131]) h.pt3dadd(154.5, -501.5, -114.5, 3.2, sec = self.dend[131]) h.pt3dadd(153, -503.5, -124, 1, sec = self.dend[131]) h.pt3dadd(153, -506.5, -124, 0.9, sec = self.dend[131]) h.pt3dadd(152, -509, -124, 1.6, sec = self.dend[131]) h.pt3dadd(151, -511, -124, 1.6, sec = self.dend[131]) h.pt3dadd(150, -514, -124, 1.2, sec = self.dend[131]) h.pt3dadd(150, -518, -124, 0.8, sec = self.dend[131]) h.pt3dadd(149.5, -522, -124, 1.2, sec = self.dend[131]) h.pt3dadd(147, -525.5, -121.5, 1.2, sec = self.dend[131]) h.pt3dadd(144, -528.5, -121.5, 1.2, sec = self.dend[131]) h.pt3dadd(142, -531, -121.5, 1.2, sec = self.dend[131]) h.pt3dadd(139, -535, -116.5, 0.7, sec = self.dend[131]) h.pt3dadd(136.5, -537, -119, 0.7, sec = self.dend[131]) h.pt3dadd(134, -542, -124, 0.6, sec = self.dend[131]) h.pt3dadd(133, -542, -119, 0.6, sec = self.dend[131]) h.pt3dadd(132, -543.5, -119, 1, sec = self.dend[131]) h.pt3dadd(130.5, -544.5, -116.5, 1.6, sec = self.dend[131]) h.pt3dadd(130, -545, -116.5, 0.9, sec = self.dend[131]) h.pt3dadd(129.5, -545.5, -116.5, 0.2, sec = self.dend[131]) h.pt3dadd(129.5, -547, -116.5, 0.2, sec = self.dend[131]) h.pt3dadd(126, -549, -121.5, 2.4, sec = self.dend[131]) h.pt3dadd(124, -550.5, -121.5, 0.5, sec = self.dend[131]) h.pt3dadd(122.5, -552, -121.5, 0.5, sec = self.dend[131]) h.pt3dadd(122, -554, -121.5, 1.2, sec = self.dend[131]) h.pt3dadd(121, -555.5, -121.5, 1.6, sec = self.dend[131]) h.pt3dadd(119, -557, -121.5, 2.7, sec = self.dend[131]) h.pt3dadd(116, -559, -121.5, 1.2, sec = self.dend[131]) h.pt3dadd(113.5, -559.5, -121.5, 0.5, sec = self.dend[131]) h.pt3dadd(111, -562.5, -119, 0.5, sec = self.dend[131]) h.pt3dadd(108, -562.5, -119, 0.5, sec = self.dend[131]) h.pt3dadd(107.5, -564, -121.5, 0.5, sec = self.dend[131]) h.pt3dadd(106.5, -566.5, -114.5, 0.5, sec = self.dend[131]) h.pt3dadd(107.5, -568.5, -114.5, 1.6, sec = self.dend[131]) h.pt3dadd(107, -569.5, -114.5, 1.6, sec = self.dend[131]) h.pt3dadd(105.5, -571.5, -114.5, 0.7, sec = self.dend[131]) h.pt3dadd(104.5, -573.5, -114.5, 0.7, sec = self.dend[131]) h.pt3dadd(104.5, -576, -114.5, 1, sec = self.dend[131]) h.pt3dadd(105, -577.5, -114.5, 1.3, sec = self.dend[131]) h.pt3dadd(105, -579, -114.5, 1.3, sec = self.dend[131]) h.pt3dadd(107, -581.5, -114.5, 1.5, sec = self.dend[131]) h.pt3dadd(106.5, -584.5, -112, 1.9, sec = self.dend[131]) h.pt3dadd(106, -587, -112, 2.1, sec = self.dend[131]) h.pt3dadd(107.5, -589.5, -109.5, 1.3, sec = self.dend[131]) h.pt3dadd(110, -589.5, -109.5, 0.1, sec = self.dend[131]) h.pt3dadd(113, -589.5, -109.5, 0.1, sec = self.dend[131]) h.pt3dadd(115.5, -589.5, -112, 0.1, sec = self.dend[131]) h.pt3dadd(116, -590.5, -112, 1.2, sec = self.dend[131]) h.pt3dadd(117.5, -591.5, -112, 1.5, sec = self.dend[131]) h.pt3dadd(119.5, -592, -112, 0.9, sec = self.dend[131]) h.pt3dadd(121, -592.5, -112, 0.1, sec = self.dend[131]) h.pt3dadd(122.5, -594.5, -112, 0.1, sec = self.dend[131]) h.pt3dadd(123, -597.5, -112, 0.1, sec = self.dend[131]) h.pt3dadd(123, -600, -112, 0.1, sec = self.dend[131]) h.pt3dadd(124.5, -601, -109.5, 1.6, sec = self.dend[131]) h.pt3dadd(126, -602.5, -112, 0.6, sec = self.dend[131]) h.pt3dadd(126, -603.5, -112, 0.1, sec = self.dend[131]) h.pt3dadd(126, -608, -109.5, 0.1, sec = self.dend[131]) h.pt3dadd(126, -610.5, -109.5, 0.1, sec = self.dend[131]) h.pt3dadd(126, -611, -107, 1.6, sec = self.dend[131]) h.pt3dadd(125.5, -611, -112, 1.3, sec = self.dend[131]) h.pt3dadd(125.5, -611.5, -109.5, 0.3, sec = self.dend[131]) h.pt3dadd(125, -613.5, -109.5, 0.3, sec = self.dend[131]) h.pt3dadd(123.5, -613.5, -109.5, 0.3, sec = self.dend[131]) h.pt3dadd(121.5, -618, -107, 0.3, sec = self.dend[131]) h.pt3dadd(119.5, -618, -107, 0.3, sec = self.dend[131]) h.pt3dadd(120, -619.5, -109.5, 1.5, sec = self.dend[131]) h.pt3dadd(122, -620.5, -109.5, 0.7, sec = self.dend[131]) h.pt3dadd(124, -620.5, -107, 0.7, sec = self.dend[131]) h.pt3dadd(126.5, -620.5, -107, 0.7, sec = self.dend[131]) h.pt3dadd(127.5, -622, -107, 0.7, sec = self.dend[131]) h.pt3dadd(126.5, -624.5, -105, 0.1, sec = self.dend[131]) h.pt3dadd(128, -625, -107, 0.1, sec = self.dend[131]) h.pt3dadd(129.5, -625.5, -107, 0.1, sec = self.dend[131]) h.pt3dadd(131.5, -629, -107, 0.1, sec = self.dend[131]) h.pt3dadd(133, -629, -105, 0.1, sec = self.dend[131]) h.pt3dadd(135, -629.5, -105, 0.1, sec = self.dend[131]) h.pt3dadd(135.5, -633, -100, 0.1, sec = self.dend[131]) h.pt3dadd(132.5, -636.5, -100, 0.1, sec = self.dend[131]) h.pt3dadd(127, -636.5, -97.5, 0.1, sec = self.dend[131]) h.pt3dadd(125.5, -637.5, -97.5, 0.1, sec = self.dend[131]) h.pt3dadd(124.5, -640, -102.5, 0.1, sec = self.dend[131]) h.pt3dadd(122.5, -639.5, -97.5, 1.6, sec = self.dend[131]) h.pt3dadd(121, -642, -95.5, 0.1, sec = self.dend[131]) h.pt3dadd(119, -642.5, -95.5, 0.1, sec = self.dend[131]) h.pt3dadd(118, -642, -93, 1.6, sec = self.dend[131]) h.pt3dadd(115.5, -642.5, -93, 0.1, sec = self.dend[131]) h.pt3dclear(sec = self.dend[132]) h.pt3dadd(3, 6.5, -4, 13.2, sec = self.dend[132]) h.pt3dadd(-4, 3, -3, 9.3, sec = self.dend[132]) h.pt3dadd(-7.5, 2, -2, 8.5, sec = self.dend[132]) h.pt3dadd(-10.5, 1, -3, 7.7, sec = self.dend[132]) h.pt3dadd(-12.5, -1, -3, 7.5, sec = self.dend[132]) h.pt3dadd(-16, -1.5, -3, 8.5, sec = self.dend[132]) h.pt3dclear(sec = self.dend[133]) h.pt3dadd(-16, -1.5, -3, 8.5, sec = self.dend[133]) h.pt3dadd(-25, -3.5, -1, 6.7, sec = self.dend[133]) h.pt3dadd(-28, -2.5, -6.5, 6, sec = self.dend[133]) h.pt3dadd(-30.5, -2, -5, 5, sec = self.dend[133]) h.pt3dadd(-34, -2, -5, 4, sec = self.dend[133]) h.pt3dadd(-36, -2.5, -6.5, 4, sec = self.dend[133]) h.pt3dadd(-38.5, -3.5, -6.5, 4.9, sec = self.dend[133]) h.pt3dadd(-40, -4, -6.5, 3.8, sec = self.dend[133]) h.pt3dadd(-42.5, -3.5, -5.5, 3.6, sec = self.dend[133]) h.pt3dadd(-44.5, -3.5, -8.5, 3.7, sec = self.dend[133]) h.pt3dadd(-50, -4.5, -9.5, 3.6, sec = self.dend[133]) h.pt3dadd(-58, -5.5, -9.5, 7.1, sec = self.dend[133]) h.pt3dadd(-64, -5.5, -9.5, 7.1, sec = self.dend[133]) h.pt3dadd(-68, -6, -10.5, 7.1, sec = self.dend[133]) h.pt3dadd(-72, -7, -10.5, 6.5, sec = self.dend[133]) h.pt3dadd(-75.5, -8, -11.5, 6.8, sec = self.dend[133]) h.pt3dadd(-81.5, -9.5, -11.5, 7.8, sec = self.dend[133]) h.pt3dadd(-86, -9.5, -11.5, 7.8, sec = self.dend[133]) h.pt3dadd(-90, -10.5, -11.5, 7.8, sec = self.dend[133]) h.pt3dadd(-93.5, -11, -11.5, 7.2, sec = self.dend[133]) h.pt3dadd(-97, -11.5, -11.5, 6.9, sec = self.dend[133]) h.pt3dadd(-103, -12.5, -11.5, 7.3, sec = self.dend[133]) h.pt3dadd(-106.5, -12.5, -11.5, 7, sec = self.dend[133]) h.pt3dadd(-113, -12.5, -14, 6.7, sec = self.dend[133]) h.pt3dadd(-116.5, -12.5, -13, 6.8, sec = self.dend[133]) h.pt3dadd(-121, -13, -13, 6.5, sec = self.dend[133]) h.pt3dadd(-123.5, -14.5, -13, 6.8, sec = self.dend[133]) h.pt3dadd(-128.5, -16, -13, 6.8, sec = self.dend[133]) h.pt3dadd(-132, -18, -15, 7.4, sec = self.dend[133]) h.pt3dadd(-136.5, -19.5, -15, 7.4, sec = self.dend[133]) h.pt3dclear(sec = self.dend[134]) h.pt3dadd(-136.5, -19.5, -15, 7.4, sec = self.dend[134]) h.pt3dadd(-142.5, -20, -16.5, 4.9, sec = self.dend[134]) h.pt3dadd(-147, -20, -16.5, 4.9, sec = self.dend[134]) h.pt3dadd(-150.5, -21, -15, 5.1, sec = self.dend[134]) h.pt3dadd(-154, -22.5, -16.5, 5.1, sec = self.dend[134]) h.pt3dadd(-156, -24.5, -15, 5, sec = self.dend[134]) h.pt3dadd(-161.5, -26, -15.5, 3.2, sec = self.dend[134]) h.pt3dadd(-164.5, -27.5, -15.5, 3.8, sec = self.dend[134]) h.pt3dadd(-166, -28.5, -17, 4.4, sec = self.dend[134]) h.pt3dadd(-170.5, -29.5, -17, 3.4, sec = self.dend[134]) h.pt3dadd(-174, -32, -17, 3.3, sec = self.dend[134]) h.pt3dadd(-178.5, -33, -17.5, 3.8, sec = self.dend[134]) h.pt3dadd(-182.5, -33, -17.5, 4.3, sec = self.dend[134]) h.pt3dadd(-187, -35, -17.5, 4.3, sec = self.dend[134]) h.pt3dadd(-191.5, -35, -17.5, 4.3, sec = self.dend[134]) h.pt3dadd(-195.5, -35.5, -17.5, 3.6, sec = self.dend[134]) h.pt3dadd(-199.5, -36.5, -19, 3.5, sec = self.dend[134]) h.pt3dadd(-203, -38, -19, 3.3, sec = self.dend[134]) h.pt3dadd(-205.5, -41, -17.5, 4.3, sec = self.dend[134]) h.pt3dadd(-209, -44, -17.5, 3.6, sec = self.dend[134]) h.pt3dadd(-212.5, -46.5, -17.5, 4.6, sec = self.dend[134]) h.pt3dadd(-213, -50, -18, 2.7, sec = self.dend[134]) h.pt3dadd(-216, -51.5, -18, 2.7, sec = self.dend[134]) h.pt3dadd(-219, -51.5, -17.5, 4.4, sec = self.dend[134]) h.pt3dadd(-221, -51.5, -17.5, 5.4, sec = self.dend[134]) h.pt3dadd(-224.5, -52, -17.5, 4.6, sec = self.dend[134]) h.pt3dadd(-227.5, -54.5, -17.5, 4.3, sec = self.dend[134]) h.pt3dadd(-231, -57.5, -18, 4.1, sec = self.dend[134]) h.pt3dadd(-235, -60.5, -18, 4.5, sec = self.dend[134]) h.pt3dadd(-239, -61, -18, 4.8, sec = self.dend[134]) h.pt3dadd(-242.5, -61, -18, 5.7, sec = self.dend[134]) h.pt3dadd(-246, -60.5, -19, 6.8, sec = self.dend[134]) h.pt3dadd(-250, -60.5, -19, 6.3, sec = self.dend[134]) h.pt3dadd(-253.5, -60, -19, 6, sec = self.dend[134]) h.pt3dadd(-257, -58.5, -19, 6, sec = self.dend[134]) h.pt3dadd(-261, -57, -19, 6, sec = self.dend[134]) h.pt3dadd(-265, -55, -19.5, 6, sec = self.dend[134]) h.pt3dadd(-266.5, -55, -19.5, 2.5, sec = self.dend[134]) h.pt3dadd(-268.5, -55, -19.5, 3.4, sec = self.dend[134]) h.pt3dadd(-271, -55, -25.5, 5.4, sec = self.dend[134]) h.pt3dadd(-273.5, -54, -19.5, 6.2, sec = self.dend[134]) h.pt3dadd(-275, -54, -19.5, 5.2, sec = self.dend[134]) h.pt3dadd(-278, -54, -19.5, 4.6, sec = self.dend[134]) h.pt3dadd(-281.5, -54, -25.5, 4.6, sec = self.dend[134]) h.pt3dadd(-284.5, -54, -25.5, 5.5, sec = self.dend[134]) h.pt3dadd(-287.5, -54, -25.5, 6.5, sec = self.dend[134]) h.pt3dadd(-290, -54, -25.5, 5.6, sec = self.dend[134]) h.pt3dadd(-292, -55.5, -25.5, 4.7, sec = self.dend[134]) h.pt3dadd(-293.5, -57, -25.5, 5.3, sec = self.dend[134]) h.pt3dadd(-295, -57, -25.5, 4.9, sec = self.dend[134]) h.pt3dadd(-297, -57, -25.5, 3.7, sec = self.dend[134]) h.pt3dadd(-299.5, -57, -19.5, 4.1, sec = self.dend[134]) h.pt3dadd(-301.5, -57, -19.5, 4.1, sec = self.dend[134]) h.pt3dadd(-303, -57, -19.5, 4.1, sec = self.dend[134]) h.pt3dadd(-303, -60, -19.5, 4.4, sec = self.dend[134]) h.pt3dadd(-306, -60, -25.5, 4.4, sec = self.dend[134]) h.pt3dadd(-308, -61.5, -25.5, 5.7, sec = self.dend[134]) h.pt3dadd(-309, -63, -25.5, 7.1, sec = self.dend[134]) h.pt3dadd(-311.5, -66, -25.5, 6.3, sec = self.dend[134]) h.pt3dadd(-313.5, -68, -25.5, 7, sec = self.dend[134]) h.pt3dadd(-317, -70.5, -32, 7, sec = self.dend[134]) h.pt3dadd(-319, -71.5, -32, 7.1, sec = self.dend[134]) h.pt3dadd(-321.5, -73, -32, 6.4, sec = self.dend[134]) h.pt3dadd(-324, -74, -32, 6.4, sec = self.dend[134]) h.pt3dadd(-327, -75.5, -32, 6.7, sec = self.dend[134]) h.pt3dadd(-330, -80, -38, 6.9, sec = self.dend[134]) h.pt3dadd(-330.5, -82.5, -38, 6.9, sec = self.dend[134]) h.pt3dadd(-331.5, -84.5, -44.5, 6.8, sec = self.dend[134]) h.pt3dadd(-332, -86, -44.5, 6.5, sec = self.dend[134]) h.pt3dadd(-333, -88, -44.5, 6.5, sec = self.dend[134]) h.pt3dadd(-335.5, -90, -44.5, 5.5, sec = self.dend[134]) h.pt3dadd(-339, -92.5, -46.5, 5.2, sec = self.dend[134]) h.pt3dadd(-342, -93, -48.5, 5.2, sec = self.dend[134]) h.pt3dadd(-343.5, -94, -48.5, 5, sec = self.dend[134]) h.pt3dadd(-346.5, -95, -48.5, 3.8, sec = self.dend[134]) h.pt3dadd(-349, -96.5, -48.5, 4.4, sec = self.dend[134]) h.pt3dadd(-349, -100.5, -48.5, 6.1, sec = self.dend[134]) h.pt3dadd(-350.5, -101, -50.5, 4.2, sec = self.dend[134]) h.pt3dadd(-351.5, -101.5, -52.5, 4.2, sec = self.dend[134]) h.pt3dadd(-353.5, -103.5, -52.5, 4.7, sec = self.dend[134]) h.pt3dadd(-355.5, -106, -52.5, 5.7, sec = self.dend[134]) h.pt3dadd(-358, -107, -50.5, 4.7, sec = self.dend[134]) h.pt3dadd(-360, -109.5, -52.5, 4.6, sec = self.dend[134]) h.pt3dadd(-362, -112, -54.5, 5.7, sec = self.dend[134]) h.pt3dadd(-365, -115.5, -66, 5.7, sec = self.dend[134]) h.pt3dadd(-367, -119.5, -66, 4.9, sec = self.dend[134]) h.pt3dadd(-369.5, -122, -69, 4.9, sec = self.dend[134]) h.pt3dadd(-372, -122, -69, 4.4, sec = self.dend[134]) h.pt3dadd(-372.5, -124.5, -75, 4.4, sec = self.dend[134]) h.pt3dadd(-373.5, -126.5, -75, 4.3, sec = self.dend[134]) h.pt3dadd(-374, -129, -78, 3.8, sec = self.dend[134]) h.pt3dadd(-376.5, -130.5, -81, 3.8, sec = self.dend[134]) h.pt3dadd(-377.5, -131, -78, 4.3, sec = self.dend[134]) h.pt3dadd(-379.5, -131, -84, 4.1, sec = self.dend[134]) h.pt3dadd(-382.5, -137.5, -89.5, 6.3, sec = self.dend[134]) h.pt3dadd(-384.5, -142.5, -87, 6, sec = self.dend[134]) h.pt3dadd(-391, -142, -84.5, 3.7, sec = self.dend[134]) h.pt3dadd(-395, -145, -82, 4.3, sec = self.dend[134]) h.pt3dadd(-397.5, -146, -82, 5.2, sec = self.dend[134]) h.pt3dadd(-399, -150, -84.5, 4.9, sec = self.dend[134]) h.pt3dadd(-399.5, -150, -87, 4.8, sec = self.dend[134]) h.pt3dadd(-400.5, -153, -87, 2.6, sec = self.dend[134]) h.pt3dadd(-402.5, -153, -87, 2.5, sec = self.dend[134]) h.pt3dadd(-404, -152.5, -91.5, 3.1, sec = self.dend[134]) h.pt3dclear(sec = self.dend[135]) h.pt3dadd(-404, -152.5, -91.5, 3.1, sec = self.dend[135]) h.pt3dadd(-409.5, -153.5, -91.5, 4.6, sec = self.dend[135]) h.pt3dadd(-412, -153.5, -91.5, 4.6, sec = self.dend[135]) h.pt3dadd(-416, -154, -96.5, 4.6, sec = self.dend[135]) h.pt3dadd(-420, -154.5, -96.5, 4.9, sec = self.dend[135]) h.pt3dadd(-422.5, -157, -101, 3.6, sec = self.dend[135]) h.pt3dadd(-425, -157, -101, 3.4, sec = self.dend[135]) h.pt3dadd(-427.5, -158.5, -98.5, 3, sec = self.dend[135]) h.pt3dadd(-430, -159.5, -101, 4.2, sec = self.dend[135]) h.pt3dadd(-433, -161.5, -101, 4.5, sec = self.dend[135]) h.pt3dadd(-436, -163.5, -101, 5.3, sec = self.dend[135]) h.pt3dclear(sec = self.dend[136]) h.pt3dadd(-404, -152.5, -91.5, 3.1, sec = self.dend[136]) h.pt3dadd(-409, -150.5, -94, 0.1, sec = self.dend[136]) h.pt3dadd(-409.5, -148, -91.5, 0.1, sec = self.dend[136]) h.pt3dadd(-410.5, -148, -91.5, 1.3, sec = self.dend[136]) h.pt3dadd(-413, -146, -94, 0.9, sec = self.dend[136]) h.pt3dadd(-414, -147, -101, 0.9, sec = self.dend[136]) h.pt3dadd(-415.5, -147, -101, 1.8, sec = self.dend[136]) h.pt3dadd(-417, -145.5, -96.5, 0.2, sec = self.dend[136]) h.pt3dadd(-418.5, -144, -98.5, 0.2, sec = self.dend[136]) h.pt3dadd(-420, -144, -103.5, 1.8, sec = self.dend[136]) h.pt3dadd(-422.5, -144, -103.5, 0.3, sec = self.dend[136]) h.pt3dadd(-424.5, -143.5, -106, 0.3, sec = self.dend[136]) h.pt3dadd(-425, -141, -101, 1.8, sec = self.dend[136]) h.pt3dadd(-427, -141, -106, 0.1, sec = self.dend[136]) h.pt3dclear(sec = self.dend[137]) h.pt3dadd(-136.5, -19.5, -15, 7.4, sec = self.dend[137]) h.pt3dadd(-145.5, -25.5, -15, 3.8, sec = self.dend[137]) h.pt3dadd(-148.5, -26, -15, 3.8, sec = self.dend[137]) h.pt3dadd(-153, -30, -15, 3.8, sec = self.dend[137]) h.pt3dadd(-157, -30, -16.5, 4.6, sec = self.dend[137]) h.pt3dadd(-161, -31.5, -15, 5.2, sec = self.dend[137]) h.pt3dadd(-169, -32, -14, 5.6, sec = self.dend[137]) h.pt3dadd(-171.5, -32, -15, 4.6, sec = self.dend[137]) h.pt3dadd(-173.5, -32, -15, 3.8, sec = self.dend[137]) h.pt3dadd(-175.5, -32, -15, 2.8, sec = self.dend[137]) h.pt3dadd(-178, -32, -15, 2.9, sec = self.dend[137]) h.pt3dadd(-179.5, -32, -14, 4.4, sec = self.dend[137]) h.pt3dadd(-183, -32, -15, 5.3, sec = self.dend[137]) h.pt3dadd(-186.5, -33, -15, 5.3, sec = self.dend[137]) h.pt3dadd(-189.5, -35, -15, 4.9, sec = self.dend[137]) h.pt3dadd(-193.5, -35, -15, 5.3, sec = self.dend[137]) h.pt3dadd(-197.5, -35, -15, 5.3, sec = self.dend[137]) h.pt3dadd(-200.5, -35, -14, 4.6, sec = self.dend[137]) h.pt3dadd(-204.5, -35, -14, 4.3, sec = self.dend[137]) h.pt3dadd(-207.5, -35, -14, 4.4, sec = self.dend[137]) h.pt3dadd(-212, -36.5, -14, 4.7, sec = self.dend[137]) h.pt3dadd(-215.5, -36.5, -14, 5.7, sec = self.dend[137]) h.pt3dadd(-221.5, -37.5, -14, 5.4, sec = self.dend[137]) h.pt3dadd(-226, -38.5, -14, 5.3, sec = self.dend[137]) h.pt3dadd(-229, -38.5, -14, 4.9, sec = self.dend[137]) h.pt3dadd(-233.5, -37, -14, 3.9, sec = self.dend[137]) h.pt3dadd(-237.5, -34.5, -11.5, 3.1, sec = self.dend[137]) h.pt3dadd(-239.5, -34.5, -11.5, 2.6, sec = self.dend[137]) h.pt3dadd(-242, -34.5, -11.5, 3.4, sec = self.dend[137]) h.pt3dadd(-245.5, -35, -11.5, 5.2, sec = self.dend[137]) h.pt3dadd(-249, -35, -13, 5.3, sec = self.dend[137]) h.pt3dadd(-253.5, -36, -11.5, 5.3, sec = self.dend[137]) h.pt3dadd(-257.5, -36, -10.5, 5, sec = self.dend[137]) h.pt3dadd(-263, -34.5, -4, 4, sec = self.dend[137]) h.pt3dadd(-267, -34.5, -4, 3.1, sec = self.dend[137]) h.pt3dadd(-269, -34.5, -4, 3.1, sec = self.dend[137]) h.pt3dadd(-273, -34.5, -3, 3.7, sec = self.dend[137]) h.pt3dadd(-277.5, -35.5, -2, 4.7, sec = self.dend[137]) h.pt3dadd(-281.5, -37, -6, 4, sec = self.dend[137]) h.pt3dadd(-285, -37, -5, 3.3, sec = self.dend[137]) h.pt3dadd(-290, -38, -5, 5.2, sec = self.dend[137]) h.pt3dadd(-301, -42, -5, 5.7, sec = self.dend[137]) h.pt3dadd(-304.5, -43.5, -4, 4.6, sec = self.dend[137]) h.pt3dadd(-307.5, -43.5, -2, 3.7, sec = self.dend[137]) h.pt3dadd(-310.5, -45.5, -3, 3.6, sec = self.dend[137]) h.pt3dadd(-314, -47, -3, 4.3, sec = self.dend[137]) h.pt3dadd(-318, -47, -3, 5, sec = self.dend[137]) h.pt3dadd(-321.5, -49, -3, 4.3, sec = self.dend[137]) h.pt3dadd(-325.5, -49.5, -3, 3.6, sec = self.dend[137]) h.pt3dadd(-330, -51.5, -2, 3.1, sec = self.dend[137]) h.pt3dadd(-334, -51.5, -2, 3.7, sec = self.dend[137]) h.pt3dadd(-337.5, -51.5, -1, 4, sec = self.dend[137]) h.pt3dadd(-342, -51.5, -1, 5.3, sec = self.dend[137]) h.pt3dadd(-346, -50.5, -1, 5.7, sec = self.dend[137]) h.pt3dadd(-349, -50, -1, 5.7, sec = self.dend[137]) h.pt3dclear(sec = self.dend[138]) h.pt3dadd(-349, -50, -1, 5.7, sec = self.dend[138]) h.pt3dadd(-351.5, -52, -4, 0.5, sec = self.dend[138]) h.pt3dadd(-353, -53, -4, 0.5, sec = self.dend[138]) h.pt3dadd(-354, -56, -4, 0.5, sec = self.dend[138]) h.pt3dadd(-355, -57.5, -3, 1.2, sec = self.dend[138]) h.pt3dadd(-357.5, -59, -3, 0.5, sec = self.dend[138]) h.pt3dadd(-359, -61, -3, 0.4, sec = self.dend[138]) h.pt3dadd(-359.5, -62, -3, 2.5, sec = self.dend[138]) h.pt3dadd(-360, -62, -3, 2.7, sec = self.dend[138]) h.pt3dadd(-361, -64, -3, 1.4, sec = self.dend[138]) h.pt3dadd(-361.5, -65.5, -3, 0.6, sec = self.dend[138]) h.pt3dadd(-362.5, -67, 1.5, 0.1, sec = self.dend[138]) h.pt3dadd(-364, -68, 1.5, 1.1, sec = self.dend[138]) h.pt3dadd(-367, -70, 1.5, 0.2, sec = self.dend[138]) h.pt3dadd(-369, -71.5, 1.5, 0.2, sec = self.dend[138]) h.pt3dadd(-370.5, -72, 1.5, 0.2, sec = self.dend[138]) h.pt3dadd(-375.5, -74, -0.5, 0.2, sec = self.dend[138]) h.pt3dadd(-375, -77, -0.5, 0.2, sec = self.dend[138]) h.pt3dadd(-374.5, -78, -0.5, 0.2, sec = self.dend[138]) h.pt3dadd(-376.5, -81, -1, 0.1, sec = self.dend[138]) h.pt3dadd(-377.5, -81.5, -1, 1, sec = self.dend[138]) h.pt3dadd(-379, -82, -1, 0.2, sec = self.dend[138]) h.pt3dadd(-379, -84.5, -1, 0.2, sec = self.dend[138]) h.pt3dadd(-379, -85.5, -0.5, 2.4, sec = self.dend[138]) h.pt3dadd(-379.5, -87.5, -2, 0.2, sec = self.dend[138]) h.pt3dadd(-382, -89, -4, 0.1, sec = self.dend[138]) h.pt3dadd(-382, -91, -4, 0.1, sec = self.dend[138]) h.pt3dadd(-383.5, -92, -3, 0.8, sec = self.dend[138]) h.pt3dadd(-383.5, -94.5, -4, 0.1, sec = self.dend[138]) h.pt3dadd(-379.5, -95.5, -7.5, 0.1, sec = self.dend[138]) h.pt3dadd(-375.5, -93.5, -9.5, 0.1, sec = self.dend[138]) h.pt3dclear(sec = self.dend[139]) h.pt3dadd(-349, -50, -1, 5.7, sec = self.dend[139]) h.pt3dadd(-352.5, -49.5, -1, 3.9, sec = self.dend[139]) h.pt3dadd(-355, -47.5, -2, 3.6, sec = self.dend[139]) h.pt3dadd(-358, -47.5, -2, 4, sec = self.dend[139]) h.pt3dadd(-362, -45.5, -2, 4, sec = self.dend[139]) h.pt3dadd(-364.5, -43.5, -1, 3.6, sec = self.dend[139]) h.pt3dadd(-368.5, -43.5, -1, 3.4, sec = self.dend[139]) h.pt3dadd(-371.5, -43, -1, 4.4, sec = self.dend[139]) h.pt3dadd(-375.5, -43, 3.5, 4.8, sec = self.dend[139]) h.pt3dadd(-380, -43, 4, 4.8, sec = self.dend[139]) h.pt3dadd(-385.5, -43, 4, 4.8, sec = self.dend[139]) h.pt3dadd(-391.5, -43, 6.5, 2.5, sec = self.dend[139]) h.pt3dadd(-396.5, -42, 15, 3, sec = self.dend[139]) h.pt3dadd(-400, -42, 17.5, 3.4, sec = self.dend[139]) h.pt3dadd(-405.5, -41.5, 20.5, 3.4, sec = self.dend[139]) h.pt3dadd(-408.5, -41.5, 20.5, 2.7, sec = self.dend[139]) h.pt3dadd(-411.5, -41.5, 20.5, 2.5, sec = self.dend[139]) h.pt3dadd(-415.5, -40.5, 20.5, 2.7, sec = self.dend[139]) h.pt3dadd(-421, -39.5, 20.5, 3.8, sec = self.dend[139]) h.pt3dadd(-424, -39, 23, 4.9, sec = self.dend[139]) h.pt3dadd(-429, -39.5, 23, 3.2, sec = self.dend[139]) h.pt3dadd(-431.5, -39.5, 23, 2.6, sec = self.dend[139]) h.pt3dadd(-435, -39.5, 23, 2.6, sec = self.dend[139]) h.pt3dadd(-438.5, -39.5, 23, 2.7, sec = self.dend[139]) h.pt3dadd(-441.5, -39.5, 23, 3.4, sec = self.dend[139]) h.pt3dadd(-445.5, -39.5, 23, 4.3, sec = self.dend[139]) h.pt3dadd(-449.5, -40, 31.5, 4.6, sec = self.dend[139]) h.pt3dadd(-453, -41, 34.5, 3.8, sec = self.dend[139]) h.pt3dadd(-458, -41, 34.5, 3.8, sec = self.dend[139]) h.pt3dadd(-463.5, -42.5, 36, 3.8, sec = self.dend[139]) h.pt3dadd(-469.5, -42.5, 37.5, 5.9, sec = self.dend[139]) h.pt3dadd(-475, -43, 39, 6.6, sec = self.dend[139]) h.pt3dadd(-477, -43.5, 39, 5.7, sec = self.dend[139]) h.pt3dadd(-477, -43.5, 43.5, 7.2, sec = self.dend[139]) h.pt3dadd(-480, -45, 43.5, 4.1, sec = self.dend[139]) h.pt3dadd(-483, -46, 43.5, 3.3, sec = self.dend[139]) h.pt3dadd(-486, -47, 49, 2.7, sec = self.dend[139]) h.pt3dadd(-488.5, -47.5, 46, 2.8, sec = self.dend[139]) h.pt3dadd(-491, -48.5, 46, 3.6, sec = self.dend[139]) h.pt3dadd(-495, -51, 46, 3.5, sec = self.dend[139]) h.pt3dadd(-498.5, -53.5, 46, 3.6, sec = self.dend[139]) h.pt3dadd(-500, -53.5, 46, 2.5, sec = self.dend[139]) h.pt3dadd(-503, -53.5, 46, 3.6, sec = self.dend[139]) h.pt3dadd(-504, -53.5, 46, 5.4, sec = self.dend[139]) h.pt3dadd(-506, -53.5, 46, 6, sec = self.dend[139]) h.pt3dadd(-510, -53.5, 47.5, 5.2, sec = self.dend[139]) h.pt3dadd(-512.5, -53.5, 47.5, 3.3, sec = self.dend[139]) h.pt3dadd(-516, -53.5, 47.5, 2.3, sec = self.dend[139]) h.pt3dadd(-518.5, -53.5, 47.5, 1.9, sec = self.dend[139]) h.pt3dadd(-521, -53.5, 47.5, 3.6, sec = self.dend[139]) h.pt3dadd(-524, -54.5, 47.5, 5.2, sec = self.dend[139]) h.pt3dadd(-528.5, -56.5, 49, 7.6, sec = self.dend[139]) h.pt3dadd(-533.5, -55, 46, 8, sec = self.dend[139]) h.pt3dclear(sec = self.dend[140]) h.pt3dadd(-533.5, -55, 46, 8, sec = self.dend[140]) h.pt3dadd(-540.5, -52, 46, 3.3, sec = self.dend[140]) h.pt3dadd(-543.5, -50, 46, 2, sec = self.dend[140]) h.pt3dadd(-548.5, -50, 44.5, 2.1, sec = self.dend[140]) h.pt3dadd(-550.5, -50, 46, 2.5, sec = self.dend[140]) h.pt3dadd(-552, -48, 47.5, 4, sec = self.dend[140]) h.pt3dadd(-555.5, -48, 49, 4.9, sec = self.dend[140]) h.pt3dadd(-557.5, -48, 49, 1.7, sec = self.dend[140]) h.pt3dadd(-559, -47.5, 49, 1.6, sec = self.dend[140]) h.pt3dadd(-562.5, -46.5, 49, 1.2, sec = self.dend[140]) h.pt3dadd(-563, -45, 50.5, 2.9, sec = self.dend[140]) h.pt3dadd(-567, -44.5, 54.5, 3.8, sec = self.dend[140]) h.pt3dadd(-571.5, -43, 54.5, 1.6, sec = self.dend[140]) h.pt3dadd(-572, -43, 54.5, 1.1, sec = self.dend[140]) h.pt3dadd(-576.5, -41.5, 56, 1.4, sec = self.dend[140]) h.pt3dadd(-579, -40, 56, 1.5, sec = self.dend[140]) h.pt3dadd(-581.5, -39, 57.5, 4.3, sec = self.dend[140]) h.pt3dadd(-586, -37, 57.5, 2.5, sec = self.dend[140]) h.pt3dadd(-587, -35.5, 59, 1.6, sec = self.dend[140]) h.pt3dadd(-589.5, -35.5, 59, 1.6, sec = self.dend[140]) h.pt3dadd(-591, -35.5, 60.5, 2.3, sec = self.dend[140]) h.pt3dadd(-594, -34, 60.5, 3.2, sec = self.dend[140]) h.pt3dadd(-597, -32.5, 60.5, 3, sec = self.dend[140]) h.pt3dadd(-600.5, -31, 60.5, 2.4, sec = self.dend[140]) h.pt3dadd(-604, -30, 60.5, 1.9, sec = self.dend[140]) h.pt3dadd(-605.5, -31, 60.5, 1.1, sec = self.dend[140]) h.pt3dadd(-606.5, -31, 60.5, 1.1, sec = self.dend[140]) h.pt3dadd(-608, -31, 60.5, 1.1, sec = self.dend[140]) h.pt3dadd(-608, -29.5, 62, 3.4, sec = self.dend[140]) h.pt3dadd(-610, -28.5, 62, 3.6, sec = self.dend[140]) h.pt3dadd(-613, -27.5, 62, 2, sec = self.dend[140]) h.pt3dadd(-616, -26, 62, 1.2, sec = self.dend[140]) h.pt3dadd(-618.5, -25, 62, 1.1, sec = self.dend[140]) h.pt3dadd(-620.5, -23.5, 62, 1.3, sec = self.dend[140]) h.pt3dadd(-622.5, -22.5, 69, 2, sec = self.dend[140]) h.pt3dadd(-625, -22, 66, 3.7, sec = self.dend[140]) h.pt3dadd(-626.5, -22, 66, 5.2, sec = self.dend[140]) h.pt3dadd(-629, -22, 72, 2.8, sec = self.dend[140]) h.pt3dadd(-634.5, -21.5, 64.5, 2.9, sec = self.dend[140]) h.pt3dadd(-638, -21.5, 72, 2.3, sec = self.dend[140]) h.pt3dadd(-639, -21, 72, 3.1, sec = self.dend[140]) h.pt3dadd(-642.5, -19, 70, 1.9, sec = self.dend[140]) h.pt3dadd(-644, -18.5, 70, 1.1, sec = self.dend[140]) h.pt3dadd(-645, -17.5, 70, 1.6, sec = self.dend[140]) h.pt3dadd(-646, -15, 72, 2.4, sec = self.dend[140]) h.pt3dadd(-648, -15, 72, 3.7, sec = self.dend[140]) h.pt3dadd(-650, -15, 72, 3.3, sec = self.dend[140]) h.pt3dadd(-652, -15, 72, 1.4, sec = self.dend[140]) h.pt3dadd(-654, -12, 72, 1.8, sec = self.dend[140]) h.pt3dadd(-655.5, -11.5, 72, 2.7, sec = self.dend[140]) h.pt3dadd(-658, -9.5, 72, 3.8, sec = self.dend[140]) h.pt3dadd(-660, -9.5, 72, 4.1, sec = self.dend[140]) h.pt3dadd(-663, -9, 73.5, 3.1, sec = self.dend[140]) h.pt3dadd(-665.5, -7.5, 73.5, 1.3, sec = self.dend[140]) h.pt3dadd(-669, -7.5, 73.5, 1.7, sec = self.dend[140]) h.pt3dadd(-670, -6.5, 73.5, 1.7, sec = self.dend[140]) h.pt3dadd(-671.5, -6.5, 75.5, 3.1, sec = self.dend[140]) h.pt3dadd(-674, -6.5, 77, 3.6, sec = self.dend[140]) h.pt3dadd(-676, -7, 77, 2.8, sec = self.dend[140]) h.pt3dadd(-678.5, -6.5, 77, 1.6, sec = self.dend[140]) h.pt3dadd(-681.5, -6.5, 79, 1.6, sec = self.dend[140]) h.pt3dadd(-683, -6.5, 79, 1.6, sec = self.dend[140]) h.pt3dadd(-685, -6.5, 80.5, 3.6, sec = self.dend[140]) h.pt3dadd(-689.5, -6, 79, 1.4, sec = self.dend[140]) h.pt3dadd(-691, -4.5, 79, 1.3, sec = self.dend[140]) h.pt3dadd(-693.5, -4.5, 79, 1.3, sec = self.dend[140]) h.pt3dadd(-695, -4, 79, 1.3, sec = self.dend[140]) h.pt3dadd(-699, -4, 84.5, 4.5, sec = self.dend[140]) h.pt3dadd(-701.5, -3, 79, 3.8, sec = self.dend[140]) h.pt3dadd(-703.5, -2, 80.5, 2.5, sec = self.dend[140]) h.pt3dadd(-707, 0, 80.5, 1.4, sec = self.dend[140]) h.pt3dadd(-710, 2, 80.5, 1.4, sec = self.dend[140]) h.pt3dadd(-713, 4.5, 80.5, 1.5, sec = self.dend[140]) h.pt3dadd(-713.5, 6.5, 82.5, 1.4, sec = self.dend[140]) h.pt3dadd(-716, 9, 82.5, 1.4, sec = self.dend[140]) h.pt3dadd(-718.5, 10.5, 82.5, 1.5, sec = self.dend[140]) h.pt3dadd(-719, 9, 84.5, 4.7, sec = self.dend[140]) h.pt3dadd(-719.5, 5, 86, 2.1, sec = self.dend[140]) h.pt3dadd(-722.5, 4, 84.5, 1.5, sec = self.dend[140]) h.pt3dadd(-723.5, 7, 84.5, 1.5, sec = self.dend[140]) h.pt3dadd(-726.5, 9.5, 84.5, 1.6, sec = self.dend[140]) h.pt3dadd(-727, 11, 84.5, 1.6, sec = self.dend[140]) h.pt3dadd(-729.5, 9, 84.5, 1.6, sec = self.dend[140]) h.pt3dadd(-731, 9.5, 90.5, 1.9, sec = self.dend[140]) h.pt3dadd(-733.5, 11, 89, 1.9, sec = self.dend[140]) h.pt3dadd(-735, 12.5, 90.5, 2.7, sec = self.dend[140]) h.pt3dadd(-736.5, 12, 90.5, 3.7, sec = self.dend[140]) h.pt3dadd(-738, 13, 90.5, 3.9, sec = self.dend[140]) h.pt3dadd(-741, 13.5, 90.5, 2.9, sec = self.dend[140]) h.pt3dadd(-742.5, 15, 90.5, 2.3, sec = self.dend[140]) h.pt3dadd(-745, 15, 90.5, 1.6, sec = self.dend[140]) h.pt3dadd(-747, 16.5, 92, 1.4, sec = self.dend[140]) h.pt3dadd(-749, 17.5, 92, 2.3, sec = self.dend[140]) h.pt3dadd(-752, 18.5, 93.5, 2.7, sec = self.dend[140]) h.pt3dadd(-754, 20, 92, 1.1, sec = self.dend[140]) h.pt3dadd(-755, 21.5, 95, 1.1, sec = self.dend[140]) h.pt3dadd(-756.5, 23, 95, 1.1, sec = self.dend[140]) h.pt3dadd(-759, 23.5, 96.5, 1.8, sec = self.dend[140]) h.pt3dadd(-762, 22.5, 96.5, 1.5, sec = self.dend[140]) h.pt3dadd(-765, 23, 96.5, 1.3, sec = self.dend[140]) h.pt3dadd(-766.5, 22.5, 98, 2.1, sec = self.dend[140]) h.pt3dadd(-769, 23, 98, 1.5, sec = self.dend[140]) h.pt3dadd(-772.5, 24, 101, 0.9, sec = self.dend[140]) h.pt3dadd(-773.5, 24.5, 101, 0.9, sec = self.dend[140]) h.pt3dadd(-775, 25.5, 101, 0.9, sec = self.dend[140]) h.pt3dadd(-776.5, 26, 101, 0.7, sec = self.dend[140]) h.pt3dadd(-777.5, 28, 101, 1.1, sec = self.dend[140]) h.pt3dadd(-777.5, 30.5, 101, 1.1, sec = self.dend[140]) h.pt3dadd(-779, 30.5, 101, 1.1, sec = self.dend[140]) h.pt3dadd(-780, 29.5, 101, 1.1, sec = self.dend[140]) h.pt3dadd(-781, 29.5, 101, 2.1, sec = self.dend[140]) h.pt3dadd(-784, 31.5, 101, 4.1, sec = self.dend[140]) h.pt3dadd(-786, 30.5, 101, 4.1, sec = self.dend[140]) h.pt3dadd(-789, 30.5, 101, 4.1, sec = self.dend[140]) h.pt3dadd(-793, 31, 107, 4.1, sec = self.dend[140]) h.pt3dadd(-796, 30, 105, 0.9, sec = self.dend[140]) h.pt3dadd(-799.5, 29.5, 107, 1.5, sec = self.dend[140]) h.pt3dadd(-801.5, 29, 107, 2.8, sec = self.dend[140]) h.pt3dadd(-803, 29, 107, 3.6, sec = self.dend[140]) h.pt3dadd(-806.5, 29, 107, 2.9, sec = self.dend[140]) h.pt3dadd(-809.5, 28.5, 107, 0.8, sec = self.dend[140]) h.pt3dadd(-811.5, 28.5, 107, 1, sec = self.dend[140]) h.pt3dadd(-814, 28.5, 109, 1.4, sec = self.dend[140]) h.pt3dadd(-815.5, 28.5, 111, 2.7, sec = self.dend[140]) h.pt3dadd(-819, 28.5, 111, 2.1, sec = self.dend[140]) h.pt3dadd(-820.5, 28.5, 111, 0.6, sec = self.dend[140]) h.pt3dadd(-823.5, 31, 113, 0.6, sec = self.dend[140]) h.pt3dadd(-825.5, 31, 115, 2.5, sec = self.dend[140]) h.pt3dadd(-826, 31, 115, 3.8, sec = self.dend[140]) h.pt3dclear(sec = self.dend[141]) h.pt3dadd(-826, 31, 115, 3.8, sec = self.dend[141]) h.pt3dadd(-831, 34, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-832, 34, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-834.5, 34.5, 119, 0.1, sec = self.dend[141]) h.pt3dadd(-839, 36, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-841, 35.5, 119, 0.8, sec = self.dend[141]) h.pt3dadd(-842.5, 36.5, 111, 1.3, sec = self.dend[141]) h.pt3dadd(-844, 36.5, 111, 0.6, sec = self.dend[141]) h.pt3dadd(-847, 36.5, 111, 0.2, sec = self.dend[141]) h.pt3dadd(-849.5, 36.5, 113, 0.2, sec = self.dend[141]) h.pt3dadd(-849, 36.5, 117, 1.2, sec = self.dend[141]) h.pt3dadd(-852, 37, 115, 0.3, sec = self.dend[141]) h.pt3dadd(-855, 37.5, 115, 0.3, sec = self.dend[141]) h.pt3dadd(-856, 37.5, 117, 2.1, sec = self.dend[141]) h.pt3dadd(-862, 37.5, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-863.5, 37.5, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-867, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-870.5, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-873.5, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-875.5, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-877.5, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-880.5, 39.5, 121, 0.5, sec = self.dend[141]) h.pt3dadd(-883.5, 39.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-886, 40, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-886, 41, 123, 0.6, sec = self.dend[141]) h.pt3dadd(-887.5, 41.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-888.5, 42, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-889, 43, 121, 1.7, sec = self.dend[141]) h.pt3dadd(-893.5, 43, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-894.5, 43.5, 121, 1.3, sec = self.dend[141]) h.pt3dadd(-898, 45, 121, 0.1, sec = self.dend[141]) h.pt3dadd(-900, 45, 121, 0.1, sec = self.dend[141]) h.pt3dadd(-902.5, 45, 133, 0.1, sec = self.dend[141]) h.pt3dadd(-904, 45, 111, 1.2, sec = self.dend[141]) h.pt3dadd(-906.5, 44, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-910, 44, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-912.5, 43, 111, 1.6, sec = self.dend[141]) h.pt3dadd(-915, 43, 107, 0.1, sec = self.dend[141]) h.pt3dadd(-917, 43, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-919, 44, 111, 1.1, sec = self.dend[141]) h.pt3dadd(-919.5, 44.5, 117, 0.1, sec = self.dend[141]) h.pt3dadd(-923, 46, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-927.5, 46, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-928.5, 49, 119, 1.7, sec = self.dend[141]) h.pt3dadd(-931.5, 47.5, 103, 0.1, sec = self.dend[141]) h.pt3dadd(-934, 47.5, 107, 0.1, sec = self.dend[141]) h.pt3dadd(-936, 49, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-937.5, 49, 113, 0.7, sec = self.dend[141]) h.pt3dadd(-941.5, 49, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-943.5, 49, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-945, 48, 113, 0.9, sec = self.dend[141]) h.pt3dadd(-947.5, 48, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-948.5, 48, 115, 1.6, sec = self.dend[141]) h.pt3dadd(-951, 48, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-952.5, 49, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-954, 49.5, 113, 0.9, sec = self.dend[141]) h.pt3dadd(-954.5, 49.5, 113, 1.1, sec = self.dend[141]) h.pt3dadd(-955, 49.5, 113, 1.1, sec = self.dend[141]) h.pt3dadd(-958.5, 49, 101, 0.1, sec = self.dend[141]) h.pt3dadd(-959.5, 48.5, 109, 1.1, sec = self.dend[141]) h.pt3dadd(-961.5, 48.5, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-962, 48.5, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-963, 49, 109, 0.7, sec = self.dend[141]) h.pt3dadd(-965, 49.5, 111, 0.9, sec = self.dend[141]) h.pt3dadd(-966, 48, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-967.5, 48, 111, 0.1, sec = self.dend[141]) h.pt3dadd(-969, 48, 117, 0.7, sec = self.dend[141]) h.pt3dadd(-971, 49, 107, 0.1, sec = self.dend[141]) h.pt3dadd(-973, 49.5, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-974, 50.5, 117, 1.3, sec = self.dend[141]) h.pt3dadd(-976, 51, 113, 0.1, sec = self.dend[141]) h.pt3dadd(-978, 52.5, 115, 0.1, sec = self.dend[141]) h.pt3dadd(-978.5, 53.5, 115, 0.9, sec = self.dend[141]) h.pt3dadd(-979.5, 54, 109, 0.1, sec = self.dend[141]) h.pt3dadd(-980.5, 60, 109, 0.1, sec = self.dend[141]) h.pt3dclear(sec = self.dend[142]) h.pt3dadd(-826, 31, 115, 3.8, sec = self.dend[142]) h.pt3dadd(-830, 29.5, 109, 0.6, sec = self.dend[142]) h.pt3dadd(-831.5, 29.5, 109, 0.6, sec = self.dend[142]) h.pt3dadd(-832.5, 28.5, 113, 2.8, sec = self.dend[142]) h.pt3dadd(-834.5, 28.5, 113, 4.6, sec = self.dend[142]) h.pt3dadd(-837, 27, 113, 2.1, sec = self.dend[142]) h.pt3dadd(-838.5, 26.5, 113, 0.9, sec = self.dend[142]) h.pt3dadd(-842, 25.5, 111, 1.1, sec = self.dend[142]) h.pt3dadd(-844, 23.5, 113, 1.1, sec = self.dend[142]) h.pt3dadd(-846, 23.5, 113, 1.8, sec = self.dend[142]) h.pt3dadd(-848, 22, 113, 3.1, sec = self.dend[142]) h.pt3dadd(-850, 22, 113, 2.1, sec = self.dend[142]) h.pt3dadd(-853, 19, 113, 1.5, sec = self.dend[142]) h.pt3dadd(-856, 17, 113, 1.3, sec = self.dend[142]) h.pt3dadd(-858.5, 16.5, 113, 1.5, sec = self.dend[142]) h.pt3dadd(-860, 14.5, 113, 2.5, sec = self.dend[142]) h.pt3dadd(-862.5, 13, 119, 1.8, sec = self.dend[142]) h.pt3dadd(-864, 11, 119, 1.1, sec = self.dend[142]) h.pt3dadd(-866.5, 10, 117, 1, sec = self.dend[142]) h.pt3dadd(-868.5, 8.5, 119, 2.7, sec = self.dend[142]) h.pt3dadd(-870, 8, 119, 2.7, sec = self.dend[142]) h.pt3dadd(-872, 5.5, 117, 2.2, sec = self.dend[142]) h.pt3dadd(-874, 5.5, 117, 1.6, sec = self.dend[142]) h.pt3dadd(-876, 5, 117, 0.9, sec = self.dend[142]) h.pt3dadd(-878, 3, 117, 0.9, sec = self.dend[142]) h.pt3dadd(-881, 1.5, 119, 2.4, sec = self.dend[142]) h.pt3dadd(-882.5, 0.5, 119, 2.4, sec = self.dend[142]) h.pt3dadd(-885, -1, 117, 1.6, sec = self.dend[142]) h.pt3dadd(-887.5, -1.5, 119, 1.7, sec = self.dend[142]) h.pt3dadd(-888, -4.5, 119, 2.5, sec = self.dend[142]) h.pt3dadd(-890.5, -6, 121, 2.5, sec = self.dend[142]) h.pt3dadd(-896, -6.5, 121, 1, sec = self.dend[142]) h.pt3dadd(-897.5, -7.5, 121, 1.4, sec = self.dend[142]) h.pt3dadd(-901, -9, 124, 1.1, sec = self.dend[142]) h.pt3dadd(-905, -10, 122.5, 1.1, sec = self.dend[142]) h.pt3dadd(-906.5, -12, 121, 1.1, sec = self.dend[142]) h.pt3dadd(-908.5, -15, 121, 1.4, sec = self.dend[142]) h.pt3dadd(-911, -15, 121, 1.2, sec = self.dend[142]) h.pt3dadd(-912.5, -16.5, 121, 0.7, sec = self.dend[142]) h.pt3dadd(-917.5, -15.5, 121, 0.5, sec = self.dend[142]) h.pt3dadd(-920, -14, 124, 0.5, sec = self.dend[142]) h.pt3dadd(-922.5, -15, 124, 2.9, sec = self.dend[142]) h.pt3dadd(-925, -15.5, 124, 3.1, sec = self.dend[142]) h.pt3dadd(-930, -16.5, 121, 1, sec = self.dend[142]) h.pt3dadd(-931, -18.5, 121, 0.3, sec = self.dend[142]) h.pt3dadd(-933, -18.5, 121, 0.3, sec = self.dend[142]) h.pt3dadd(-934, -21, 127.5, 3.4, sec = self.dend[142]) h.pt3dadd(-936, -21, 125, 3, sec = self.dend[142]) h.pt3dadd(-939, -23, 122.5, 1.3, sec = self.dend[142]) h.pt3dadd(-941, -24.5, 122.5, 1.6, sec = self.dend[142]) h.pt3dadd(-943, -25.5, 122.5, 2, sec = self.dend[142]) h.pt3dadd(-946, -25.5, 122.5, 2, sec = self.dend[142]) h.pt3dadd(-946.5, -28.5, 122.5, 2, sec = self.dend[142]) h.pt3dadd(-944, -26.5, 122.5, 1.3, sec = self.dend[142]) h.pt3dadd(-947, -24, 126.5, 1.3, sec = self.dend[142]) h.pt3dadd(-949, -24.5, 125, 1.6, sec = self.dend[142]) h.pt3dadd(-948.5, -27, 126.5, 3.4, sec = self.dend[142]) h.pt3dadd(-950.5, -30, 125, 1.8, sec = self.dend[142]) h.pt3dadd(-953.5, -30, 125, 1.7, sec = self.dend[142]) h.pt3dadd(-957, -29.5, 133, 1.2, sec = self.dend[142]) h.pt3dadd(-958, -30, 134.5, 2.4, sec = self.dend[142]) h.pt3dadd(-960, -30, 134.5, 2.8, sec = self.dend[142]) h.pt3dadd(-962, -30, 134.5, 1.3, sec = self.dend[142]) h.pt3dadd(-963.5, -33, 134.5, 1, sec = self.dend[142]) h.pt3dadd(-967, -35, 135.5, 1.2, sec = self.dend[142]) h.pt3dadd(-969.5, -36.5, 135.5, 1.2, sec = self.dend[142]) h.pt3dadd(-972, -36.5, 135.5, 0.4, sec = self.dend[142]) h.pt3dadd(-974.5, -39.5, 134.5, 0.4, sec = self.dend[142]) h.pt3dadd(-976, -39.5, 134.5, 2.6, sec = self.dend[142]) h.pt3dadd(-976, -39.5, 135.5, 3.3, sec = self.dend[142]) h.pt3dadd(-979.5, -39.5, 135.5, 1.4, sec = self.dend[142]) h.pt3dadd(-980.5, -39.5, 137, 0.7, sec = self.dend[142]) h.pt3dadd(-982.5, -40, 137, 0.7, sec = self.dend[142]) h.pt3dadd(-984, -39, 137, 0.7, sec = self.dend[142]) h.pt3dadd(-984.5, -41.5, 139.5, 0.7, sec = self.dend[142]) h.pt3dadd(-985, -42, 142, 0.6, sec = self.dend[142]) h.pt3dclear(sec = self.dend[143]) h.pt3dadd(-533.5, -55, 46, 8, sec = self.dend[143]) h.pt3dadd(-538.5, -59, 43.5, 1.7, sec = self.dend[143]) h.pt3dadd(-542, -60.5, 43.5, 2.1, sec = self.dend[143]) h.pt3dadd(-547, -61.5, 43.5, 1.9, sec = self.dend[143]) h.pt3dadd(-551, -62, 44.5, 3, sec = self.dend[143]) h.pt3dadd(-551.5, -62, 46, 3.7, sec = self.dend[143]) h.pt3dadd(-554, -63, 46, 4.7, sec = self.dend[143]) h.pt3dadd(-553.5, -63, 46, 4.7, sec = self.dend[143]) h.pt3dadd(-565.5, -69, 46, 6.5, sec = self.dend[143]) h.pt3dadd(-583.5, -71.5, 47.5, 5.3, sec = self.dend[143]) h.pt3dadd(-585, -71.5, 56, 3.3, sec = self.dend[143]) h.pt3dadd(-587, -71.5, 57.5, 4.7, sec = self.dend[143]) h.pt3dclear(sec = self.dend[144]) h.pt3dadd(-587, -71.5, 57.5, 4.7, sec = self.dend[144]) h.pt3dadd(-590.5, -69.5, 66, 2.8, sec = self.dend[144]) h.pt3dadd(-593.5, -66, 57.5, 1.9, sec = self.dend[144]) h.pt3dadd(-596, -65, 60.5, 3.6, sec = self.dend[144]) h.pt3dadd(-600, -64, 73.5, 2.8, sec = self.dend[144]) h.pt3dadd(-604, -64, 73.5, 2.8, sec = self.dend[144]) h.pt3dadd(-607, -61.5, 57.5, 2.8, sec = self.dend[144]) h.pt3dadd(-609.5, -62, 57.5, 4.6, sec = self.dend[144]) h.pt3dadd(-611.5, -62, 57.5, 2.9, sec = self.dend[144]) h.pt3dadd(-614, -62, 57.5, 0.7, sec = self.dend[144]) h.pt3dadd(-616, -62.5, 57.5, 1.3, sec = self.dend[144]) h.pt3dadd(-618, -62.5, 57.5, 1.9, sec = self.dend[144]) h.pt3dadd(-619.5, -61, 61.5, 2.5, sec = self.dend[144]) h.pt3dadd(-622.5, -61, 61.5, 4.6, sec = self.dend[144]) h.pt3dadd(-625.5, -61, 61.5, 2.4, sec = self.dend[144]) h.pt3dadd(-627, -61, 61.5, 1.6, sec = self.dend[144]) h.pt3dadd(-628, -61, 61.5, 1.2, sec = self.dend[144]) h.pt3dadd(-631, -61, 61.5, 1.2, sec = self.dend[144]) h.pt3dadd(-633.5, -61, 63, 2.7, sec = self.dend[144]) h.pt3dadd(-636.5, -61, 65, 4.6, sec = self.dend[144]) h.pt3dadd(-641, -61, 63, 1.5, sec = self.dend[144]) h.pt3dadd(-642, -61, 63, 1.3, sec = self.dend[144]) h.pt3dadd(-646, -62.5, 63, 1.4, sec = self.dend[144]) h.pt3dadd(-648, -62.5, 63, 1.5, sec = self.dend[144]) h.pt3dadd(-651, -62.5, 63, 1.6, sec = self.dend[144]) h.pt3dadd(-654.5, -64, 68.5, 1.7, sec = self.dend[144]) h.pt3dadd(-660, -65.5, 73, 2.4, sec = self.dend[144]) h.pt3dadd(-659.5, -66.5, 73, 1.6, sec = self.dend[144]) h.pt3dadd(-660.5, -68.5, 73, 1.6, sec = self.dend[144]) h.pt3dadd(-662.5, -69.5, 70, 1.6, sec = self.dend[144]) h.pt3dadd(-664.5, -69, 70, 2.3, sec = self.dend[144]) h.pt3dadd(-665.5, -68.5, 71.5, 3.7, sec = self.dend[144]) h.pt3dadd(-668.5, -67, 73, 4.9, sec = self.dend[144]) h.pt3dadd(-672, -67, 73, 3.4, sec = self.dend[144]) h.pt3dadd(-674, -68, 73, 1.7, sec = self.dend[144]) h.pt3dadd(-674, -68.5, 73, 0.7, sec = self.dend[144]) h.pt3dadd(-676, -69.5, 73, 0.7, sec = self.dend[144]) h.pt3dadd(-676, -68, 73, 1.1, sec = self.dend[144]) h.pt3dadd(-677, -67, 73, 1.4, sec = self.dend[144]) h.pt3dadd(-679.5, -68, 73, 2.1, sec = self.dend[144]) h.pt3dadd(-681.5, -68.5, 73, 2.2, sec = self.dend[144]) h.pt3dadd(-683, -69, 73, 2.5, sec = self.dend[144]) h.pt3dadd(-683, -70.5, 79, 3.4, sec = self.dend[144]) h.pt3dadd(-685, -72, 79, 4.6, sec = self.dend[144]) h.pt3dadd(-688, -72.5, 76, 2.8, sec = self.dend[144]) h.pt3dadd(-689.5, -72.5, 76, 1.7, sec = self.dend[144]) h.pt3dadd(-690, -72.5, 76, 0.9, sec = self.dend[144]) h.pt3dadd(-693, -73, 79, 0.9, sec = self.dend[144]) h.pt3dadd(-694.5, -72.5, 79, 2.2, sec = self.dend[144]) h.pt3dadd(-696.5, -73.5, 79, 3.4, sec = self.dend[144]) h.pt3dadd(-700, -74.5, 79, 2, sec = self.dend[144]) h.pt3dadd(-702, -74.5, 79, 1.3, sec = self.dend[144]) h.pt3dadd(-704.5, -74.5, 79, 1.3, sec = self.dend[144]) h.pt3dadd(-707.5, -77, 79, 1.3, sec = self.dend[144]) h.pt3dadd(-708.5, -77.5, 79, 1.7, sec = self.dend[144]) h.pt3dadd(-710, -79, 79, 2.9, sec = self.dend[144]) h.pt3dadd(-711, -80.5, 79, 3.1, sec = self.dend[144]) h.pt3dadd(-711, -81.5, 79, 3.4, sec = self.dend[144]) h.pt3dadd(-714, -82.5, 79, 2.4, sec = self.dend[144]) h.pt3dadd(-715, -83, 79, 1.7, sec = self.dend[144]) h.pt3dadd(-717, -85, 82, 1.2, sec = self.dend[144]) h.pt3dadd(-720.5, -86.5, 82, 1.6, sec = self.dend[144]) h.pt3dadd(-721.5, -88.5, 82, 1.9, sec = self.dend[144]) h.pt3dadd(-723.5, -88, 82, 3.6, sec = self.dend[144]) h.pt3dadd(-725.5, -88.5, 83.5, 4.4, sec = self.dend[144]) h.pt3dadd(-728.5, -88.5, 83.5, 4.8, sec = self.dend[144]) h.pt3dadd(-732, -92, 81.5, 2.5, sec = self.dend[144]) h.pt3dadd(-734.5, -92, 79.5, 1.3, sec = self.dend[144]) h.pt3dadd(-734, -94, 79.5, 3.2, sec = self.dend[144]) h.pt3dadd(-736, -94, 79.5, 4.1, sec = self.dend[144]) h.pt3dadd(-739.5, -95.5, 85.5, 1.3, sec = self.dend[144]) h.pt3dadd(-741, -95.5, 85.5, 1.3, sec = self.dend[144]) h.pt3dadd(-742.5, -97.5, 85.5, 2.9, sec = self.dend[144]) h.pt3dadd(-745, -97.5, 85.5, 3.5, sec = self.dend[144]) h.pt3dadd(-747, -97.5, 85.5, 1.5, sec = self.dend[144]) h.pt3dadd(-748, -97.5, 85.5, 0.9, sec = self.dend[144]) h.pt3dadd(-751, -97.5, 89.5, 0.6, sec = self.dend[144]) h.pt3dadd(-751, -99, 87.5, 0.7, sec = self.dend[144]) h.pt3dadd(-755.5, -100.5, 87.5, 0.8, sec = self.dend[144]) h.pt3dadd(-756, -101, 87.5, 2.6, sec = self.dend[144]) h.pt3dadd(-756.5, -102.5, 89.5, 3.4, sec = self.dend[144]) h.pt3dadd(-758.5, -102.5, 89.5, 1.4, sec = self.dend[144]) h.pt3dadd(-761.5, -102.5, 89.5, 1, sec = self.dend[144]) h.pt3dadd(-763.5, -103, 89.5, 1, sec = self.dend[144]) h.pt3dadd(-765, -103, 89.5, 2.9, sec = self.dend[144]) h.pt3dadd(-767.5, -103, 89.5, 4, sec = self.dend[144]) h.pt3dadd(-769.5, -106, 89.5, 2.8, sec = self.dend[144]) h.pt3dadd(-771, -108, 89.5, 2.2, sec = self.dend[144]) h.pt3dadd(-774.5, -112.5, 97.5, 1.3, sec = self.dend[144]) h.pt3dadd(-775, -114.5, 97.5, 0.9, sec = self.dend[144]) h.pt3dadd(-776, -117, 97.5, 0.9, sec = self.dend[144]) h.pt3dadd(-778.5, -118, 99.5, 1.4, sec = self.dend[144]) h.pt3dadd(-781, -119.5, 99.5, 1.4, sec = self.dend[144]) h.pt3dadd(-782.5, -122, 99.5, 1.4, sec = self.dend[144]) h.pt3dadd(-782.5, -123, 101.5, 3.2, sec = self.dend[144]) h.pt3dadd(-786.5, -125.5, 99.5, 2.7, sec = self.dend[144]) h.pt3dadd(-790.5, -128, 99.5, 0.8, sec = self.dend[144]) h.pt3dadd(-792, -131, 99.5, 2.8, sec = self.dend[144]) h.pt3dadd(-794, -133.5, 99.5, 2.4, sec = self.dend[144]) h.pt3dadd(-796, -133.5, 99.5, 1.6, sec = self.dend[144]) h.pt3dadd(-797.5, -134.5, 99.5, 1, sec = self.dend[144]) h.pt3dadd(-799.5, -134.5, 97.5, 1, sec = self.dend[144]) h.pt3dadd(-803, -138, 99.5, 1, sec = self.dend[144]) h.pt3dadd(-804.5, -138, 101.5, 1.4, sec = self.dend[144]) h.pt3dadd(-808, -138, 103.5, 1.6, sec = self.dend[144]) h.pt3dadd(-810.5, -139.5, 101.5, 1.1, sec = self.dend[144]) h.pt3dadd(-810.5, -142, 101.5, 1.6, sec = self.dend[144]) h.pt3dadd(-813.5, -145.5, 101.5, 1.6, sec = self.dend[144]) h.pt3dadd(-816, -150.5, 103.5, 1.3, sec = self.dend[144]) h.pt3dadd(-818.5, -153.5, 106, 0.6, sec = self.dend[144]) h.pt3dadd(-819, -156.5, 106, 1.1, sec = self.dend[144]) h.pt3dadd(-820.5, -157, 106, 1.3, sec = self.dend[144]) h.pt3dadd(-820.5, -159, 106, 1.3, sec = self.dend[144]) h.pt3dadd(-820.5, -161, 106, 1.9, sec = self.dend[144]) h.pt3dadd(-820.5, -163.5, 107.5, 2.5, sec = self.dend[144]) h.pt3dadd(-821.5, -165, 107.5, 1.1, sec = self.dend[144]) h.pt3dadd(-822.5, -166.5, 107.5, 0.5, sec = self.dend[144]) h.pt3dadd(-822.5, -168.5, 107.5, 0.5, sec = self.dend[144]) h.pt3dadd(-821.5, -171, 108.5, 2.7, sec = self.dend[144]) h.pt3dadd(-821, -172.5, 110, 4.1, sec = self.dend[144]) h.pt3dadd(-821.5, -175.5, 110, 1.6, sec = self.dend[144]) h.pt3dadd(-822, -179, 110, 1, sec = self.dend[144]) h.pt3dadd(-823.5, -179, 110, 1, sec = self.dend[144]) h.pt3dadd(-827.5, -179.5, 110, 1.2, sec = self.dend[144]) h.pt3dadd(-830, -183, 110, 1.7, sec = self.dend[144]) h.pt3dadd(-832.5, -184.5, 110, 1.1, sec = self.dend[144]) h.pt3dadd(-834.5, -186.5, 108.5, 0.4, sec = self.dend[144]) h.pt3dadd(-835, -186.5, 108.5, 0.4, sec = self.dend[144]) h.pt3dadd(-836.5, -186.5, 108.5, 2, sec = self.dend[144]) h.pt3dadd(-838, -186.5, 108.5, 2.5, sec = self.dend[144]) h.pt3dadd(-839, -186.5, 108.5, 1.2, sec = self.dend[144]) h.pt3dadd(-841, -186.5, 108.5, 0.4, sec = self.dend[144]) h.pt3dadd(-845, -186, 108.5, 0.5, sec = self.dend[144]) h.pt3dadd(-848, -185.5, 110, 1.5, sec = self.dend[144]) h.pt3dadd(-848.5, -182.5, 110, 1.8, sec = self.dend[144]) h.pt3dadd(-850, -181.5, 110, 1.8, sec = self.dend[144]) h.pt3dadd(-847, -181.5, 110, 1.8, sec = self.dend[144]) h.pt3dadd(-847, -181.5, 115, 2, sec = self.dend[144]) h.pt3dadd(-847, -186, 114, 1.9, sec = self.dend[144]) h.pt3dadd(-849, -186, 115, 1.2, sec = self.dend[144]) h.pt3dadd(-851, -187, 116.5, 1.4, sec = self.dend[144]) h.pt3dadd(-853, -188.5, 116.5, 1.4, sec = self.dend[144]) h.pt3dadd(-854.5, -188.5, 118, 1.9, sec = self.dend[144]) h.pt3dadd(-856, -192, 119, 1.2, sec = self.dend[144]) h.pt3dadd(-857, -192.5, 119, 0.9, sec = self.dend[144]) h.pt3dadd(-860, -195.5, 119, 0.9, sec = self.dend[144]) h.pt3dadd(-862.5, -196.5, 124.5, 0.9, sec = self.dend[144]) h.pt3dadd(-864, -200.5, 127, 1.2, sec = self.dend[144]) h.pt3dclear(sec = self.dend[145]) h.pt3dadd(-587, -71.5, 57.5, 4.7, sec = self.dend[145]) h.pt3dadd(-590.5, -71.5, 60.5, 0.1, sec = self.dend[145]) h.pt3dadd(-591.5, -72, 63.5, 2.8, sec = self.dend[145]) h.pt3dadd(-595, -72, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-596, -73.5, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-597, -74, 63.5, 2.1, sec = self.dend[145]) h.pt3dadd(-598, -74, 63.5, 3.4, sec = self.dend[145]) h.pt3dadd(-599, -76, 63.5, 1.6, sec = self.dend[145]) h.pt3dadd(-601, -76, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-604.5, -76, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-609, -76.5, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-609.5, -76.5, 63.5, 3.2, sec = self.dend[145]) h.pt3dadd(-612.5, -76.5, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-616, -75.5, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-618, -74.5, 62, 0.1, sec = self.dend[145]) h.pt3dadd(-621, -72, 62, 0.7, sec = self.dend[145]) h.pt3dadd(-624.5, -72, 63.5, 3.2, sec = self.dend[145]) h.pt3dadd(-627.5, -72, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-629.5, -72, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-631.5, -72, 63.5, 2.3, sec = self.dend[145]) h.pt3dadd(-632.5, -72, 63.5, 2.1, sec = self.dend[145]) h.pt3dadd(-634.5, -71, 63.5, 1.3, sec = self.dend[145]) h.pt3dadd(-635.5, -71, 63.5, 0.2, sec = self.dend[145]) h.pt3dadd(-637.5, -71, 63.5, 0.1, sec = self.dend[145]) h.pt3dadd(-639.5, -72, 63.5, 0.7, sec = self.dend[145]) h.pt3dadd(-640, -72, 63.5, 1.2, sec = self.dend[145]) h.pt3dadd(-641.5, -72, 62, 0.3, sec = self.dend[145]) h.pt3dadd(-643, -70.5, 72, 0.2, sec = self.dend[145]) h.pt3dclear(sec = self.dend[146]) h.pt3dadd(-16, -1.5, -3, 8.5, sec = self.dend[146]) h.pt3dadd(-23.5, -3.5, -2, 8.5, sec = self.dend[146]) h.pt3dadd(-26.5, -8.5, -2, 9.7, sec = self.dend[146]) h.pt3dadd(-32.5, -8.5, -2, 9.7, sec = self.dend[146]) h.pt3dadd(-36.5, -8.5, -3, 8.8, sec = self.dend[146]) h.pt3dadd(-40.5, -11.5, -3, 8.8, sec = self.dend[146]) h.pt3dadd(-46, -15, -2, 9.5, sec = self.dend[146]) h.pt3dadd(-51.5, -17, -2, 8.9, sec = self.dend[146]) h.pt3dadd(-56, -20, -2, 8.5, sec = self.dend[146]) h.pt3dadd(-61, -20.5, -2, 9, sec = self.dend[146]) h.pt3dadd(-64.5, -22, -2, 8.5, sec = self.dend[146]) h.pt3dadd(-69, -23.5, -2, 7.5, sec = self.dend[146]) h.pt3dadd(-74, -24, -2, 8.5, sec = self.dend[146]) h.pt3dadd(-78.5, -24.5, -1, 9.5, sec = self.dend[146]) h.pt3dadd(-82, -26.5, -1, 9.7, sec = self.dend[146]) h.pt3dadd(-85.5, -27, -1, 8.3, sec = self.dend[146]) h.pt3dadd(-90, -27.5, -5, 7.3, sec = self.dend[146]) h.pt3dadd(-92.5, -29.5, -2, 6.3, sec = self.dend[146]) h.pt3dadd(-97.5, -30, -3, 7.4, sec = self.dend[146]) h.pt3dadd(-101, -31.5, -5.5, 7.2, sec = self.dend[146]) h.pt3dadd(-108, -33, -8.5, 8, sec = self.dend[146]) h.pt3dadd(-112, -36.5, -8.5, 7.3, sec = self.dend[146]) h.pt3dadd(-116.5, -38.5, -7.5, 6, sec = self.dend[146]) h.pt3dadd(-120.5, -41, -8.5, 6.6, sec = self.dend[146]) h.pt3dadd(-124.5, -45, -8.5, 8.8, sec = self.dend[146]) h.pt3dclear(sec = self.dend[147]) h.pt3dadd(-124.5, -45, -8.5, 8.8, sec = self.dend[147]) h.pt3dadd(-124.5, -48.5, -11, 3, sec = self.dend[147]) h.pt3dadd(-126, -54, -11, 3.7, sec = self.dend[147]) h.pt3dadd(-128, -58.5, -14, 3.8, sec = self.dend[147]) h.pt3dadd(-127.5, -61.5, -14, 4.3, sec = self.dend[147]) h.pt3dadd(-129, -64, -14, 3.1, sec = self.dend[147]) h.pt3dadd(-130, -65.5, -16.5, 3.4, sec = self.dend[147]) h.pt3dadd(-132.5, -66.5, -15.5, 4.2, sec = self.dend[147]) h.pt3dadd(-134, -69.5, -15.5, 4.7, sec = self.dend[147]) h.pt3dadd(-137, -70, -15.5, 4.1, sec = self.dend[147]) h.pt3dadd(-139, -73, -15.5, 4.6, sec = self.dend[147]) h.pt3dadd(-141, -75, -16.5, 4.9, sec = self.dend[147]) h.pt3dadd(-145, -78, -16.5, 4.4, sec = self.dend[147]) h.pt3dadd(-147.5, -79.5, -16.5, 5.2, sec = self.dend[147]) h.pt3dadd(-150.5, -82, -19, 5.6, sec = self.dend[147]) h.pt3dadd(-154, -83.5, -19, 5.9, sec = self.dend[147]) h.pt3dadd(-157.5, -85, -17.5, 5.7, sec = self.dend[147]) h.pt3dadd(-164, -89.5, -15.5, 4.5, sec = self.dend[147]) h.pt3dadd(-170, -93.5, -15.5, 4.5, sec = self.dend[147]) h.pt3dadd(-176, -95, -15.5, 5.3, sec = self.dend[147]) h.pt3dadd(-182, -99.5, -15.5, 4.5, sec = self.dend[147]) h.pt3dadd(-184.5, -102, -16, 3.6, sec = self.dend[147]) h.pt3dadd(-188, -102.5, -15.5, 3.1, sec = self.dend[147]) h.pt3dadd(-191, -105, -16.5, 3.5, sec = self.dend[147]) h.pt3dadd(-195, -106.5, -16, 3.8, sec = self.dend[147]) h.pt3dadd(-200, -109.5, -16, 4.3, sec = self.dend[147]) h.pt3dadd(-203, -112, -17.5, 4.6, sec = self.dend[147]) h.pt3dadd(-207, -114, -16.5, 4.9, sec = self.dend[147]) h.pt3dadd(-210, -117.5, -17.5, 4.9, sec = self.dend[147]) h.pt3dadd(-213.5, -120.5, -17.5, 5.6, sec = self.dend[147]) h.pt3dadd(-215.5, -121.5, -16.5, 5.3, sec = self.dend[147]) h.pt3dadd(-217.5, -123, -18.5, 5.4, sec = self.dend[147]) h.pt3dadd(-220, -127, -18, 5.4, sec = self.dend[147]) h.pt3dadd(-222, -130.5, -18, 5.4, sec = self.dend[147]) h.pt3dadd(-225, -134, -18, 4.6, sec = self.dend[147]) h.pt3dadd(-228, -136.5, -17.5, 4.3, sec = self.dend[147]) h.pt3dadd(-229.5, -138.5, -18.5, 4.5, sec = self.dend[147]) h.pt3dadd(-230.5, -143.5, -18, 5, sec = self.dend[147]) h.pt3dadd(-232.5, -146, -18.5, 4.6, sec = self.dend[147]) h.pt3dadd(-234.5, -148.5, -18.5, 4.4, sec = self.dend[147]) h.pt3dadd(-234.5, -150.5, -18.5, 4.4, sec = self.dend[147]) h.pt3dadd(-234.5, -153.5, -19.5, 4.4, sec = self.dend[147]) h.pt3dadd(-236.5, -156, -18.5, 4, sec = self.dend[147]) h.pt3dadd(-237, -158, -20, 3.5, sec = self.dend[147]) h.pt3dadd(-239, -159.5, -20, 3.5, sec = self.dend[147]) h.pt3dadd(-239, -161.5, -18.5, 4.9, sec = self.dend[147]) h.pt3dadd(-239.5, -163, -20, 3.8, sec = self.dend[147]) h.pt3dadd(-240, -165.5, -20, 4.1, sec = self.dend[147]) h.pt3dadd(-240.5, -169, -20, 4.6, sec = self.dend[147]) h.pt3dadd(-240.5, -171, -20, 4.3, sec = self.dend[147]) h.pt3dadd(-240.5, -172.5, -20, 4.3, sec = self.dend[147]) h.pt3dadd(-240.5, -178, -21.5, 3.4, sec = self.dend[147]) h.pt3dadd(-242, -179.5, -21.5, 3.3, sec = self.dend[147]) h.pt3dadd(-242, -181.5, -21.5, 4, sec = self.dend[147]) h.pt3dadd(-245.5, -185, -20.5, 4.6, sec = self.dend[147]) h.pt3dadd(-248, -189.5, -23, 5.2, sec = self.dend[147]) h.pt3dadd(-250.5, -193, -23, 5.5, sec = self.dend[147]) h.pt3dadd(-252.5, -194, -16.5, 4.5, sec = self.dend[147]) h.pt3dadd(-254.5, -195, -23, 3.8, sec = self.dend[147]) h.pt3dadd(-257, -198.5, -23, 3.8, sec = self.dend[147]) h.pt3dadd(-258, -199.5, -23, 4.3, sec = self.dend[147]) h.pt3dadd(-259, -200.5, -23, 4.7, sec = self.dend[147]) h.pt3dadd(-260.5, -201.5, -23, 4.7, sec = self.dend[147]) h.pt3dadd(-261.5, -204.5, -23, 4.8, sec = self.dend[147]) h.pt3dadd(-262.5, -206.5, -23, 4.3, sec = self.dend[147]) h.pt3dadd(-264.5, -210, -29, 5.3, sec = self.dend[147]) h.pt3dadd(-266.5, -211.5, -29, 4.9, sec = self.dend[147]) h.pt3dadd(-268, -213.5, -29, 4.7, sec = self.dend[147]) h.pt3dadd(-270, -214.5, -29, 5.1, sec = self.dend[147]) h.pt3dadd(-270.5, -217, -29, 5.7, sec = self.dend[147]) h.pt3dadd(-271.5, -220, -29, 5.7, sec = self.dend[147]) h.pt3dadd(-273.5, -222, -29, 6.3, sec = self.dend[147]) h.pt3dclear(sec = self.dend[148]) h.pt3dadd(-273.5, -222, -29, 6.3, sec = self.dend[148]) h.pt3dadd(-276.5, -226, -35.5, 2.3, sec = self.dend[148]) h.pt3dadd(-278.5, -225, -41.5, 2.3, sec = self.dend[148]) h.pt3dadd(-279.5, -223.5, -41.5, 1.8, sec = self.dend[148]) h.pt3dadd(-281, -223.5, -41.5, 1.2, sec = self.dend[148]) h.pt3dadd(-282, -224, -41.5, 1.1, sec = self.dend[148]) h.pt3dadd(-282, -226, -41.5, 2.2, sec = self.dend[148]) h.pt3dadd(-282.5, -228, -41.5, 2.9, sec = self.dend[148]) h.pt3dadd(-283.5, -229.5, -41.5, 3.1, sec = self.dend[148]) h.pt3dadd(-284.5, -230.5, -48, 4.1, sec = self.dend[148]) h.pt3dadd(-286, -231, -48, 4.1, sec = self.dend[148]) h.pt3dadd(-287.5, -232, -48, 3.7, sec = self.dend[148]) h.pt3dadd(-290, -233.5, -48, 3.1, sec = self.dend[148]) h.pt3dadd(-290, -239.5, -51.5, 2.4, sec = self.dend[148]) h.pt3dadd(-290, -240.5, -49.5, 1.8, sec = self.dend[148]) h.pt3dadd(-290.5, -242.5, -49.5, 1.8, sec = self.dend[148]) h.pt3dadd(-292.5, -242.5, -49.5, 2.5, sec = self.dend[148]) h.pt3dadd(-294.5, -242.5, -49.5, 2.5, sec = self.dend[148]) h.pt3dadd(-294.5, -244.5, -51.5, 2.7, sec = self.dend[148]) h.pt3dadd(-294.5, -246, -51.5, 2.7, sec = self.dend[148]) h.pt3dadd(-295, -246.5, -53.5, 2, sec = self.dend[148]) h.pt3dadd(-295, -247.5, -53.5, 1.8, sec = self.dend[148]) h.pt3dadd(-298, -247.5, -53.5, 1.8, sec = self.dend[148]) h.pt3dadd(-299.5, -249.5, -57.5, 2.4, sec = self.dend[148]) h.pt3dadd(-302.5, -250, -55.5, 3.3, sec = self.dend[148]) h.pt3dadd(-305, -254.5, -57.5, 2.7, sec = self.dend[148]) h.pt3dadd(-306.5, -254.5, -55.5, 3.3, sec = self.dend[148]) h.pt3dadd(-309, -254.5, -55.5, 1.7, sec = self.dend[148]) h.pt3dadd(-314, -256.5, -61, 1.1, sec = self.dend[148]) h.pt3dadd(-316, -256.5, -61, 3.3, sec = self.dend[148]) h.pt3dadd(-319.5, -258.5, -55, 3.6, sec = self.dend[148]) h.pt3dadd(-322, -258.5, -55, 2, sec = self.dend[148]) h.pt3dadd(-324, -259.5, -58, 2.3, sec = self.dend[148]) h.pt3dadd(-325, -261, -61, 2.4, sec = self.dend[148]) h.pt3dadd(-324, -264.5, -61, 2.8, sec = self.dend[148]) h.pt3dadd(-325, -265.5, -61, 3.6, sec = self.dend[148]) h.pt3dclear(sec = self.dend[149]) h.pt3dadd(-325, -265.5, -61, 3.6, sec = self.dend[149]) h.pt3dadd(-328.5, -266, -64, 0.1, sec = self.dend[149]) h.pt3dadd(-331, -266, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-332, -266, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-333.5, -266, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-334, -266, -58, 1.6, sec = self.dend[149]) h.pt3dadd(-336.5, -266, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-339, -264, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-340, -264, -58, 1.1, sec = self.dend[149]) h.pt3dadd(-342.5, -264, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-344, -264, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-345.5, -264, -58, 0.9, sec = self.dend[149]) h.pt3dadd(-347, -263.5, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-348, -263.5, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-349.5, -263.5, -64, 0.4, sec = self.dend[149]) h.pt3dadd(-351.5, -263.5, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-354, -264, -61, 0.1, sec = self.dend[149]) h.pt3dadd(-354.5, -263, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-357, -263, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-359.5, -262.5, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-359.5, -262, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-362, -261.5, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-363.5, -260, -58, 1.1, sec = self.dend[149]) h.pt3dadd(-366, -260, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-369, -260, -58, 0.1, sec = self.dend[149]) h.pt3dadd(-371, -260, -55, 2, sec = self.dend[149]) h.pt3dadd(-373.5, -260, -55, 1.7, sec = self.dend[149]) h.pt3dclear(sec = self.dend[150]) h.pt3dadd(-325, -265.5, -61, 3.6, sec = self.dend[150]) h.pt3dadd(-325, -269, -64, 3.2, sec = self.dend[150]) h.pt3dadd(-326, -270, -67, 2.5, sec = self.dend[150]) h.pt3dadd(-327, -272.5, -67, 2.7, sec = self.dend[150]) h.pt3dadd(-328, -273.5, -70, 3.3, sec = self.dend[150]) h.pt3dadd(-330.5, -273.5, -67, 4, sec = self.dend[150]) h.pt3dadd(-332, -273.5, -73, 4.1, sec = self.dend[150]) h.pt3dadd(-335, -274.5, -73, 3.2, sec = self.dend[150]) h.pt3dadd(-338, -276, -75.5, 2.5, sec = self.dend[150]) h.pt3dadd(-340, -276, -75.5, 2.3, sec = self.dend[150]) h.pt3dadd(-342.5, -277.5, -78.5, 1.9, sec = self.dend[150]) h.pt3dadd(-346, -278.5, -78.5, 1.8, sec = self.dend[150]) h.pt3dadd(-349.5, -280, -76, 2, sec = self.dend[150]) h.pt3dadd(-350.5, -283, -78.5, 4.5, sec = self.dend[150]) h.pt3dadd(-353, -283.5, -76, 3.9, sec = self.dend[150]) h.pt3dadd(-354.5, -286, -80.5, 2.4, sec = self.dend[150]) h.pt3dadd(-355.5, -290, -85.5, 2.7, sec = self.dend[150]) h.pt3dadd(-356.5, -293, -85.5, 2.6, sec = self.dend[150]) h.pt3dadd(-356.5, -294, -85.5, 2.8, sec = self.dend[150]) h.pt3dadd(-359.5, -294.5, -85.5, 2, sec = self.dend[150]) h.pt3dadd(-361, -294.5, -85.5, 2.5, sec = self.dend[150]) h.pt3dadd(-363, -294.5, -90, 2.8, sec = self.dend[150]) h.pt3dadd(-364.5, -294.5, -85.5, 3.3, sec = self.dend[150]) h.pt3dadd(-368.5, -296, -92.5, 2.7, sec = self.dend[150]) h.pt3dadd(-367, -296, -90, 2.7, sec = self.dend[150]) h.pt3dadd(-367, -292.5, -88, 2.2, sec = self.dend[150]) h.pt3dadd(-365, -294.5, -95, 2.6, sec = self.dend[150]) h.pt3dadd(-366, -300, -95, 1.6, sec = self.dend[150]) h.pt3dadd(-368, -300, -99.5, 1.6, sec = self.dend[150]) h.pt3dadd(-370, -301, -97.5, 1.5, sec = self.dend[150]) h.pt3dclear(sec = self.dend[151]) h.pt3dadd(-273.5, -222, -29, 6.3, sec = self.dend[151]) h.pt3dadd(-276, -226, -35.5, 5.2, sec = self.dend[151]) h.pt3dadd(-277.5, -227.5, -29, 3.3, sec = self.dend[151]) h.pt3dadd(-279, -229.5, -35.5, 2.5, sec = self.dend[151]) h.pt3dadd(-280, -230.5, -35.5, 2.4, sec = self.dend[151]) h.pt3dadd(-281, -233, -35.5, 2.4, sec = self.dend[151]) h.pt3dadd(-281, -234, -35.5, 2, sec = self.dend[151]) h.pt3dadd(-282, -236.5, -35.5, 2.5, sec = self.dend[151]) h.pt3dadd(-282.5, -239.5, -35.5, 2.3, sec = self.dend[151]) h.pt3dadd(-284, -241.5, -35.5, 2.4, sec = self.dend[151]) h.pt3dadd(-285, -244, -35.5, 2.8, sec = self.dend[151]) h.pt3dadd(-286.5, -247, -35.5, 4, sec = self.dend[151]) h.pt3dadd(-289.5, -250.5, -35.5, 5.5, sec = self.dend[151]) h.pt3dadd(-291, -252.5, -41.5, 5, sec = self.dend[151]) h.pt3dadd(-291, -254.5, -41.5, 4.5, sec = self.dend[151]) h.pt3dadd(-292.5, -256.5, -41.5, 3.1, sec = self.dend[151]) h.pt3dadd(-295.5, -257, -41.5, 2, sec = self.dend[151]) h.pt3dadd(-297, -259, -41.5, 2, sec = self.dend[151]) h.pt3dadd(-299, -260.5, -41.5, 2.3, sec = self.dend[151]) h.pt3dadd(-300.5, -262.5, -48, 1.9, sec = self.dend[151]) h.pt3dadd(-305, -265, -54, 2, sec = self.dend[151]) h.pt3dadd(-307, -268.5, -54, 3.8, sec = self.dend[151]) h.pt3dadd(-309.5, -270.5, -54, 3.8, sec = self.dend[151]) h.pt3dadd(-310.5, -271, -52, 3.1, sec = self.dend[151]) h.pt3dadd(-312, -272, -54, 2.5, sec = self.dend[151]) h.pt3dadd(-312.5, -274, -54, 2.1, sec = self.dend[151]) h.pt3dadd(-315, -273, -54, 1.4, sec = self.dend[151]) h.pt3dadd(-317, -273.5, -54, 1.2, sec = self.dend[151]) h.pt3dadd(-318, -275, -52, 1.4, sec = self.dend[151]) h.pt3dadd(-319, -277, -52, 2.6, sec = self.dend[151]) h.pt3dadd(-320.5, -279, -52, 3, sec = self.dend[151]) h.pt3dadd(-322, -280, -56, 3.4, sec = self.dend[151]) h.pt3dadd(-325.5, -280.5, -56, 2.9, sec = self.dend[151]) h.pt3dadd(-327.5, -281, -56, 2.3, sec = self.dend[151]) h.pt3dadd(-330, -282, -56, 2.3, sec = self.dend[151]) h.pt3dadd(-331.5, -283.5, -56, 3.6, sec = self.dend[151]) h.pt3dadd(-333.5, -287, -56, 4.8, sec = self.dend[151]) h.pt3dadd(-334.5, -289, -56, 4.6, sec = self.dend[151]) h.pt3dadd(-337, -289.5, -61.5, 3.8, sec = self.dend[151]) h.pt3dadd(-340, -290, -63.5, 2.9, sec = self.dend[151]) h.pt3dadd(-342, -292, -63.5, 2.3, sec = self.dend[151]) h.pt3dadd(-346.5, -295.5, -65.5, 2.3, sec = self.dend[151]) h.pt3dadd(-350, -297, -65.5, 2.8, sec = self.dend[151]) h.pt3dadd(-353, -298, -63.5, 2.8, sec = self.dend[151]) h.pt3dadd(-355.5, -299, -65.5, 2.4, sec = self.dend[151]) h.pt3dadd(-357, -300, -65.5, 3.4, sec = self.dend[151]) h.pt3dadd(-358.5, -301.5, -61.5, 4.7, sec = self.dend[151]) h.pt3dadd(-360.5, -301.5, -61.5, 5.3, sec = self.dend[151]) h.pt3dadd(-363, -302.5, -61.5, 3.5, sec = self.dend[151]) h.pt3dadd(-364, -303.5, -61.5, 2.1, sec = self.dend[151]) h.pt3dadd(-366, -304, -61.5, 1.4, sec = self.dend[151]) h.pt3dadd(-367.5, -305.5, -61.5, 1.4, sec = self.dend[151]) h.pt3dadd(-369, -308, -61.5, 3.1, sec = self.dend[151]) h.pt3dadd(-371, -309.5, -61.5, 2.5, sec = self.dend[151]) h.pt3dadd(-371.5, -311, -63.5, 3.9, sec = self.dend[151]) h.pt3dadd(-372.5, -312.5, -63.5, 2.9, sec = self.dend[151]) h.pt3dadd(-374, -314.5, -63.5, 2.2, sec = self.dend[151]) h.pt3dadd(-376, -316, -63.5, 1.8, sec = self.dend[151]) h.pt3dadd(-376, -317.5, -63.5, 1.7, sec = self.dend[151]) h.pt3dadd(-377, -320.5, -63.5, 1.9, sec = self.dend[151]) h.pt3dadd(-378.5, -320.5, -63.5, 2.4, sec = self.dend[151]) h.pt3dadd(-380, -323.5, -63.5, 3.3, sec = self.dend[151]) h.pt3dadd(-383, -326, -63.5, 4, sec = self.dend[151]) h.pt3dadd(-386, -328.5, -61.5, 3.7, sec = self.dend[151]) h.pt3dadd(-387.5, -331, -61.5, 3.3, sec = self.dend[151]) h.pt3dadd(-389, -334, -63.5, 4, sec = self.dend[151]) h.pt3dadd(-389.5, -337.5, -63.5, 3.2, sec = self.dend[151]) h.pt3dadd(-390, -339, -61.5, 2.5, sec = self.dend[151]) h.pt3dadd(-392, -339, -63.5, 1.9, sec = self.dend[151]) h.pt3dadd(-394, -341, -63.5, 1.5, sec = self.dend[151]) h.pt3dadd(-400, -345, -67.5, 1.4, sec = self.dend[151]) h.pt3dadd(-400.5, -346, -67.5, 2.1, sec = self.dend[151]) h.pt3dadd(-403, -349, -67.5, 3.5, sec = self.dend[151]) h.pt3dadd(-405.5, -350, -67.5, 2.5, sec = self.dend[151]) h.pt3dadd(-406.5, -353, -67.5, 0.8, sec = self.dend[151]) h.pt3dadd(-408.5, -353.5, -67.5, 0.9, sec = self.dend[151]) h.pt3dadd(-411.5, -357.5, -67.5, 0.9, sec = self.dend[151]) h.pt3dadd(-412, -358.5, -70.5, 1.7, sec = self.dend[151]) h.pt3dadd(-414, -360.5, -67.5, 2.2, sec = self.dend[151]) h.pt3dadd(-416, -362.5, -67.5, 2.7, sec = self.dend[151]) h.pt3dadd(-418, -365, -67.5, 3.4, sec = self.dend[151]) h.pt3dadd(-419.5, -368.5, -73.5, 3.7, sec = self.dend[151]) h.pt3dclear(sec = self.dend[152]) h.pt3dadd(-419.5, -368.5, -73.5, 3.7, sec = self.dend[152]) h.pt3dadd(-422.5, -372.5, -67.5, 0.1, sec = self.dend[152]) h.pt3dadd(-424.5, -374, -67.5, 0.1, sec = self.dend[152]) h.pt3dadd(-425, -376, -70.5, 0.1, sec = self.dend[152]) h.pt3dadd(-425, -378.5, -70.5, 1.1, sec = self.dend[152]) h.pt3dadd(-424.5, -380.5, -70.5, 2.4, sec = self.dend[152]) h.pt3dadd(-423.5, -382, -73.5, 3.8, sec = self.dend[152]) h.pt3dadd(-423.5, -383.5, -76.5, 0.6, sec = self.dend[152]) h.pt3dadd(-423.5, -386, -76.5, 0.8, sec = self.dend[152]) h.pt3dadd(-424, -386, -76.5, 0.8, sec = self.dend[152]) h.pt3dadd(-426, -387, -76.5, 0.9, sec = self.dend[152]) h.pt3dadd(-427, -388.5, -79.5, 0.9, sec = self.dend[152]) h.pt3dadd(-427, -390.5, -76.5, 1.5, sec = self.dend[152]) h.pt3dadd(-429, -391.5, -79.5, 2.1, sec = self.dend[152]) h.pt3dadd(-430.5, -392.5, -79.5, 1.5, sec = self.dend[152]) h.pt3dadd(-431.5, -393.5, -79.5, 0.9, sec = self.dend[152]) h.pt3dadd(-432.5, -394, -85, 0.6, sec = self.dend[152]) h.pt3dadd(-434, -395, -82, 0.6, sec = self.dend[152]) h.pt3dadd(-436, -396.5, -79.5, 0.6, sec = self.dend[152]) h.pt3dadd(-436.5, -398, -79.5, 1.9, sec = self.dend[152]) h.pt3dadd(-439, -399, -79.5, 2.8, sec = self.dend[152]) h.pt3dadd(-439.5, -401.5, -85, 2.8, sec = self.dend[152]) h.pt3dadd(-442.5, -403, -85, 1.4, sec = self.dend[152]) h.pt3dadd(-445, -404.5, -85, 0.9, sec = self.dend[152]) h.pt3dadd(-446.5, -406.5, -85, 1, sec = self.dend[152]) h.pt3dadd(-448, -407.5, -85, 1, sec = self.dend[152]) h.pt3dadd(-450, -410, -82, 1.6, sec = self.dend[152]) h.pt3dadd(-452.5, -410, -82, 1.1, sec = self.dend[152]) h.pt3dadd(-452.5, -412, -82, 1.1, sec = self.dend[152]) h.pt3dadd(-453.5, -413.5, -85, 0.7, sec = self.dend[152]) h.pt3dadd(-455.5, -415.5, -85, 1.1, sec = self.dend[152]) h.pt3dadd(-457.5, -417.5, -85, 1.3, sec = self.dend[152]) h.pt3dadd(-459, -418.5, -88, 1.7, sec = self.dend[152]) h.pt3dadd(-462, -421, -88, 1.1, sec = self.dend[152]) h.pt3dadd(-465, -422.5, -92.5, 0.1, sec = self.dend[152]) h.pt3dadd(-466, -423.5, -90, 0.1, sec = self.dend[152]) h.pt3dadd(-467, -424.5, -88, 1.7, sec = self.dend[152]) h.pt3dadd(-469, -426.5, -92.5, 1.1, sec = self.dend[152]) h.pt3dadd(-470.5, -427.5, -92.5, 0.3, sec = self.dend[152]) h.pt3dadd(-474, -429.5, -92.5, 0.3, sec = self.dend[152]) h.pt3dadd(-474.5, -431, -90, 1.2, sec = self.dend[152]) h.pt3dadd(-475, -432.5, -90, 2, sec = self.dend[152]) h.pt3dadd(-477.5, -432.5, -90, 0.8, sec = self.dend[152]) h.pt3dadd(-478, -434, -90, 0.1, sec = self.dend[152]) h.pt3dadd(-480, -435, -90, 0.1, sec = self.dend[152]) h.pt3dadd(-480, -437.5, -90, 1.3, sec = self.dend[152]) h.pt3dadd(-482.5, -439.5, -95, 0.1, sec = self.dend[152]) h.pt3dadd(-483, -441, -95, 0.1, sec = self.dend[152]) h.pt3dadd(-484.5, -444.5, -95, 2.3, sec = self.dend[152]) h.pt3dadd(-485.5, -446, -95, 0.3, sec = self.dend[152]) h.pt3dadd(-486.5, -447.5, -95, 0.3, sec = self.dend[152]) h.pt3dadd(-488.5, -450.5, -95, 2.8, sec = self.dend[152]) h.pt3dadd(-490.5, -451.5, -95, 1.5, sec = self.dend[152]) h.pt3dadd(-491.5, -453.5, -99.5, 0.4, sec = self.dend[152]) h.pt3dadd(-496, -455, -99.5, 0.4, sec = self.dend[152]) h.pt3dadd(-497.5, -457, -99.5, 0.4, sec = self.dend[152]) h.pt3dadd(-499, -459, -99.5, 2.7, sec = self.dend[152]) h.pt3dadd(-500.5, -461.5, -102, 0.7, sec = self.dend[152]) h.pt3dadd(-503.5, -463, -99.5, 0.7, sec = self.dend[152]) h.pt3dadd(-506.5, -464.5, -99.5, 0.7, sec = self.dend[152]) h.pt3dadd(-508, -465, -99.5, 2.7, sec = self.dend[152]) h.pt3dadd(-508.5, -467, -99.5, 2.6, sec = self.dend[152]) h.pt3dadd(-511, -468, -99.5, 1.7, sec = self.dend[152]) h.pt3dadd(-512.5, -469.5, -107, 0.5, sec = self.dend[152]) h.pt3dadd(-513, -470.5, -107, 0.5, sec = self.dend[152]) h.pt3dadd(-515.5, -473.5, -102, 2.5, sec = self.dend[152]) h.pt3dadd(-519, -474.5, -104.5, 0.5, sec = self.dend[152]) h.pt3dadd(-522, -475, -104.5, 0.5, sec = self.dend[152]) h.pt3dadd(-525, -477.5, -111.5, 0.5, sec = self.dend[152]) h.pt3dadd(-527, -480, -107, 2.2, sec = self.dend[152]) h.pt3dadd(-528.5, -480, -107, 1.1, sec = self.dend[152]) h.pt3dadd(-530.5, -481, -107, 0.6, sec = self.dend[152]) h.pt3dadd(-533, -482.5, -107, 0.6, sec = self.dend[152]) h.pt3dadd(-534.5, -483.5, -107, 1.2, sec = self.dend[152]) h.pt3dadd(-536, -485, -107, 2.2, sec = self.dend[152]) h.pt3dadd(-539.5, -485.5, -111.5, 0.7, sec = self.dend[152]) h.pt3dadd(-540.5, -488, -111.5, 1, sec = self.dend[152]) h.pt3dadd(-543.5, -488, -111.5, 1, sec = self.dend[152]) h.pt3dadd(-546, -490.5, -111.5, 0.9, sec = self.dend[152]) h.pt3dadd(-547, -493, -111.5, 0.2, sec = self.dend[152]) h.pt3dclear(sec = self.dend[153]) h.pt3dadd(-419.5, -368.5, -73.5, 3.7, sec = self.dend[153]) h.pt3dadd(-422.5, -371.5, -70.5, 0.6, sec = self.dend[153]) h.pt3dadd(-424, -371.5, -70.5, 1.2, sec = self.dend[153]) h.pt3dadd(-426.5, -375.5, -73.5, 1.5, sec = self.dend[153]) h.pt3dadd(-428, -376, -70.5, 1.5, sec = self.dend[153]) h.pt3dadd(-429, -379, -70.5, 2.3, sec = self.dend[153]) h.pt3dadd(-430, -380, -70.5, 2.8, sec = self.dend[153]) h.pt3dadd(-432, -380.5, -70.5, 1.3, sec = self.dend[153]) h.pt3dadd(-433.5, -381, -70.5, 0.9, sec = self.dend[153]) h.pt3dadd(-435, -383, -70.5, 0.9, sec = self.dend[153]) h.pt3dadd(-436.5, -384, -70.5, 0.7, sec = self.dend[153]) h.pt3dadd(-438, -385.5, -70.5, 0.7, sec = self.dend[153]) h.pt3dadd(-439, -387.5, -70.5, 1.4, sec = self.dend[153]) h.pt3dadd(-440.5, -390, -70.5, 2.4, sec = self.dend[153]) h.pt3dadd(-443, -392, -70.5, 1.1, sec = self.dend[153]) h.pt3dadd(-444.5, -392, -70.5, 0.7, sec = self.dend[153]) h.pt3dadd(-446, -392.5, -70.5, 0.6, sec = self.dend[153]) h.pt3dadd(-446, -394, -70.5, 0.6, sec = self.dend[153]) h.pt3dadd(-447, -395.5, -70.5, 1.5, sec = self.dend[153]) h.pt3dadd(-448, -397.5, -67.5, 3.3, sec = self.dend[153]) h.pt3dadd(-449.5, -399, -73.5, 4.1, sec = self.dend[153]) h.pt3dadd(-452, -400, -70.5, 1.7, sec = self.dend[153]) h.pt3dadd(-453, -400, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-455, -402, -70.5, 1, sec = self.dend[153]) h.pt3dadd(-459.5, -405.5, -70.5, 0.9, sec = self.dend[153]) h.pt3dadd(-461.5, -406, -70.5, 0.9, sec = self.dend[153]) h.pt3dadd(-463.5, -407.5, -73.5, 1.1, sec = self.dend[153]) h.pt3dadd(-464.5, -409, -73.5, 1.1, sec = self.dend[153]) h.pt3dadd(-466.5, -410.5, -70.5, 1.6, sec = self.dend[153]) h.pt3dadd(-468, -412.5, -73.5, 2.4, sec = self.dend[153]) h.pt3dadd(-469.5, -414, -73.5, 3.8, sec = self.dend[153]) h.pt3dadd(-473, -417, -73.5, 2, sec = self.dend[153]) h.pt3dadd(-474.5, -420, -70.5, 1.1, sec = self.dend[153]) h.pt3dadd(-476, -420.5, -73.5, 0.6, sec = self.dend[153]) h.pt3dadd(-477.5, -424, -73.5, 0.8, sec = self.dend[153]) h.pt3dadd(-478, -426, -70.5, 2.5, sec = self.dend[153]) h.pt3dadd(-479.5, -428, -70.5, 3.6, sec = self.dend[153]) h.pt3dadd(-480.5, -431, -70.5, 1.2, sec = self.dend[153]) h.pt3dadd(-482, -433, -73.5, 0.7, sec = self.dend[153]) h.pt3dadd(-485, -435, -73.5, 0.7, sec = self.dend[153]) h.pt3dadd(-486.5, -437, -73.5, 1.4, sec = self.dend[153]) h.pt3dadd(-487, -439.5, -70.5, 2.7, sec = self.dend[153]) h.pt3dadd(-488.5, -441.5, -70.5, 1.5, sec = self.dend[153]) h.pt3dadd(-489.5, -444.5, -70.5, 0.7, sec = self.dend[153]) h.pt3dadd(-490, -446, -70.5, 1.9, sec = self.dend[153]) h.pt3dadd(-491, -447, -70.5, 3.4, sec = self.dend[153]) h.pt3dadd(-492, -448.5, -70.5, 2.1, sec = self.dend[153]) h.pt3dadd(-493, -450, -73.5, 1.1, sec = self.dend[153]) h.pt3dadd(-493.5, -451.5, -73.5, 0.9, sec = self.dend[153]) h.pt3dadd(-494, -453.5, -73.5, 1.1, sec = self.dend[153]) h.pt3dadd(-495, -456, -73.5, 1.3, sec = self.dend[153]) h.pt3dadd(-496, -457.5, -70.5, 1.3, sec = self.dend[153]) h.pt3dadd(-497.5, -459.5, -70.5, 0.7, sec = self.dend[153]) h.pt3dadd(-497.5, -461.5, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-498.5, -463.5, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-498.5, -466, -67.5, 1.6, sec = self.dend[153]) h.pt3dadd(-500.5, -467, -73.5, 2.7, sec = self.dend[153]) h.pt3dadd(-502, -470, -70.5, 1.6, sec = self.dend[153]) h.pt3dadd(-502.5, -471.5, -73.5, 0.7, sec = self.dend[153]) h.pt3dadd(-502.5, -473, -73.5, 0.6, sec = self.dend[153]) h.pt3dadd(-504, -475, -73.5, 0.9, sec = self.dend[153]) h.pt3dadd(-505, -476.5, -67.5, 1.2, sec = self.dend[153]) h.pt3dadd(-506, -476.5, -76.5, 0.5, sec = self.dend[153]) h.pt3dadd(-507.5, -479, -70.5, 1.2, sec = self.dend[153]) h.pt3dadd(-508.5, -480.5, -70.5, 2.6, sec = self.dend[153]) h.pt3dadd(-508.5, -481.5, -70.5, 4.3, sec = self.dend[153]) h.pt3dadd(-510.5, -485, -70.5, 2, sec = self.dend[153]) h.pt3dadd(-512.5, -487, -76.5, 0.7, sec = self.dend[153]) h.pt3dadd(-514.5, -489, -76.5, 0.7, sec = self.dend[153]) h.pt3dadd(-516, -489, -73.5, 2, sec = self.dend[153]) h.pt3dadd(-518.5, -491, -70.5, 2.6, sec = self.dend[153]) h.pt3dadd(-520, -491, -73.5, 1.3, sec = self.dend[153]) h.pt3dadd(-521.5, -492, -76.5, 0.3, sec = self.dend[153]) h.pt3dadd(-525, -495, -70.5, 0.3, sec = self.dend[153]) h.pt3dadd(-527.5, -497, -70.5, 1.6, sec = self.dend[153]) h.pt3dadd(-528, -497, -70.5, 2.5, sec = self.dend[153]) h.pt3dadd(-529.5, -498.5, -70.5, 1.2, sec = self.dend[153]) h.pt3dadd(-532, -501, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-536, -502.5, -73.5, 0.8, sec = self.dend[153]) h.pt3dadd(-538, -503.5, -73.5, 0.8, sec = self.dend[153]) h.pt3dadd(-538.5, -505.5, -67.5, 1.4, sec = self.dend[153]) h.pt3dadd(-541, -509, -73.5, 3.7, sec = self.dend[153]) h.pt3dadd(-543.5, -509.5, -70.5, 2.4, sec = self.dend[153]) h.pt3dadd(-545.5, -512.5, -73.5, 0.9, sec = self.dend[153]) h.pt3dadd(-548, -514.5, -73.5, 0.7, sec = self.dend[153]) h.pt3dadd(-549, -516.5, -73.5, 0.7, sec = self.dend[153]) h.pt3dadd(-551.5, -517.5, -70.5, 1.5, sec = self.dend[153]) h.pt3dadd(-553, -521, -73.5, 2.7, sec = self.dend[153]) h.pt3dadd(-555, -521, -70.5, 2, sec = self.dend[153]) h.pt3dadd(-556, -522.5, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-556.5, -525.5, -70.5, 0.8, sec = self.dend[153]) h.pt3dadd(-558.5, -526, -73.5, 1.3, sec = self.dend[153]) h.pt3dadd(-559.5, -528, -73.5, 1.9, sec = self.dend[153]) h.pt3dadd(-560.5, -529.5, -73.5, 1.4, sec = self.dend[153]) h.pt3dadd(-561, -531.5, -73.5, 0.8, sec = self.dend[153]) h.pt3dadd(-563, -533.5, -73.5, 0.5, sec = self.dend[153]) h.pt3dadd(-563, -535, -73.5, 0.5, sec = self.dend[153]) h.pt3dadd(-564.5, -536.5, -73.5, 2.6, sec = self.dend[153]) h.pt3dadd(-567.5, -539.5, -76.5, 3.3, sec = self.dend[153]) h.pt3dadd(-570.5, -540.5, -76.5, 2.6, sec = self.dend[153]) h.pt3dadd(-572, -542, -76.5, 1.1, sec = self.dend[153]) h.pt3dadd(-576, -546, -76.5, 1.1, sec = self.dend[153]) h.pt3dadd(-577.5, -547.5, -82, 1.2, sec = self.dend[153]) h.pt3dadd(-579, -549.5, -79.5, 2.7, sec = self.dend[153]) h.pt3dadd(-580.5, -550.5, -76.5, 1.1, sec = self.dend[153]) h.pt3dadd(-581.5, -552, -76.5, 0.3, sec = self.dend[153]) h.pt3dadd(-585.5, -555, -73.5, 0.3, sec = self.dend[153]) h.pt3dadd(-588.5, -558.5, -76.5, 0.3, sec = self.dend[153]) h.pt3dadd(-588.5, -560.5, -76.5, 0.3, sec = self.dend[153]) h.pt3dadd(-589.5, -563.5, -76.5, 1.7, sec = self.dend[153]) h.pt3dadd(-591, -564.5, -79.5, 2.5, sec = self.dend[153]) h.pt3dadd(-592, -566.5, -79.5, 1.5, sec = self.dend[153]) h.pt3dadd(-593.5, -569, -76.5, 0.9, sec = self.dend[153]) h.pt3dadd(-595.5, -572.5, -79.5, 0.1, sec = self.dend[153]) h.pt3dadd(-597, -576.5, -82, 0.1, sec = self.dend[153]) h.pt3dadd(-597.5, -578, -85, 0.9, sec = self.dend[153]) h.pt3dadd(-597, -579.5, -85, 0.9, sec = self.dend[153]) h.pt3dadd(-596, -581.5, -82, 0.4, sec = self.dend[153]) h.pt3dadd(-595, -583.5, -85, 0.4, sec = self.dend[153]) h.pt3dadd(-594.5, -583.5, -82, 1.2, sec = self.dend[153]) h.pt3dadd(-592.5, -585.5, -85, 0.9, sec = self.dend[153]) h.pt3dadd(-592.5, -586.5, -85, 0.6, sec = self.dend[153]) h.pt3dadd(-590.5, -587.5, -85, 0.5, sec = self.dend[153]) h.pt3dadd(-589.5, -588.5, -88, 0.7, sec = self.dend[153]) h.pt3dadd(-589, -589.5, -85, 1.6, sec = self.dend[153]) h.pt3dadd(-587.5, -592.5, -88, 0.8, sec = self.dend[153]) h.pt3dadd(-586, -596.5, -88, 0.8, sec = self.dend[153]) h.pt3dadd(-585, -599.5, -91, 1.2, sec = self.dend[153]) h.pt3dadd(-584, -603, -94, 1.2, sec = self.dend[153]) h.pt3dadd(-584, -607.5, -94, 1.2, sec = self.dend[153]) h.pt3dadd(-584, -610, -94, 1.2, sec = self.dend[153]) h.pt3dadd(-584, -613.5, -94, 1.2, sec = self.dend[153]) h.pt3dadd(-584, -616.5, -94, 1.2, sec = self.dend[153]) h.pt3dadd(-585.5, -619.5, -94, 0.7, sec = self.dend[153]) h.pt3dadd(-585.5, -622, -94, 0.6, sec = self.dend[153]) h.pt3dadd(-584.5, -624, -94, 0.6, sec = self.dend[153]) h.pt3dadd(-583.5, -626, -94, 0.6, sec = self.dend[153]) h.pt3dadd(-584.5, -628, -94, 0.6, sec = self.dend[153]) h.pt3dadd(-585.5, -629, -94, 0.6, sec = self.dend[153]) h.pt3dadd(-585, -632.5, -91, 1, sec = self.dend[153]) h.pt3dadd(-586, -633.5, -91, 1, sec = self.dend[153]) h.pt3dadd(-587.5, -636.5, -91, 0.6, sec = self.dend[153]) h.pt3dadd(-589.5, -636.5, -91, 0.6, sec = self.dend[153]) h.pt3dadd(-589.5, -638, -91, 0.6, sec = self.dend[153]) h.pt3dadd(-589.5, -640, -94, 1.4, sec = self.dend[153]) h.pt3dadd(-589.5, -643, -91, 2.1, sec = self.dend[153]) h.pt3dadd(-589, -646.5, -91, 1.4, sec = self.dend[153]) h.pt3dadd(-588, -646.5, -91, 0.3, sec = self.dend[153]) h.pt3dadd(-587, -648, -91, 0.3, sec = self.dend[153]) h.pt3dadd(-586.5, -649, -91, 1.6, sec = self.dend[153]) h.pt3dadd(-584, -652, -91, 0.7, sec = self.dend[153]) h.pt3dadd(-582.5, -654, -91, 1.4, sec = self.dend[153]) h.pt3dadd(-582, -654.5, -88, 1.6, sec = self.dend[153]) h.pt3dadd(-581, -656, -94, 0.9, sec = self.dend[153]) h.pt3dadd(-580, -658.5, -94, 0.9, sec = self.dend[153]) h.pt3dadd(-578, -659.5, -94, 0.7, sec = self.dend[153]) h.pt3dadd(-575, -661, -88, 1.1, sec = self.dend[153]) h.pt3dadd(-572.5, -661, -94, 0.9, sec = self.dend[153]) h.pt3dadd(-570, -661, -88, 0.4, sec = self.dend[153]) h.pt3dadd(-567.5, -659, -91, 0.3, sec = self.dend[153]) h.pt3dadd(-567.5, -662.5, -91, 0.1, sec = self.dend[153]) h.pt3dadd(-566.5, -662.5, -94, 0.1, sec = self.dend[153]) h.pt3dadd(-565, -664.5, -91, 0.1, sec = self.dend[153]) h.pt3dadd(-563.5, -664.5, -91, 0.1, sec = self.dend[153]) h.pt3dadd(-563, -666.5, -88, 0.1, sec = self.dend[153]) h.pt3dadd(-561, -667.5, -88, 0.1, sec = self.dend[153]) h.pt3dclear(sec = self.dend[154]) h.pt3dadd(-124.5, -45, -8.5, 8.8, sec = self.dend[154]) h.pt3dadd(-127.5, -45, -8.5, 6.5, sec = self.dend[154]) h.pt3dadd(-131, -48.5, -8.5, 5.8, sec = self.dend[154]) h.pt3dadd(-134, -50.5, -8.5, 5.7, sec = self.dend[154]) h.pt3dadd(-137, -52.5, -9.5, 4.9, sec = self.dend[154]) h.pt3dadd(-141, -54.5, -9.5, 4.1, sec = self.dend[154]) h.pt3dadd(-144, -57, -9.5, 6.3, sec = self.dend[154]) h.pt3dadd(-149, -58.5, -11, 8.1, sec = self.dend[154]) h.pt3dadd(-153.5, -60.5, -10, 7.9, sec = self.dend[154]) h.pt3dadd(-158.5, -60.5, -10, 7.3, sec = self.dend[154]) h.pt3dadd(-161.5, -60.5, -10, 6.3, sec = self.dend[154]) h.pt3dadd(-167, -63.5, -8.5, 6.3, sec = self.dend[154]) h.pt3dadd(-174.5, -63.5, -7.5, 6.3, sec = self.dend[154]) h.pt3dadd(-183.5, -67, -9.5, 6.3, sec = self.dend[154]) h.pt3dadd(-189.5, -67, -11.5, 5.8, sec = self.dend[154]) h.pt3dadd(-194, -67, -10.5, 6.7, sec = self.dend[154]) h.pt3dadd(-197.5, -67.5, -12.5, 6.3, sec = self.dend[154]) h.pt3dadd(-202.5, -70.5, -12.5, 5.1, sec = self.dend[154]) h.pt3dadd(-206, -70.5, -12.5, 5.1, sec = self.dend[154]) h.pt3dadd(-211, -72.5, -11.5, 5.6, sec = self.dend[154]) h.pt3dadd(-214.5, -72.5, -11.5, 6, sec = self.dend[154]) h.pt3dadd(-218.5, -72.5, -11.5, 6.3, sec = self.dend[154]) h.pt3dadd(-223, -71.5, -11.5, 6.3, sec = self.dend[154]) h.pt3dadd(-228.5, -73, -12.5, 5.5, sec = self.dend[154]) h.pt3dadd(-232.5, -74, -12.5, 5.5, sec = self.dend[154]) h.pt3dadd(-237.5, -74.5, -12.5, 5.7, sec = self.dend[154]) h.pt3dadd(-242, -74.5, -14, 6.3, sec = self.dend[154]) h.pt3dadd(-245.5, -75, -14, 6.3, sec = self.dend[154]) h.pt3dadd(-255.5, -76.5, -11.5, 5.9, sec = self.dend[154]) h.pt3dadd(-260.5, -76.5, -11.5, 5.2, sec = self.dend[154]) h.pt3dadd(-262.5, -76, -14, 4.5, sec = self.dend[154]) h.pt3dadd(-266, -78, -14, 5.7, sec = self.dend[154]) h.pt3dadd(-271.5, -80.5, -14, 6.2, sec = self.dend[154]) h.pt3dadd(-276, -81, -14, 6.7, sec = self.dend[154]) h.pt3dadd(-280.5, -82.5, -14, 6.7, sec = self.dend[154]) h.pt3dadd(-284.5, -85, -14, 6, sec = self.dend[154]) h.pt3dadd(-289.5, -86, -14, 5.3, sec = self.dend[154]) h.pt3dadd(-292.5, -86.5, -14, 5.3, sec = self.dend[154]) h.pt3dadd(-296.5, -87, -15, 5.8, sec = self.dend[154]) h.pt3dadd(-302.5, -87.5, -14, 5.8, sec = self.dend[154]) h.pt3dadd(-308.5, -88, -14, 5.3, sec = self.dend[154]) h.pt3dadd(-313.5, -88, -12.5, 5.7, sec = self.dend[154]) h.pt3dadd(-317, -87, -14, 6.3, sec = self.dend[154]) h.pt3dadd(-322, -87, -15, 5.4, sec = self.dend[154]) h.pt3dadd(-326.5, -87, -15, 5, sec = self.dend[154]) h.pt3dadd(-329, -89.5, -12.5, 4.2, sec = self.dend[154]) h.pt3dadd(-332, -89.5, -12.5, 5.8, sec = self.dend[154]) h.pt3dadd(-334, -90, -14, 6.3, sec = self.dend[154]) h.pt3dadd(-335.5, -90, -14, 6.9, sec = self.dend[154]) h.pt3dclear(sec = self.dend[155]) h.pt3dadd(-335.5, -90, -14, 6.9, sec = self.dend[155]) h.pt3dadd(-342, -88.5, -11.5, 2, sec = self.dend[155]) h.pt3dadd(-344, -89, -11.5, 1.7, sec = self.dend[155]) h.pt3dadd(-346, -89, -11.5, 2.4, sec = self.dend[155]) h.pt3dadd(-348, -89, -11.5, 2.8, sec = self.dend[155]) h.pt3dadd(-351, -88.5, -10.5, 1.9, sec = self.dend[155]) h.pt3dadd(-352.5, -88.5, -10.5, 3.7, sec = self.dend[155]) h.pt3dadd(-354, -90, -11.5, 3.1, sec = self.dend[155]) h.pt3dadd(-357, -92, -11.5, 1.9, sec = self.dend[155]) h.pt3dadd(-358.5, -94, -11.5, 1.9, sec = self.dend[155]) h.pt3dadd(-360, -94, -11.5, 1.9, sec = self.dend[155]) h.pt3dadd(-361, -93, -9.5, 1.8, sec = self.dend[155]) h.pt3dadd(-365, -93.5, -9.5, 2.5, sec = self.dend[155]) h.pt3dadd(-368, -94.5, -9.5, 3.1, sec = self.dend[155]) h.pt3dadd(-371.5, -98.5, -9.5, 3.7, sec = self.dend[155]) h.pt3dadd(-375.5, -100, -9.5, 3.7, sec = self.dend[155]) h.pt3dadd(-380, -102, -8.5, 3.7, sec = self.dend[155]) h.pt3dadd(-383, -104.5, -10.5, 3.2, sec = self.dend[155]) h.pt3dadd(-389, -105.5, -9.5, 2.3, sec = self.dend[155]) h.pt3dadd(-392.5, -105.5, -8.5, 1.6, sec = self.dend[155]) h.pt3dadd(-395, -105.5, -7.5, 3.1, sec = self.dend[155]) h.pt3dadd(-398.5, -105.5, -7.5, 4.3, sec = self.dend[155]) h.pt3dadd(-407, -110, -7.5, 4.1, sec = self.dend[155]) h.pt3dadd(-409, -112, -7.5, 3.1, sec = self.dend[155]) h.pt3dadd(-411.5, -112, -7.5, 1.8, sec = self.dend[155]) h.pt3dadd(-414, -112, -7.5, 1.8, sec = self.dend[155]) h.pt3dadd(-417.5, -112, -7.5, 2.2, sec = self.dend[155]) h.pt3dadd(-417.5, -111.5, -7.5, 2.8, sec = self.dend[155]) h.pt3dadd(-419.5, -111.5, -7, 1.8, sec = self.dend[155]) h.pt3dadd(-422, -111.5, -6, 3.8, sec = self.dend[155]) h.pt3dadd(-424.5, -112.5, -6, 2.9, sec = self.dend[155]) h.pt3dadd(-427.5, -112.5, -6, 2.2, sec = self.dend[155]) h.pt3dadd(-429, -112.5, -6, 1.9, sec = self.dend[155]) h.pt3dadd(-433, -112.5, -4, 2.7, sec = self.dend[155]) h.pt3dadd(-437.5, -112.5, -2.5, 4, sec = self.dend[155]) h.pt3dadd(-440.5, -112.5, -2.5, 2.2, sec = self.dend[155]) h.pt3dadd(-440.5, -112, -3, 2.1, sec = self.dend[155]) h.pt3dadd(-444, -112, -3, 2.1, sec = self.dend[155]) h.pt3dadd(-446, -112, -3, 2.1, sec = self.dend[155]) h.pt3dadd(-449.5, -111.5, -1.5, 4, sec = self.dend[155]) h.pt3dadd(-452, -111.5, -0.5, 4.3, sec = self.dend[155]) h.pt3dadd(-456, -111, -0.5, 3.4, sec = self.dend[155]) h.pt3dadd(-459.5, -111, -0.5, 1.8, sec = self.dend[155]) h.pt3dadd(-465, -110.5, -0.5, 1.8, sec = self.dend[155]) h.pt3dadd(-468, -110.5, 7.5, 2.5, sec = self.dend[155]) h.pt3dadd(-470.5, -110.5, 7.5, 3.3, sec = self.dend[155]) h.pt3dadd(-471, -110, 7.5, 4.2, sec = self.dend[155]) h.pt3dadd(-473.5, -110, 7.5, 2.8, sec = self.dend[155]) h.pt3dadd(-476, -109.5, 7.5, 2, sec = self.dend[155]) h.pt3dadd(-479.5, -109, 7.5, 1.1, sec = self.dend[155]) h.pt3dadd(-482.5, -109, 7.5, 1.7, sec = self.dend[155]) h.pt3dadd(-484.5, -108, 7.5, 2.6, sec = self.dend[155]) h.pt3dadd(-486, -107, 10.5, 3.3, sec = self.dend[155]) h.pt3dadd(-489.5, -107, 10.5, 1.6, sec = self.dend[155]) h.pt3dadd(-492, -106.5, 10.5, 1.6, sec = self.dend[155]) h.pt3dadd(-495.5, -104.5, 10.5, 3.6, sec = self.dend[155]) h.pt3dadd(-499.5, -104.5, 10.5, 5.5, sec = self.dend[155]) h.pt3dadd(-502, -104, 10.5, 4, sec = self.dend[155]) h.pt3dclear(sec = self.dend[156]) h.pt3dadd(-502, -104, 10.5, 4, sec = self.dend[156]) h.pt3dadd(-507.5, -101.5, 13, 1.3, sec = self.dend[156]) h.pt3dadd(-509.5, -100.5, 13, 1.7, sec = self.dend[156]) h.pt3dadd(-513, -99.5, 24.5, 1, sec = self.dend[156]) h.pt3dadd(-515.5, -97.5, 13, 1.2, sec = self.dend[156]) h.pt3dadd(-518.5, -97, 16, 1, sec = self.dend[156]) h.pt3dadd(-520, -96.5, 19, 2.2, sec = self.dend[156]) h.pt3dadd(-521.5, -94, 24.5, 3.1, sec = self.dend[156]) h.pt3dadd(-524, -94, 24.5, 2.5, sec = self.dend[156]) h.pt3dadd(-525, -92, 24.5, 1.4, sec = self.dend[156]) h.pt3dadd(-526.5, -90.5, 19, 0.6, sec = self.dend[156]) h.pt3dadd(-527.5, -90.5, 19, 0.6, sec = self.dend[156]) h.pt3dadd(-529, -90, 21.5, 2, sec = self.dend[156]) h.pt3dadd(-530.5, -89, 24.5, 3.5, sec = self.dend[156]) h.pt3dadd(-532.5, -89, 24.5, 1.2, sec = self.dend[156]) h.pt3dadd(-534, -88.5, 24.5, 0.9, sec = self.dend[156]) h.pt3dadd(-536.5, -87.5, 16, 0.9, sec = self.dend[156]) h.pt3dadd(-540, -87.5, 19, 0.9, sec = self.dend[156]) h.pt3dadd(-542.5, -87, 24.5, 1.6, sec = self.dend[156]) h.pt3dadd(-544.5, -86, 24.5, 1.8, sec = self.dend[156]) h.pt3dadd(-546.5, -85.5, 16, 1.2, sec = self.dend[156]) h.pt3dadd(-549.5, -82.5, 19, 0.6, sec = self.dend[156]) h.pt3dadd(-553.5, -81.5, 21.5, 0.6, sec = self.dend[156]) h.pt3dadd(-556.5, -79.5, 21.5, 1, sec = self.dend[156]) h.pt3dadd(-558.5, -79.5, 21.5, 1, sec = self.dend[156]) h.pt3dadd(-560.5, -78.5, 21.5, 2.3, sec = self.dend[156]) h.pt3dadd(-562.5, -77.5, 24.5, 4.2, sec = self.dend[156]) h.pt3dadd(-566.5, -75.5, 21.5, 2.4, sec = self.dend[156]) h.pt3dadd(-569, -75, 21.5, 1, sec = self.dend[156]) h.pt3dadd(-570, -73, 21.5, 1, sec = self.dend[156]) h.pt3dadd(-573.5, -73, 27, 2.8, sec = self.dend[156]) h.pt3dadd(-576, -72.5, 27, 2, sec = self.dend[156]) h.pt3dadd(-578, -71, 27, 1.4, sec = self.dend[156]) h.pt3dadd(-578.5, -70, 27, 1.1, sec = self.dend[156]) h.pt3dadd(-579.5, -69, 27, 0.7, sec = self.dend[156]) h.pt3dadd(-581.5, -67, 30, 0.7, sec = self.dend[156]) h.pt3dadd(-583, -69, 17, 0.1, sec = self.dend[156]) h.pt3dadd(-585.5, -69, 20, 0.1, sec = self.dend[156]) h.pt3dadd(-588.5, -69, 20, 0.1, sec = self.dend[156]) h.pt3dadd(-594, -68, 20, 0.1, sec = self.dend[156]) h.pt3dadd(-597.5, -68, 20, 0.1, sec = self.dend[156]) h.pt3dadd(-600, -68.5, 17, 0.1, sec = self.dend[156]) h.pt3dadd(-603, -68.5, 21.5, 1.2, sec = self.dend[156]) h.pt3dadd(-604, -69, 23, 1.9, sec = self.dend[156]) h.pt3dadd(-607, -69, 17, 1.3, sec = self.dend[156]) h.pt3dadd(-608, -69, 18.5, 0.5, sec = self.dend[156]) h.pt3dadd(-611, -69, 18.5, 0.3, sec = self.dend[156]) h.pt3dadd(-612.5, -69, 20, 0.5, sec = self.dend[156]) h.pt3dadd(-615, -69, 20, 0.5, sec = self.dend[156]) h.pt3dadd(-618.5, -69, 20, 0.5, sec = self.dend[156]) h.pt3dadd(-620.5, -69, 21.5, 1.7, sec = self.dend[156]) h.pt3dadd(-622, -69, 24, 3.2, sec = self.dend[156]) h.pt3dadd(-625, -68, 24, 3.4, sec = self.dend[156]) h.pt3dadd(-628, -68, 25.5, 1.4, sec = self.dend[156]) h.pt3dadd(-629.5, -67, 25.5, 1.1, sec = self.dend[156]) h.pt3dadd(-632.5, -66, 25.5, 1.1, sec = self.dend[156]) h.pt3dadd(-636, -66, 25.5, 1.1, sec = self.dend[156]) h.pt3dadd(-639.5, -66, 27, 1.5, sec = self.dend[156]) h.pt3dadd(-641, -66, 28.5, 3.4, sec = self.dend[156]) h.pt3dadd(-643, -65, 15.5, 4, sec = self.dend[156]) h.pt3dadd(-646, -64.5, 15.5, 1.4, sec = self.dend[156]) h.pt3dadd(-648.5, -64.5, 15.5, 0.8, sec = self.dend[156]) h.pt3dadd(-651.5, -64, 17, 1.1, sec = self.dend[156]) h.pt3dadd(-656, -63.5, 18.5, 1.1, sec = self.dend[156]) h.pt3dadd(-659.5, -62.5, 20, 2.4, sec = self.dend[156]) h.pt3dadd(-662.5, -62.5, 20, 0.9, sec = self.dend[156]) h.pt3dadd(-665, -62, 20, 1.1, sec = self.dend[156]) h.pt3dadd(-667.5, -62, 20, 2.6, sec = self.dend[156]) h.pt3dadd(-670, -62, 21.5, 4.3, sec = self.dend[156]) h.pt3dadd(-672.5, -62, 21.5, 1.9, sec = self.dend[156]) h.pt3dadd(-675, -61.5, 23, 0.6, sec = self.dend[156]) h.pt3dadd(-677, -60, 23, 0.6, sec = self.dend[156]) h.pt3dadd(-680.5, -60, 24, 0.7, sec = self.dend[156]) h.pt3dadd(-680.5, -58, 25.5, 0.7, sec = self.dend[156]) h.pt3dadd(-683, -58, 25.5, 1.6, sec = self.dend[156]) h.pt3dadd(-683.5, -55.5, 28.5, 4.3, sec = self.dend[156]) h.pt3dadd(-688, -55.5, 28.5, 0.8, sec = self.dend[156]) h.pt3dadd(-690.5, -54.5, 28.5, 0.8, sec = self.dend[156]) h.pt3dadd(-691, -51.5, 30, 1.6, sec = self.dend[156]) h.pt3dadd(-691.5, -49.5, 31.5, 2.4, sec = self.dend[156]) h.pt3dadd(-691.5, -48, 31.5, 3.6, sec = self.dend[156]) h.pt3dadd(-692, -45.5, 31.5, 2, sec = self.dend[156]) h.pt3dadd(-693, -43.5, 31.5, 1.1, sec = self.dend[156]) h.pt3dadd(-693.5, -41, 31.5, 0.8, sec = self.dend[156]) h.pt3dadd(-697, -39, 24, 1.1, sec = self.dend[156]) h.pt3dadd(-697, -38.5, 24, 1.1, sec = self.dend[156]) h.pt3dadd(-699, -36.5, 25.5, 2.2, sec = self.dend[156]) h.pt3dadd(-700.5, -34, 25.5, 1.4, sec = self.dend[156]) h.pt3dadd(-703, -33, 25.5, 1.6, sec = self.dend[156]) h.pt3dadd(-704.5, -33, 25.5, 0.6, sec = self.dend[156]) h.pt3dadd(-706.5, -31.5, 25.5, 0.6, sec = self.dend[156]) h.pt3dadd(-708, -30, 25.5, 0.6, sec = self.dend[156]) h.pt3dadd(-709.5, -30, 25.5, 2.1, sec = self.dend[156]) h.pt3dadd(-710.5, -29.5, 28.5, 2.9, sec = self.dend[156]) h.pt3dadd(-712, -28, 25.5, 0.9, sec = self.dend[156]) h.pt3dadd(-713, -27.5, 25.5, 0.9, sec = self.dend[156]) h.pt3dadd(-714, -27.5, 25.5, 0.9, sec = self.dend[156]) h.pt3dadd(-715.5, -27.5, 25.5, 1.7, sec = self.dend[156]) h.pt3dadd(-716.5, -25.5, 27, 2.5, sec = self.dend[156]) h.pt3dadd(-719, -25, 25.5, 1, sec = self.dend[156]) h.pt3dadd(-719.5, -24.5, 24, 0.7, sec = self.dend[156]) h.pt3dadd(-721, -23, 24, 0.7, sec = self.dend[156]) h.pt3dadd(-722.5, -22, 27, 1.6, sec = self.dend[156]) h.pt3dadd(-725.5, -22, 27, 2.6, sec = self.dend[156]) h.pt3dadd(-727, -20, 27, 1.4, sec = self.dend[156]) h.pt3dadd(-730, -19.5, 27, 0.7, sec = self.dend[156]) h.pt3dadd(-732, -19, 27, 0.7, sec = self.dend[156]) h.pt3dadd(-732, -18, 28.5, 2.4, sec = self.dend[156]) h.pt3dadd(-734, -18, 30, 3.6, sec = self.dend[156]) h.pt3dadd(-735.5, -17.5, 30, 1.5, sec = self.dend[156]) h.pt3dadd(-738, -17.5, 30, 0.5, sec = self.dend[156]) h.pt3dadd(-740.5, -16.5, 30, 0.5, sec = self.dend[156]) h.pt3dadd(-742, -16.5, 30, 2.5, sec = self.dend[156]) h.pt3dadd(-743.5, -16.5, 30, 3.2, sec = self.dend[156]) h.pt3dadd(-745, -16, 30, 1.4, sec = self.dend[156]) h.pt3dadd(-746.5, -15.5, 30, 0.6, sec = self.dend[156]) h.pt3dadd(-749.5, -15.5, 30, 0.6, sec = self.dend[156]) h.pt3dadd(-751.5, -16, 31.5, 2.1, sec = self.dend[156]) h.pt3dadd(-752, -16, 31.5, 2.4, sec = self.dend[156]) h.pt3dadd(-753, -17.5, 31.5, 1.6, sec = self.dend[156]) h.pt3dadd(-756.5, -19, 30, 1.8, sec = self.dend[156]) h.pt3dclear(sec = self.dend[157]) h.pt3dadd(-756.5, -19, 30, 1.8, sec = self.dend[157]) h.pt3dadd(-760.5, -16, 27, 0.9, sec = self.dend[157]) h.pt3dadd(-760.5, -15, 28.5, 1, sec = self.dend[157]) h.pt3dadd(-762.5, -13, 28.5, 1.3, sec = self.dend[157]) h.pt3dadd(-764, -13, 28.5, 1.9, sec = self.dend[157]) h.pt3dadd(-766.5, -11.5, 28.5, 1.1, sec = self.dend[157]) h.pt3dadd(-766.5, -9.5, 28.5, 1.4, sec = self.dend[157]) h.pt3dadd(-769, -7, 30, 1.2, sec = self.dend[157]) h.pt3dadd(-772.5, -5, 30, 1.4, sec = self.dend[157]) h.pt3dadd(-773, -3.5, 35, 2.3, sec = self.dend[157]) h.pt3dadd(-774.5, -1.5, 35, 0.2, sec = self.dend[157]) h.pt3dadd(-775.5, -0.5, 35, 0.2, sec = self.dend[157]) h.pt3dadd(-777, 1, 35, 0.2, sec = self.dend[157]) h.pt3dadd(-778, 2, 35, 2.6, sec = self.dend[157]) h.pt3dadd(-779.5, 2, 35, 3.8, sec = self.dend[157]) h.pt3dadd(-782, 2, 37, 0.4, sec = self.dend[157]) h.pt3dadd(-784, 3, 37, 0.4, sec = self.dend[157]) h.pt3dadd(-783.5, 4.5, 37, 0.4, sec = self.dend[157]) h.pt3dadd(-783.5, 5.5, 37, 0.4, sec = self.dend[157]) h.pt3dadd(-785.5, 7.5, 46, 3.7, sec = self.dend[157]) h.pt3dadd(-788.5, 5.5, 44, 0.5, sec = self.dend[157]) h.pt3dadd(-792.5, 6, 46, 0.6, sec = self.dend[157]) h.pt3dadd(-794, 6, 46, 0.6, sec = self.dend[157]) h.pt3dadd(-796.5, 6, 51.5, 1.6, sec = self.dend[157]) h.pt3dadd(-800, 6, 49.5, 1.6, sec = self.dend[157]) h.pt3dadd(-801.5, 6, 51.5, 1.4, sec = self.dend[157]) h.pt3dadd(-802, 5.5, 54.5, 0.1, sec = self.dend[157]) h.pt3dadd(-803.5, 4, 54.5, 1, sec = self.dend[157]) h.pt3dadd(-805.5, 2, 56, 2.8, sec = self.dend[157]) h.pt3dadd(-807, 1, 56, 1.4, sec = self.dend[157]) h.pt3dadd(-807.5, 0, 56, 0.3, sec = self.dend[157]) h.pt3dadd(-809, -0.5, 56, 0.1, sec = self.dend[157]) h.pt3dadd(-811, -0.5, 54.5, 0.1, sec = self.dend[157]) h.pt3dadd(-812, -0.5, 54.5, 1.3, sec = self.dend[157]) h.pt3dadd(-814.5, -0.5, 54.5, 1.5, sec = self.dend[157]) h.pt3dadd(-816.5, -0.5, 54.5, 0.5, sec = self.dend[157]) h.pt3dadd(-818, -0.5, 54.5, 0.1, sec = self.dend[157]) h.pt3dadd(-820, -0.5, 54.5, 0.4, sec = self.dend[157]) h.pt3dadd(-820.5, -0.5, 60.5, 2.8, sec = self.dend[157]) h.pt3dadd(-823, -0.5, 60.5, 1.9, sec = self.dend[157]) h.pt3dadd(-825, 1, 60.5, 1.4, sec = self.dend[157]) h.pt3dadd(-826, 1, 56, 0.6, sec = self.dend[157]) h.pt3dadd(-829, 0.5, 57.5, 0.6, sec = self.dend[157]) h.pt3dadd(-831, 0.5, 57.5, 0.6, sec = self.dend[157]) h.pt3dadd(-832.5, -1.5, 57.5, 0.6, sec = self.dend[157]) h.pt3dadd(-834, -1.5, 57.5, 0.6, sec = self.dend[157]) h.pt3dadd(-835.5, 0, 57.5, 0.6, sec = self.dend[157]) h.pt3dadd(-837, -1, 57.5, 0.4, sec = self.dend[157]) h.pt3dadd(-839, -1, 57.5, 2, sec = self.dend[157]) h.pt3dadd(-841, -1, 59, 2.3, sec = self.dend[157]) h.pt3dadd(-842.5, -0.5, 59, 1.4, sec = self.dend[157]) h.pt3dadd(-844.5, -0.5, 59, 0.8, sec = self.dend[157]) h.pt3dadd(-847, -0.5, 59, 0.5, sec = self.dend[157]) h.pt3dadd(-850, 0.5, 60.5, 0.6, sec = self.dend[157]) h.pt3dadd(-852.5, 0, 60.5, 0.6, sec = self.dend[157]) h.pt3dadd(-854.5, -0.5, 60.5, 1.8, sec = self.dend[157]) h.pt3dadd(-857, -1, 62, 2.1, sec = self.dend[157]) h.pt3dadd(-859, -2, 62, 1.6, sec = self.dend[157]) h.pt3dadd(-861, -4.5, 62, 0.3, sec = self.dend[157]) h.pt3dadd(-863, -7.5, 62, 0.3, sec = self.dend[157]) h.pt3dadd(-864.5, -7.5, 62, 0.3, sec = self.dend[157]) h.pt3dadd(-866, -8, 62, 0.2, sec = self.dend[157]) h.pt3dadd(-867, -10, 63.5, 0.2, sec = self.dend[157]) h.pt3dadd(-869, -11, 63.5, 0.3, sec = self.dend[157]) h.pt3dadd(-870.5, -11.5, 63.5, 0.3, sec = self.dend[157]) h.pt3dadd(-870.5, -13.5, 63.5, 0.2, sec = self.dend[157]) h.pt3dadd(-872, -13.5, 65, 1.4, sec = self.dend[157]) h.pt3dadd(-873, -15, 65, 2, sec = self.dend[157]) h.pt3dadd(-874.5, -17, 65, 1.2, sec = self.dend[157]) h.pt3dadd(-876, -17, 65, 1.4, sec = self.dend[157]) h.pt3dadd(-878, -17, 65, 0.6, sec = self.dend[157]) h.pt3dadd(-879.5, -18, 65, 0.4, sec = self.dend[157]) h.pt3dadd(-881.5, -18, 65, 0.4, sec = self.dend[157]) h.pt3dadd(-884, -17.5, 65, 0.2, sec = self.dend[157]) h.pt3dadd(-885, -16.5, 68, 0.1, sec = self.dend[157]) h.pt3dadd(-886, -17, 69.5, 0.1, sec = self.dend[157]) h.pt3dadd(-888, -17.5, 60.5, 0.1, sec = self.dend[157]) h.pt3dadd(-890, -18, 63.5, 0.1, sec = self.dend[157]) h.pt3dadd(-891, -17, 66.5, 1.5, sec = self.dend[157]) h.pt3dadd(-893, -17, 66.5, 1.6, sec = self.dend[157]) h.pt3dadd(-894, -14.5, 66.5, 1.1, sec = self.dend[157]) h.pt3dadd(-896, -14, 66.5, 0.7, sec = self.dend[157]) h.pt3dadd(-897.5, -13.5, 65, 1, sec = self.dend[157]) h.pt3dadd(-899.5, -11.5, 66.5, 1.4, sec = self.dend[157]) h.pt3dadd(-900.5, -11.5, 72.5, 1.2, sec = self.dend[157]) h.pt3dadd(-902, -7.5, 65, 1.2, sec = self.dend[157]) h.pt3dadd(-902, -4, 65, 0.9, sec = self.dend[157]) h.pt3dadd(-902.5, -0.5, 65, 0.9, sec = self.dend[157]) h.pt3dadd(-902.5, 1.5, 66.5, 1.5, sec = self.dend[157]) h.pt3dadd(-903.5, 5, 68, 1.6, sec = self.dend[157]) h.pt3dadd(-906.5, 6.5, 69.5, 1.2, sec = self.dend[157]) h.pt3dadd(-911.5, 6.5, 69.5, 1.2, sec = self.dend[157]) h.pt3dadd(-913.5, 3.5, 69.5, 1.1, sec = self.dend[157]) h.pt3dadd(-916, -2, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-916.5, -5, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-916.5, -8, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-916.5, -10.5, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-916.5, -14.5, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-917.5, -16, 71, 1.1, sec = self.dend[157]) h.pt3dadd(-917.5, -16, 68, 1.1, sec = self.dend[157]) h.pt3dadd(-917.5, -20.5, 68, 1.1, sec = self.dend[157]) h.pt3dadd(-920, -24.5, 68, 1.1, sec = self.dend[157]) h.pt3dadd(-921.5, -31.5, 69.5, 1.1, sec = self.dend[157]) h.pt3dadd(-923.5, -37, 69.5, 1.1, sec = self.dend[157]) h.pt3dadd(-925, -41, 69.5, 1.1, sec = self.dend[157]) h.pt3dadd(-926.5, -44, 72.5, 1.1, sec = self.dend[157]) h.pt3dadd(-927, -48.5, 72.5, 1.1, sec = self.dend[157]) h.pt3dadd(-929.5, -51, 72.5, 0.8, sec = self.dend[157]) h.pt3dadd(-931.5, -53, 72.5, 0.7, sec = self.dend[157]) h.pt3dadd(-932.5, -54, 71, 0.7, sec = self.dend[157]) h.pt3dadd(-931.5, -56.5, 71, 0.7, sec = self.dend[157]) h.pt3dadd(-931, -59, 71, 0.7, sec = self.dend[157]) h.pt3dadd(-932.5, -60.5, 71, 0.8, sec = self.dend[157]) h.pt3dadd(-932, -63.5, 71, 1, sec = self.dend[157]) h.pt3dadd(-932, -64.5, 71, 2.4, sec = self.dend[157]) h.pt3dadd(-932.5, -68, 72.5, 1.5, sec = self.dend[157]) h.pt3dadd(-931.5, -67.5, 69.5, 0.4, sec = self.dend[157]) h.pt3dadd(-931.5, -71.5, 66.5, 0.4, sec = self.dend[157]) h.pt3dadd(-931, -71.5, 68, 1, sec = self.dend[157]) h.pt3dadd(-931.5, -74, 69.5, 1, sec = self.dend[157]) h.pt3dadd(-932, -74, 68, 1, sec = self.dend[157]) h.pt3dadd(-932.5, -75.5, 68, 0.7, sec = self.dend[157]) h.pt3dadd(-931.5, -77.5, 69.5, 0.7, sec = self.dend[157]) h.pt3dadd(-932, -79.5, 71, 0.5, sec = self.dend[157]) h.pt3dadd(-932, -81, 74, 1.3, sec = self.dend[157]) h.pt3dadd(-932, -83, 71, 1.6, sec = self.dend[157]) h.pt3dadd(-933.5, -85, 71, 0.7, sec = self.dend[157]) h.pt3dadd(-936, -85, 74, 0.7, sec = self.dend[157]) h.pt3dadd(-936, -89.5, 72.5, 0.7, sec = self.dend[157]) h.pt3dadd(-936.5, -91, 72.5, 0.7, sec = self.dend[157]) h.pt3dadd(-937.5, -93.5, 72.5, 0.7, sec = self.dend[157]) h.pt3dadd(-940, -94, 74, 0.7, sec = self.dend[157]) h.pt3dadd(-942, -94, 75.5, 0.9, sec = self.dend[157]) h.pt3dadd(-946.5, -94, 75.5, 0.7, sec = self.dend[157]) h.pt3dadd(-946.5, -95.5, 75.5, 0.6, sec = self.dend[157]) h.pt3dadd(-950, -99, 75.5, 0.6, sec = self.dend[157]) h.pt3dadd(-951.5, -99, 77, 1.4, sec = self.dend[157]) h.pt3dadd(-955, -101.5, 75.5, 0.6, sec = self.dend[157]) h.pt3dadd(-959.5, -101.5, 75.5, 0.6, sec = self.dend[157]) h.pt3dadd(-959.5, -104, 77, 0.4, sec = self.dend[157]) h.pt3dadd(-959.5, -108, 78.5, 0.4, sec = self.dend[157]) h.pt3dadd(-959.5, -110, 78.5, 0.4, sec = self.dend[157]) h.pt3dadd(-959, -113, 78.5, 2.4, sec = self.dend[157]) h.pt3dadd(-958.5, -114, 72.5, 0.4, sec = self.dend[157]) h.pt3dadd(-959.5, -117, 72.5, 0.4, sec = self.dend[157]) h.pt3dadd(-960.5, -118.5, 74, 1.4, sec = self.dend[157]) h.pt3dadd(-960, -121, 74, 0.1, sec = self.dend[157]) h.pt3dadd(-960, -122, 74, 0.1, sec = self.dend[157]) h.pt3dadd(-960, -124, 74, 1.3, sec = self.dend[157]) h.pt3dadd(-960.5, -127, 71, 0.1, sec = self.dend[157]) h.pt3dadd(-959, -130, 75.5, 0.1, sec = self.dend[157]) h.pt3dadd(-959, -131, 72.5, 1.4, sec = self.dend[157]) h.pt3dadd(-960, -133, 71, 1.4, sec = self.dend[157]) h.pt3dadd(-961, -133.5, 66.5, 0.9, sec = self.dend[157]) h.pt3dadd(-961, -137, 66.5, 0.3, sec = self.dend[157]) h.pt3dadd(-961, -140, 66.5, 0.3, sec = self.dend[157]) h.pt3dadd(-966, -143.5, 66.5, 0.5, sec = self.dend[157]) h.pt3dadd(-967.5, -147.5, 66.5, 0.5, sec = self.dend[157]) h.pt3dadd(-967.5, -150, 68, 1.4, sec = self.dend[157]) h.pt3dadd(-968, -151.5, 66.5, 0.2, sec = self.dend[157]) h.pt3dadd(-970.5, -155, 66.5, 0.2, sec = self.dend[157]) h.pt3dadd(-969.5, -156.5, 66.5, 0.2, sec = self.dend[157]) h.pt3dadd(-969, -159, 66.5, 0.2, sec = self.dend[157]) h.pt3dadd(-969, -162.5, 68, 0.2, sec = self.dend[157]) h.pt3dadd(-968.5, -163.5, 66.5, 0.2, sec = self.dend[157]) h.pt3dadd(-968.5, -167, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-968.5, -170, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-966.5, -171.5, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-967.5, -176.5, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-965.5, -180.5, 68, 0.3, sec = self.dend[157]) h.pt3dadd(-963, -181.5, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-961, -182, 65, 0.3, sec = self.dend[157]) h.pt3dadd(-958.5, -187, 65, 0.1, sec = self.dend[157]) h.pt3dclear(sec = self.dend[158]) h.pt3dadd(-756.5, -19, 30, 1.8, sec = self.dend[158]) h.pt3dadd(-760.5, -17.5, 30, 0.6, sec = self.dend[158]) h.pt3dadd(-762.5, -17.5, 28.5, 0.3, sec = self.dend[158]) h.pt3dadd(-763, -16, 30, 1.1, sec = self.dend[158]) h.pt3dadd(-764.5, -16, 30, 1.1, sec = self.dend[158]) h.pt3dadd(-766.5, -14.5, 30, 0.7, sec = self.dend[158]) h.pt3dadd(-767, -13.5, 28.5, 0.7, sec = self.dend[158]) h.pt3dclear(sec = self.dend[159]) h.pt3dadd(-502, -104, 10.5, 4, sec = self.dend[159]) h.pt3dadd(-506.5, -105, 7.5, 1.5, sec = self.dend[159]) h.pt3dadd(-509, -106.5, 7.5, 1.2, sec = self.dend[159]) h.pt3dadd(-510.5, -108, 7.5, 0.7, sec = self.dend[159]) h.pt3dadd(-512.5, -108, 13, 0.7, sec = self.dend[159]) h.pt3dadd(-514.5, -108.5, 13, 1.1, sec = self.dend[159]) h.pt3dadd(-517, -109.5, 16, 0.7, sec = self.dend[159]) h.pt3dadd(-519.5, -109.5, 16, 0.7, sec = self.dend[159]) h.pt3dadd(-520.5, -109.5, 19, 2.6, sec = self.dend[159]) h.pt3dadd(-524, -110.5, 13, 3.7, sec = self.dend[159]) h.pt3dadd(-526.5, -110.5, 7.5, 1.1, sec = self.dend[159]) h.pt3dadd(-529, -112.5, 7.5, 0.9, sec = self.dend[159]) h.pt3dadd(-532.5, -115, 7.5, 0.8, sec = self.dend[159]) h.pt3dadd(-535.5, -115, 7.5, 1, sec = self.dend[159]) h.pt3dadd(-537.5, -116, 5, 2, sec = self.dend[159]) h.pt3dadd(-538.5, -118.5, 5, 2.5, sec = self.dend[159]) h.pt3dadd(-541, -119.5, 5, 1.6, sec = self.dend[159]) h.pt3dadd(-543, -121.5, 5, 0.2, sec = self.dend[159]) h.pt3dadd(-544.5, -122, 5, 0.2, sec = self.dend[159]) h.pt3dadd(-546, -122.5, 5, 3.2, sec = self.dend[159]) h.pt3dadd(-547, -124, 5, 3.8, sec = self.dend[159]) h.pt3dadd(-550.5, -124.5, 5, 1.8, sec = self.dend[159]) h.pt3dadd(-553, -125, 5, 0.3, sec = self.dend[159]) h.pt3dadd(-556, -126.5, 5, 0.3, sec = self.dend[159]) h.pt3dadd(-557.5, -127, 5, 1.1, sec = self.dend[159]) h.pt3dadd(-560, -128, 5, 0.6, sec = self.dend[159]) h.pt3dadd(-561.5, -129.5, 5, 2.1, sec = self.dend[159]) h.pt3dadd(-562.5, -129.5, 5, 2.9, sec = self.dend[159]) h.pt3dadd(-566, -130, 5, 1.1, sec = self.dend[159]) h.pt3dadd(-567.5, -130, 5, 0.3, sec = self.dend[159]) h.pt3dadd(-568, -131, 5, 0.3, sec = self.dend[159]) h.pt3dadd(-569.5, -132, 10.5, 2.2, sec = self.dend[159]) h.pt3dadd(-570.5, -132, 10.5, 3.1, sec = self.dend[159]) h.pt3dadd(-572, -132, 10.5, 2.2, sec = self.dend[159]) h.pt3dadd(-574.5, -132, 10.5, 0.3, sec = self.dend[159]) h.pt3dadd(-576, -132, 10.5, 0.3, sec = self.dend[159]) h.pt3dadd(-577, -132, 10.5, 1.7, sec = self.dend[159]) h.pt3dadd(-580, -132, 10.5, 0.1, sec = self.dend[159]) h.pt3dadd(-581.5, -132, 10.5, 0.1, sec = self.dend[159]) h.pt3dadd(-582.5, -133, 10.5, 1.6, sec = self.dend[159]) h.pt3dadd(-584, -133.5, 10.5, 1.6, sec = self.dend[159]) h.pt3dadd(-586, -135, 10.5, 0.3, sec = self.dend[159]) h.pt3dadd(-591, -137, 10.5, 0.3, sec = self.dend[159]) h.pt3dadd(-595, -137, 10.5, 0.9, sec = self.dend[159]) h.pt3dadd(-595, -136, 10.5, 0.9, sec = self.dend[159]) h.pt3dadd(-595, -133.5, 9, 0.9, sec = self.dend[159]) h.pt3dadd(-596, -133.5, 9, 0.9, sec = self.dend[159]) h.pt3dadd(-598, -133.5, 9, 2.7, sec = self.dend[159]) h.pt3dadd(-600, -133.5, 17.5, 4.1, sec = self.dend[159]) h.pt3dadd(-602.5, -133.5, 13.5, 2.1, sec = self.dend[159]) h.pt3dadd(-604.5, -132, 13.5, 0.8, sec = self.dend[159]) h.pt3dadd(-606.5, -130.5, 13.5, 0.9, sec = self.dend[159]) h.pt3dadd(-606.5, -128.5, 13.5, 0.9, sec = self.dend[159]) h.pt3dadd(-608, -128.5, 13.5, 1.8, sec = self.dend[159]) h.pt3dadd(-611.5, -128.5, 13.5, 0.6, sec = self.dend[159]) h.pt3dadd(-614, -129, 13.5, 0.6, sec = self.dend[159]) h.pt3dadd(-614, -128, 13.5, 3.2, sec = self.dend[159]) h.pt3dadd(-614.5, -128, 13.5, 3.4, sec = self.dend[159]) h.pt3dadd(-617.5, -129, 13.5, 1.4, sec = self.dend[159]) h.pt3dadd(-618, -129, 13.5, 0.7, sec = self.dend[159]) h.pt3dadd(-620, -129, 13.5, 0.7, sec = self.dend[159]) h.pt3dadd(-622, -128, 15, 2.5, sec = self.dend[159]) h.pt3dadd(-622.5, -127, 15, 4.1, sec = self.dend[159]) h.pt3dadd(-624.5, -127, 15, 2.3, sec = self.dend[159]) h.pt3dadd(-627, -128.5, 19, 0.4, sec = self.dend[159]) h.pt3dadd(-630, -128.5, 19, 0.4, sec = self.dend[159]) h.pt3dadd(-630, -128, 19, 0.4, sec = self.dend[159]) h.pt3dadd(-634, -128, 17.5, 0.4, sec = self.dend[159]) h.pt3dadd(-636, -129, 19, 1.9, sec = self.dend[159]) h.pt3dadd(-637, -129, 16.5, 3.4, sec = self.dend[159]) h.pt3dadd(-638, -129, 16.5, 1.1, sec = self.dend[159]) h.pt3dadd(-640.5, -128.5, 19, 0.2, sec = self.dend[159]) h.pt3dadd(-641, -130, 19, 0.2, sec = self.dend[159]) h.pt3dadd(-642, -130, 19, 1.6, sec = self.dend[159]) h.pt3dadd(-644, -130, 19, 2.5, sec = self.dend[159]) h.pt3dadd(-646, -130, 19, 0.8, sec = self.dend[159]) h.pt3dadd(-647, -130, 19, 0.2, sec = self.dend[159]) h.pt3dadd(-648.5, -130, 19, 0.2, sec = self.dend[159]) h.pt3dadd(-649.5, -131, 19, 1.6, sec = self.dend[159]) h.pt3dadd(-650.5, -131.5, 22, 2, sec = self.dend[159]) h.pt3dadd(-652.5, -133, 19, 1.3, sec = self.dend[159]) h.pt3dadd(-654, -133.5, 19, 0.6, sec = self.dend[159]) h.pt3dadd(-655, -135.5, 20.5, 0.9, sec = self.dend[159]) h.pt3dadd(-657, -136.5, 20.5, 0.6, sec = self.dend[159]) h.pt3dadd(-659, -137, 27.5, 0.6, sec = self.dend[159]) h.pt3dadd(-659, -139.5, 27.5, 1.8, sec = self.dend[159]) h.pt3dadd(-660, -139.5, 27.5, 1.8, sec = self.dend[159]) h.pt3dadd(-660.5, -140.5, 27.5, 1, sec = self.dend[159]) h.pt3dadd(-662, -141.5, 26.5, 0.3, sec = self.dend[159]) h.pt3dadd(-664, -144.5, 32, 0.3, sec = self.dend[159]) h.pt3dadd(-666, -146.5, 32, 1.3, sec = self.dend[159]) h.pt3dadd(-666.5, -149.5, 32, 2.5, sec = self.dend[159]) h.pt3dadd(-668, -150.5, 32, 1.2, sec = self.dend[159]) h.pt3dadd(-668, -151.5, 32, 0.3, sec = self.dend[159]) h.pt3dadd(-668.5, -152, 32, 0.3, sec = self.dend[159]) h.pt3dadd(-669.5, -153.5, 32, 2, sec = self.dend[159]) h.pt3dadd(-671, -153.5, 32, 2.7, sec = self.dend[159]) h.pt3dadd(-672.5, -154.5, 32, 1.9, sec = self.dend[159]) h.pt3dadd(-673, -155.5, 32, 0.7, sec = self.dend[159]) h.pt3dadd(-674, -158.5, 33.5, 0.5, sec = self.dend[159]) h.pt3dadd(-676, -159.5, 32, 1.2, sec = self.dend[159]) h.pt3dadd(-677, -160, 32, 1.2, sec = self.dend[159]) h.pt3dadd(-677.5, -160.5, 32, 1.2, sec = self.dend[159]) h.pt3dadd(-678.5, -161, 32, 0.3, sec = self.dend[159]) h.pt3dadd(-681, -162.5, 32, 0.3, sec = self.dend[159]) h.pt3dadd(-683, -163.5, 32, 0.8, sec = self.dend[159]) h.pt3dadd(-684, -165, 32, 1.4, sec = self.dend[159]) h.pt3dadd(-685, -165.5, 32, 2, sec = self.dend[159]) h.pt3dadd(-686.5, -165.5, 32, 2.5, sec = self.dend[159]) h.pt3dadd(-688.5, -166.5, 32, 1.1, sec = self.dend[159]) h.pt3dadd(-690.5, -166.5, 32, 0.6, sec = self.dend[159]) h.pt3dadd(-694, -166.5, 32, 0.6, sec = self.dend[159]) h.pt3dadd(-694.5, -168.5, 32, 0.6, sec = self.dend[159]) h.pt3dadd(-698.5, -168.5, 32, 0.6, sec = self.dend[159]) h.pt3dadd(-700.5, -168.5, 32, 1.6, sec = self.dend[159]) h.pt3dadd(-701.5, -171, 27.5, 0.7, sec = self.dend[159]) h.pt3dadd(-706, -171, 27.5, 0.7, sec = self.dend[159]) h.pt3dadd(-706.5, -172, 27.5, 1.5, sec = self.dend[159]) h.pt3dadd(-708.5, -173, 27.5, 2, sec = self.dend[159]) h.pt3dadd(-710.5, -173.5, 27.5, 1.1, sec = self.dend[159]) h.pt3dadd(-711, -174, 27.5, 0.6, sec = self.dend[159]) h.pt3dadd(-714.5, -176.5, 27.5, 0.6, sec = self.dend[159]) h.pt3dadd(-715, -177, 27.5, 2.1, sec = self.dend[159]) h.pt3dadd(-716.5, -178.5, 27.5, 3.1, sec = self.dend[159]) h.pt3dadd(-718, -179.5, 27.5, 0.9, sec = self.dend[159]) h.pt3dadd(-718, -181, 27.5, 0.4, sec = self.dend[159]) h.pt3dadd(-720, -181, 27.5, 1.4, sec = self.dend[159]) h.pt3dadd(-720.5, -181, 27.5, 2.5, sec = self.dend[159]) h.pt3dadd(-723, -182, 27.5, 0.4, sec = self.dend[159]) h.pt3dadd(-723.5, -183, 27.5, 0.4, sec = self.dend[159]) h.pt3dadd(-726.5, -185, 27.5, 2.4, sec = self.dend[159]) h.pt3dadd(-728, -186.5, 27.5, 0.6, sec = self.dend[159]) h.pt3dadd(-731.5, -186.5, 27.5, 0.6, sec = self.dend[159]) h.pt3dadd(-731.5, -188, 27.5, 1.7, sec = self.dend[159]) h.pt3dadd(-733, -188, 27.5, 1.8, sec = self.dend[159]) h.pt3dadd(-735, -189.5, 27.5, 1.1, sec = self.dend[159]) h.pt3dadd(-735.5, -189.5, 27.5, 0.2, sec = self.dend[159]) h.pt3dadd(-737.5, -190.5, 27.5, 1.5, sec = self.dend[159]) h.pt3dadd(-739.5, -190.5, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-741.5, -190.5, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-743.5, -192.5, 27.5, 0.9, sec = self.dend[159]) h.pt3dadd(-744.5, -192.5, 27.5, 1, sec = self.dend[159]) h.pt3dadd(-746, -193, 27.5, 1, sec = self.dend[159]) h.pt3dadd(-746.5, -195, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-749.5, -195, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-751, -195, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-752, -196.5, 27.5, 1.6, sec = self.dend[159]) h.pt3dadd(-753, -197, 27.5, 1.7, sec = self.dend[159]) h.pt3dadd(-755.5, -199, 27.5, 0.8, sec = self.dend[159]) h.pt3dadd(-756, -199, 27.5, 0.2, sec = self.dend[159]) h.pt3dadd(-760, -199, 27.5, 0.2, sec = self.dend[159]) h.pt3dadd(-761.5, -199, 27.5, 1.6, sec = self.dend[159]) h.pt3dadd(-762, -199.5, 27.5, 2.1, sec = self.dend[159]) h.pt3dadd(-764.5, -199.5, 27.5, 0.8, sec = self.dend[159]) h.pt3dadd(-766.5, -199, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-767, -199, 27.5, 0.1, sec = self.dend[159]) h.pt3dadd(-768, -198.5, 30.5, 1.6, sec = self.dend[159]) h.pt3dadd(-769, -198.5, 30.5, 2, sec = self.dend[159]) h.pt3dadd(-771, -197.5, 30.5, 0.3, sec = self.dend[159]) h.pt3dadd(-772, -197, 30.5, 0.3, sec = self.dend[159]) h.pt3dadd(-774, -197, 30.5, 0.3, sec = self.dend[159]) h.pt3dadd(-775, -197, 30.5, 1.1, sec = self.dend[159]) h.pt3dadd(-775.5, -197, 30.5, 1.1, sec = self.dend[159]) h.pt3dadd(-777, -196, 30.5, 0.1, sec = self.dend[159]) h.pt3dadd(-779.5, -194.5, 32, 0.1, sec = self.dend[159]) h.pt3dadd(-782.5, -194, 32, 0.1, sec = self.dend[159]) h.pt3dadd(-785, -193.5, 32, 1.1, sec = self.dend[159]) h.pt3dadd(-789, -193.5, 32, 0.1, sec = self.dend[159]) h.pt3dadd(-790.5, -196, 33.5, 0.1, sec = self.dend[159]) h.pt3dadd(-792.5, -198.5, 35, 0.1, sec = self.dend[159]) h.pt3dadd(-794.5, -198.5, 35, 0.1, sec = self.dend[159]) h.pt3dadd(-793.5, -197, 35, 0.1, sec = self.dend[159]) h.pt3dadd(-792.5, -195.5, 36.5, 0.6, sec = self.dend[159]) h.pt3dadd(-790, -196, 22, 0.6, sec = self.dend[159]) h.pt3dadd(-786, -197, 25, 0.6, sec = self.dend[159]) h.pt3dadd(-787.5, -197.5, 33.5, 1.6, sec = self.dend[159]) h.pt3dadd(-789, -197.5, 35, 1.8, sec = self.dend[159]) h.pt3dadd(-791.5, -194, 17.5, 0.7, sec = self.dend[159]) h.pt3dadd(-793.5, -193.5, 17.5, 0.7, sec = self.dend[159]) h.pt3dadd(-794.5, -192.5, 17.5, 0.6, sec = self.dend[159]) h.pt3dadd(-796, -191, 20.5, 0.9, sec = self.dend[159]) h.pt3dadd(-799, -191, 15, 0.1, sec = self.dend[159]) h.pt3dadd(-801.5, -191, 15, 0.1, sec = self.dend[159]) h.pt3dadd(-803, -190, 17.5, 1.1, sec = self.dend[159]) h.pt3dadd(-805.5, -190, 13.5, 0.1, sec = self.dend[159]) h.pt3dadd(-807.5, -188, 15, 0.1, sec = self.dend[159]) h.pt3dadd(-807.5, -184.5, 15, 0.1, sec = self.dend[159]) h.pt3dadd(-805.5, -184, 16.5, 1.9, sec = self.dend[159]) h.pt3dadd(-805, -183, 17.5, 2.2, sec = self.dend[159]) h.pt3dadd(-803, -182, 16.5, 0.4, sec = self.dend[159]) h.pt3dadd(-801.5, -180.5, 10.5, 0.4, sec = self.dend[159]) h.pt3dadd(-799.5, -178, 17.5, 0.4, sec = self.dend[159]) h.pt3dclear(sec = self.dend[160]) h.pt3dadd(-335.5, -90, -14, 6.9, sec = self.dend[160]) h.pt3dadd(-341.5, -93.5, -16, 5.1, sec = self.dend[160]) h.pt3dadd(-345, -93.5, -16, 5.1, sec = self.dend[160]) h.pt3dadd(-348.5, -95.5, -17.5, 4.8, sec = self.dend[160]) h.pt3dadd(-353, -95.5, -15, 4, sec = self.dend[160]) h.pt3dadd(-356, -97.5, -17.5, 4.1, sec = self.dend[160]) h.pt3dadd(-359.5, -98.5, -16, 3.8, sec = self.dend[160]) h.pt3dadd(-363, -99.5, -16, 3.6, sec = self.dend[160]) h.pt3dadd(-365, -101.5, -16, 3.8, sec = self.dend[160]) h.pt3dadd(-367.5, -102.5, -16, 3.2, sec = self.dend[160]) h.pt3dadd(-369.5, -106.5, -16, 4, sec = self.dend[160]) h.pt3dadd(-372.5, -109, -15, 5.1, sec = self.dend[160]) h.pt3dadd(-375, -110.5, -16, 6, sec = self.dend[160]) h.pt3dadd(-378.5, -114.5, -17.5, 5.7, sec = self.dend[160]) h.pt3dadd(-383, -123.5, -18, 4.8, sec = self.dend[160]) h.pt3dadd(-384, -124.5, -18, 4.8, sec = self.dend[160]) h.pt3dadd(-386.5, -127, -18, 5.7, sec = self.dend[160]) h.pt3dclear(sec = self.dend[161]) h.pt3dadd(-386.5, -127, -18, 5.7, sec = self.dend[161]) h.pt3dadd(-389.5, -126.5, 2.5, 0.5, sec = self.dend[161]) h.pt3dadd(-395.5, -125.5, 2.5, 0.5, sec = self.dend[161]) h.pt3dadd(-401.5, -125.5, 3.5, 4, sec = self.dend[161]) h.pt3dadd(-406, -126.5, 3.5, 0.4, sec = self.dend[161]) h.pt3dadd(-411, -126.5, 3.5, 0.5, sec = self.dend[161]) h.pt3dadd(-414.5, -126.5, 3.5, 2.2, sec = self.dend[161]) h.pt3dadd(-419, -126, 2, 4.9, sec = self.dend[161]) h.pt3dadd(-421.5, -125, 2.5, 1.8, sec = self.dend[161]) h.pt3dadd(-425.5, -122, 3.5, 0.9, sec = self.dend[161]) h.pt3dadd(-428.5, -121, 3.5, 1.2, sec = self.dend[161]) h.pt3dadd(-432, -119.5, 3.5, 1.2, sec = self.dend[161]) h.pt3dadd(-433, -119.5, 3.5, 2.5, sec = self.dend[161]) h.pt3dadd(-435, -118, 3.5, 2.4, sec = self.dend[161]) h.pt3dadd(-438, -116, 4, 1, sec = self.dend[161]) h.pt3dadd(-443.5, -115, 2.5, 1, sec = self.dend[161]) h.pt3dadd(-449, -113.5, 2.5, 1.4, sec = self.dend[161]) h.pt3dadd(-450.5, -113.5, 2.5, 0.7, sec = self.dend[161]) h.pt3dadd(-453.5, -113, 2.5, 0.1, sec = self.dend[161]) h.pt3dadd(-455.5, -113, 2.5, 0.1, sec = self.dend[161]) h.pt3dadd(-456.5, -112.5, 2.5, 1.5, sec = self.dend[161]) h.pt3dadd(-461.5, -109.5, 4.5, 2, sec = self.dend[161]) h.pt3dadd(-463.5, -109.5, 6, 1.2, sec = self.dend[161]) h.pt3dadd(-464.5, -108.5, 7, 0.5, sec = self.dend[161]) h.pt3dadd(-467, -107, 7, 0.6, sec = self.dend[161]) h.pt3dadd(-468, -105.5, 6, 0.7, sec = self.dend[161]) h.pt3dadd(-471, -104.5, 6, 0.7, sec = self.dend[161]) h.pt3dadd(-473, -104.5, 6, 0.7, sec = self.dend[161]) h.pt3dadd(-474, -104.5, 6, 1.9, sec = self.dend[161]) h.pt3dadd(-476, -102.5, 6, 3.6, sec = self.dend[161]) h.pt3dadd(-479.5, -102.5, 6, 1.6, sec = self.dend[161]) h.pt3dadd(-482, -101, 6, 0.4, sec = self.dend[161]) h.pt3dadd(-484.5, -99, 6, 0.4, sec = self.dend[161]) h.pt3dadd(-486.5, -99, 6, 0.4, sec = self.dend[161]) h.pt3dadd(-487, -96.5, 7, 3.1, sec = self.dend[161]) h.pt3dadd(-489.5, -96.5, 6, 0.6, sec = self.dend[161]) h.pt3dadd(-493, -96.5, 6, 0.6, sec = self.dend[161]) h.pt3dadd(-496.5, -96.5, 6, 0.6, sec = self.dend[161]) h.pt3dadd(-495.5, -96, 7, 2.3, sec = self.dend[161]) h.pt3dadd(-498, -96, 7, 3.2, sec = self.dend[161]) h.pt3dadd(-500.5, -96.5, 7, 1.6, sec = self.dend[161]) h.pt3dadd(-501.5, -96, 8, 0.5, sec = self.dend[161]) h.pt3dadd(-502, -96, 8, 0.5, sec = self.dend[161]) h.pt3dadd(-504.5, -96, 8, 1.8, sec = self.dend[161]) h.pt3dadd(-506.5, -95.5, 8, 1.9, sec = self.dend[161]) h.pt3dadd(-508.5, -94, 8, 1.1, sec = self.dend[161]) h.pt3dadd(-510, -94, 8, 0.4, sec = self.dend[161]) h.pt3dadd(-512.5, -94, 8, 0.4, sec = self.dend[161]) h.pt3dadd(-513.5, -94, 8, 2, sec = self.dend[161]) h.pt3dadd(-514.5, -94, 9, 2.4, sec = self.dend[161]) h.pt3dadd(-517, -94, 9, 1.3, sec = self.dend[161]) h.pt3dadd(-518.5, -95, 9, 0.6, sec = self.dend[161]) h.pt3dadd(-520.5, -95.5, 8, 0.3, sec = self.dend[161]) h.pt3dadd(-522, -95.5, 7, 0.3, sec = self.dend[161]) h.pt3dadd(-524.5, -94.5, 9, 0.3, sec = self.dend[161]) h.pt3dadd(-528, -94, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-529, -94, 9, 2.2, sec = self.dend[161]) h.pt3dadd(-531.5, -94, 10.5, 2.5, sec = self.dend[161]) h.pt3dadd(-534, -93, 10.5, 1.3, sec = self.dend[161]) h.pt3dadd(-535, -92.5, 10.5, 0.2, sec = self.dend[161]) h.pt3dadd(-538, -91, 10.5, 0.2, sec = self.dend[161]) h.pt3dadd(-538.5, -91, 10.5, 1.8, sec = self.dend[161]) h.pt3dadd(-540.5, -90.5, 11.5, 2.8, sec = self.dend[161]) h.pt3dadd(-542.5, -88.5, 11.5, 1, sec = self.dend[161]) h.pt3dadd(-545.5, -87, 10.5, 0.1, sec = self.dend[161]) h.pt3dadd(-547.5, -87, 10.5, 0.1, sec = self.dend[161]) h.pt3dadd(-550.5, -86.5, 11.5, 0.1, sec = self.dend[161]) h.pt3dadd(-553, -83.5, 11.5, 0.1, sec = self.dend[161]) h.pt3dadd(-554, -83.5, 11.5, 0.1, sec = self.dend[161]) h.pt3dadd(-556, -84, 13.5, 3.8, sec = self.dend[161]) h.pt3dadd(-557, -84, 11.5, 4.1, sec = self.dend[161]) h.pt3dadd(-559.5, -84.5, 11.5, 1.5, sec = self.dend[161]) h.pt3dadd(-561.5, -83.5, 11.5, 0.3, sec = self.dend[161]) h.pt3dadd(-565, -83, 11.5, 0.3, sec = self.dend[161]) h.pt3dadd(-567.5, -82.5, 11.5, 2, sec = self.dend[161]) h.pt3dadd(-570, -82, 11.5, 0.3, sec = self.dend[161]) h.pt3dadd(-573, -80, 11.5, 0.3, sec = self.dend[161]) h.pt3dadd(-573, -78.5, 11.5, 0.3, sec = self.dend[161]) h.pt3dadd(-575.5, -78.5, 10.5, 2.5, sec = self.dend[161]) h.pt3dadd(-578, -78.5, 11.5, 0.6, sec = self.dend[161]) h.pt3dadd(-580.5, -77, 11.5, 1.1, sec = self.dend[161]) h.pt3dadd(-584.5, -75, 11.5, 0.7, sec = self.dend[161]) h.pt3dadd(-586.5, -75, 11.5, 1.8, sec = self.dend[161]) h.pt3dadd(-587.5, -75, 11.5, 2.4, sec = self.dend[161]) h.pt3dadd(-590, -75, 11.5, 1.3, sec = self.dend[161]) h.pt3dadd(-591, -76.5, 11.5, 0.5, sec = self.dend[161]) h.pt3dadd(-596, -76.5, 11.5, 0.4, sec = self.dend[161]) h.pt3dadd(-597, -76.5, 11.5, 1.6, sec = self.dend[161]) h.pt3dadd(-598.5, -78, 12.5, 2.7, sec = self.dend[161]) h.pt3dadd(-601, -79.5, 11.5, 1.2, sec = self.dend[161]) h.pt3dadd(-603.5, -80, 11.5, 0.5, sec = self.dend[161]) h.pt3dadd(-605.5, -81, 11.5, 0.5, sec = self.dend[161]) h.pt3dadd(-606.5, -81, 10.5, 1.4, sec = self.dend[161]) h.pt3dadd(-610, -83.5, 10.5, 2.5, sec = self.dend[161]) h.pt3dadd(-610.5, -83.5, 10.5, 1.2, sec = self.dend[161]) h.pt3dadd(-611, -85, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-614.5, -87, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-615.5, -88, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-617, -89.5, 10.5, 1.7, sec = self.dend[161]) h.pt3dadd(-618, -89.5, 10.5, 2.5, sec = self.dend[161]) h.pt3dadd(-620, -89.5, 10.5, 1.3, sec = self.dend[161]) h.pt3dadd(-621.5, -89.5, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-624, -89.5, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-625.5, -89, 10.5, 0.6, sec = self.dend[161]) h.pt3dadd(-627, -89, 10.5, 1.7, sec = self.dend[161]) h.pt3dadd(-628.5, -89, 12.5, 2.7, sec = self.dend[161]) h.pt3dadd(-631, -89, 10.5, 1.3, sec = self.dend[161]) h.pt3dadd(-631.5, -88, 10.5, 0.5, sec = self.dend[161]) h.pt3dadd(-635.5, -84, 10.5, 0.5, sec = self.dend[161]) h.pt3dadd(-636, -85, 11.5, 0.5, sec = self.dend[161]) h.pt3dadd(-639, -85, 9, 0.5, sec = self.dend[161]) h.pt3dadd(-641, -85, 10.5, 2.1, sec = self.dend[161]) h.pt3dadd(-641.5, -83.5, 9, 3.8, sec = self.dend[161]) h.pt3dadd(-642, -83.5, 10.5, 1.9, sec = self.dend[161]) h.pt3dadd(-645, -83.5, 9, 0.4, sec = self.dend[161]) h.pt3dadd(-647.5, -83.5, 7, 0.5, sec = self.dend[161]) h.pt3dadd(-648.5, -83.5, 8, 0.5, sec = self.dend[161]) h.pt3dadd(-649, -83.5, 8, 1.6, sec = self.dend[161]) h.pt3dadd(-651, -83.5, 7, 1.7, sec = self.dend[161]) h.pt3dadd(-652.5, -82.5, 7, 0.8, sec = self.dend[161]) h.pt3dadd(-654.5, -81.5, 7, 0.6, sec = self.dend[161]) h.pt3dadd(-655, -79.5, 7, 0.6, sec = self.dend[161]) h.pt3dadd(-658, -78.5, 7, 0.6, sec = self.dend[161]) h.pt3dadd(-658.5, -78.5, 8, 1.4, sec = self.dend[161]) h.pt3dadd(-661, -78.5, 8, 2.6, sec = self.dend[161]) h.pt3dadd(-662, -78, 8, 1.1, sec = self.dend[161]) h.pt3dadd(-663.5, -78, 7, 0.4, sec = self.dend[161]) h.pt3dadd(-666.5, -78, 7, 0.4, sec = self.dend[161]) h.pt3dadd(-670, -78, 7, 0.4, sec = self.dend[161]) h.pt3dadd(-671.5, -78, 7, 0.4, sec = self.dend[161]) h.pt3dadd(-672.5, -78.5, 7, 1.6, sec = self.dend[161]) h.pt3dadd(-675.5, -78.5, 7, 2.5, sec = self.dend[161]) h.pt3dadd(-677, -78.5, 7, 0.9, sec = self.dend[161]) h.pt3dadd(-677.5, -78.5, 7, 0.3, sec = self.dend[161]) h.pt3dadd(-680.5, -78.5, 7, 0.3, sec = self.dend[161]) h.pt3dadd(-683, -78.5, 7, 0.3, sec = self.dend[161]) h.pt3dadd(-684.5, -78.5, 7, 0.3, sec = self.dend[161]) h.pt3dadd(-688, -76, 8, 0.2, sec = self.dend[161]) h.pt3dadd(-689.5, -76, 9, 1.2, sec = self.dend[161]) h.pt3dadd(-691, -76, 9, 1.4, sec = self.dend[161]) h.pt3dadd(-693.5, -76, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-695.5, -76, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-697.5, -76, 8, 0.1, sec = self.dend[161]) h.pt3dadd(-700, -76, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-700.5, -76, 9, 1.7, sec = self.dend[161]) h.pt3dadd(-701, -76, 9, 2.7, sec = self.dend[161]) h.pt3dadd(-702.5, -76, 9, 1.4, sec = self.dend[161]) h.pt3dadd(-704.5, -76, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-707.5, -74, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-709, -74, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-711, -74, 9, 0.1, sec = self.dend[161]) h.pt3dadd(-713, -74, 9, 1.4, sec = self.dend[161]) h.pt3dadd(-714, -74, 10.5, 1.3, sec = self.dend[161]) h.pt3dadd(-716, -74, 10.5, 1.2, sec = self.dend[161]) h.pt3dadd(-718, -74, 10.5, 0.4, sec = self.dend[161]) h.pt3dadd(-720.5, -74, 10.5, 0.5, sec = self.dend[161]) h.pt3dadd(-722, -74, 10.5, 0.5, sec = self.dend[161]) h.pt3dadd(-726, -73.5, 10.5, 2, sec = self.dend[161]) h.pt3dadd(-727.5, -73.5, 10.5, 0.2, sec = self.dend[161]) h.pt3dadd(-728.5, -73, 10.5, 0.1, sec = self.dend[161]) h.pt3dadd(-731, -73, 10.5, 2, sec = self.dend[161]) h.pt3dadd(-733, -72.5, 10.5, 0.1, sec = self.dend[161]) h.pt3dadd(-735.5, -71.5, 10.5, 0.1, sec = self.dend[161]) h.pt3dadd(-737.5, -69.5, 11.5, 0.6, sec = self.dend[161]) h.pt3dclear(sec = self.dend[162]) h.pt3dadd(-386.5, -127, -18, 5.7, sec = self.dend[162]) h.pt3dadd(-387, -131.5, -18, 4.8, sec = self.dend[162]) h.pt3dadd(-390, -133.5, -18, 4.3, sec = self.dend[162]) h.pt3dadd(-391.5, -135.5, -18, 3.8, sec = self.dend[162]) h.pt3dadd(-394, -137.5, -18, 3.8, sec = self.dend[162]) h.pt3dadd(-395.5, -141, -18, 4.3, sec = self.dend[162]) h.pt3dadd(-397, -142.5, -18, 3.5, sec = self.dend[162]) h.pt3dadd(-399, -145, -19.5, 2.5, sec = self.dend[162]) h.pt3dadd(-402, -145.5, -19.5, 2.5, sec = self.dend[162]) h.pt3dadd(-404, -147.5, -19.5, 2.5, sec = self.dend[162]) h.pt3dadd(-405.5, -148.5, -19.5, 2.5, sec = self.dend[162]) h.pt3dadd(-408, -150.5, -19.5, 2.9, sec = self.dend[162]) h.pt3dadd(-410.5, -151.5, -19.5, 3.2, sec = self.dend[162]) h.pt3dadd(-414, -152.5, -19.5, 3.2, sec = self.dend[162]) h.pt3dadd(-416, -156, -19.5, 3.6, sec = self.dend[162]) h.pt3dadd(-419, -156, -19, 3.6, sec = self.dend[162]) h.pt3dadd(-421.5, -159, -19, 3.5, sec = self.dend[162]) h.pt3dadd(-423.5, -160, -18, 2.9, sec = self.dend[162]) h.pt3dadd(-426, -163, -18, 2.9, sec = self.dend[162]) h.pt3dadd(-428.5, -165.5, -18, 2.1, sec = self.dend[162]) h.pt3dadd(-430.5, -166.5, -18, 2.3, sec = self.dend[162]) h.pt3dadd(-431.5, -170.5, -18, 3.4, sec = self.dend[162]) h.pt3dadd(-435, -173, -19, 3.8, sec = self.dend[162]) h.pt3dadd(-439.5, -178, -19, 4.4, sec = self.dend[162]) h.pt3dadd(-444, -180.5, -19, 4.7, sec = self.dend[162]) h.pt3dadd(-447.5, -183, -19, 4.1, sec = self.dend[162]) h.pt3dadd(-451, -185, -19, 4.1, sec = self.dend[162]) h.pt3dadd(-457, -188, -19.5, 2, sec = self.dend[162]) h.pt3dadd(-460, -188, -19.5, 2, sec = self.dend[162]) h.pt3dadd(-462, -190, -19.5, 2.3, sec = self.dend[162]) h.pt3dadd(-466, -190.5, -19.5, 2.3, sec = self.dend[162]) h.pt3dadd(-468.5, -191.5, -19.5, 2.1, sec = self.dend[162]) h.pt3dadd(-470, -191.5, -19.5, 2.9, sec = self.dend[162]) h.pt3dadd(-472, -192, -19.5, 3.4, sec = self.dend[162]) h.pt3dadd(-474.5, -192.5, -19, 2.6, sec = self.dend[162]) h.pt3dadd(-477, -194.5, -19.5, 3.4, sec = self.dend[162]) h.pt3dadd(-481, -196.5, -17.5, 4.7, sec = self.dend[162]) h.pt3dclear(sec = self.dend[163]) h.pt3dadd(-481, -196.5, -17.5, 4.7, sec = self.dend[163]) h.pt3dadd(-488.5, -196.5, -4, 0.7, sec = self.dend[163]) h.pt3dadd(-493.5, -196, -4, 0.7, sec = self.dend[163]) h.pt3dadd(-495, -196, -4, 0.1, sec = self.dend[163]) h.pt3dadd(-500, -196, -3.5, 2.3, sec = self.dend[163]) h.pt3dadd(-503.5, -196, -4.5, 0.1, sec = self.dend[163]) h.pt3dadd(-507.5, -196, -4.5, 0.1, sec = self.dend[163]) h.pt3dadd(-509, -196, -5.5, 0.1, sec = self.dend[163]) h.pt3dadd(-510.5, -196, -3.5, 2.8, sec = self.dend[163]) h.pt3dadd(-514.5, -196, -3.5, 1.2, sec = self.dend[163]) h.pt3dadd(-517, -197.5, -2, 0.1, sec = self.dend[163]) h.pt3dadd(-521, -197.5, -2.5, 0.1, sec = self.dend[163]) h.pt3dadd(-523, -197.5, -1.5, 1.6, sec = self.dend[163]) h.pt3dadd(-526.5, -199, -2, 2, sec = self.dend[163]) h.pt3dadd(-528.5, -199, -2, 0.5, sec = self.dend[163]) h.pt3dadd(-533.5, -199.5, -1.5, 0.4, sec = self.dend[163]) h.pt3dclear(sec = self.dend[164]) h.pt3dadd(-481, -196.5, -17.5, 4.7, sec = self.dend[164]) h.pt3dadd(-486.5, -197, -20, 3.3, sec = self.dend[164]) h.pt3dadd(-493.5, -199, -18, 2.8, sec = self.dend[164]) h.pt3dadd(-502, -199.5, -19, 3.4, sec = self.dend[164]) h.pt3dadd(-505, -199.5, -19.5, 3.4, sec = self.dend[164]) h.pt3dadd(-509, -202.5, -17.5, 5.4, sec = self.dend[164]) h.pt3dclear(sec = self.dend[165]) h.pt3dadd(-509, -202.5, -17.5, 5.4, sec = self.dend[165]) h.pt3dadd(-512.5, -206.5, -5.5, 1.6, sec = self.dend[165]) h.pt3dadd(-512.5, -208.5, -7.5, 2.1, sec = self.dend[165]) h.pt3dadd(-512.5, -211.5, -6.5, 2.5, sec = self.dend[165]) h.pt3dadd(-512.5, -213.5, -6.5, 2.7, sec = self.dend[165]) h.pt3dadd(-512.5, -215.5, -6.5, 2.8, sec = self.dend[165]) h.pt3dadd(-513, -218, -6, 3.3, sec = self.dend[165]) h.pt3dadd(-513, -219.5, -6.5, 1.9, sec = self.dend[165]) h.pt3dadd(-515, -221.5, -6.5, 1.6, sec = self.dend[165]) h.pt3dadd(-515.5, -223, -5.5, 2, sec = self.dend[165]) h.pt3dadd(-516, -225.5, -10, 2, sec = self.dend[165]) h.pt3dadd(-515.5, -228.5, -10, 2, sec = self.dend[165]) h.pt3dadd(-515.5, -231.5, -11, 2.5, sec = self.dend[165]) h.pt3dclear(sec = self.dend[166]) h.pt3dadd(-515.5, -231.5, -11, 2.5, sec = self.dend[166]) h.pt3dadd(-515.5, -234.5, -11, 3.7, sec = self.dend[166]) h.pt3dadd(-515.5, -236.5, -11, 2.2, sec = self.dend[166]) h.pt3dadd(-515.5, -238.5, -11, 1.8, sec = self.dend[166]) h.pt3dadd(-515, -240, -11, 1.6, sec = self.dend[166]) h.pt3dadd(-517, -240, -11, 1.6, sec = self.dend[166]) h.pt3dadd(-517, -242, -17.5, 3.1, sec = self.dend[166]) h.pt3dadd(-517.5, -244, -11, 4, sec = self.dend[166]) h.pt3dadd(-517.5, -245.5, -17.5, 4, sec = self.dend[166]) h.pt3dadd(-519, -245.5, -17.5, 2.9, sec = self.dend[166]) h.pt3dadd(-520, -247, -17.5, 2.9, sec = self.dend[166]) h.pt3dadd(-520, -248, -17.5, 2, sec = self.dend[166]) h.pt3dadd(-520.5, -249.5, -17.5, 1.6, sec = self.dend[166]) h.pt3dadd(-521.5, -250.5, -17.5, 1.5, sec = self.dend[166]) h.pt3dadd(-521.5, -251.5, -17.5, 1.5, sec = self.dend[166]) h.pt3dadd(-521, -253, -17.5, 1.7, sec = self.dend[166]) h.pt3dadd(-524, -253, -23.5, 1.6, sec = self.dend[166]) h.pt3dadd(-523.5, -255.5, -23.5, 1.9, sec = self.dend[166]) h.pt3dadd(-523.5, -257, -30, 1.8, sec = self.dend[166]) h.pt3dadd(-523.5, -258.5, -30, 1.8, sec = self.dend[166]) h.pt3dadd(-523.5, -260.5, -30, 2.9, sec = self.dend[166]) h.pt3dadd(-524.5, -263.5, -30, 3.7, sec = self.dend[166]) h.pt3dadd(-524.5, -265.5, -30, 4.1, sec = self.dend[166]) h.pt3dadd(-525, -268.5, -30, 3.8, sec = self.dend[166]) h.pt3dadd(-525.5, -270, -36, 3.2, sec = self.dend[166]) h.pt3dadd(-525.5, -271.5, -36, 2.3, sec = self.dend[166]) h.pt3dadd(-527, -273, -36, 1.6, sec = self.dend[166]) h.pt3dadd(-529, -274, -36, 1.4, sec = self.dend[166]) h.pt3dadd(-532, -276, -36, 1, sec = self.dend[166]) h.pt3dadd(-534, -279.5, -30, 1.9, sec = self.dend[166]) h.pt3dadd(-535.5, -282, -30, 1.9, sec = self.dend[166]) h.pt3dadd(-536.5, -284, -34, 1.9, sec = self.dend[166]) h.pt3dadd(-536.5, -286, -34, 3.3, sec = self.dend[166]) h.pt3dadd(-538.5, -286.5, -32, 4.3, sec = self.dend[166]) h.pt3dadd(-540, -290.5, -32, 2.4, sec = self.dend[166]) h.pt3dadd(-541, -293, -34, 1.7, sec = self.dend[166]) h.pt3dadd(-542.5, -295.5, -34, 1.5, sec = self.dend[166]) h.pt3dadd(-544, -297.5, -36, 1.7, sec = self.dend[166]) h.pt3dadd(-545, -300, -37.5, 2.4, sec = self.dend[166]) h.pt3dadd(-549.5, -302, -37.5, 1.9, sec = self.dend[166]) h.pt3dadd(-552, -303, -39.5, 1.4, sec = self.dend[166]) h.pt3dadd(-555, -303, -39.5, 1.3, sec = self.dend[166]) h.pt3dadd(-556, -304, -39.5, 1.3, sec = self.dend[166]) h.pt3dadd(-556.5, -305, -39.5, 1.3, sec = self.dend[166]) h.pt3dadd(-559, -307, -39.5, 2.8, sec = self.dend[166]) h.pt3dadd(-561.5, -307, -39.5, 4, sec = self.dend[166]) h.pt3dadd(-565.5, -307, -39.5, 1.7, sec = self.dend[166]) h.pt3dadd(-567.5, -306.5, -39.5, 1.1, sec = self.dend[166]) h.pt3dadd(-569.5, -306.5, -39.5, 1.5, sec = self.dend[166]) h.pt3dadd(-572.5, -306.5, -39.5, 1.6, sec = self.dend[166]) h.pt3dadd(-574, -306.5, -39.5, 1.6, sec = self.dend[166]) h.pt3dadd(-576, -306.5, -37.5, 2.2, sec = self.dend[166]) h.pt3dadd(-578.5, -308.5, -41.5, 2.4, sec = self.dend[166]) h.pt3dadd(-582, -308.5, -41.5, 1.7, sec = self.dend[166]) h.pt3dadd(-585, -308.5, -41.5, 1.3, sec = self.dend[166]) h.pt3dadd(-587.5, -308.5, -41.5, 1.1, sec = self.dend[166]) h.pt3dadd(-589.5, -308, -36, 2.8, sec = self.dend[166]) h.pt3dadd(-592.5, -308, -36, 3.1, sec = self.dend[166]) h.pt3dadd(-595.5, -308, -36, 1.9, sec = self.dend[166]) h.pt3dadd(-599, -307.5, -36, 1.4, sec = self.dend[166]) h.pt3dadd(-602.5, -306, -36, 1.4, sec = self.dend[166]) h.pt3dadd(-603.5, -306, -36, 1.1, sec = self.dend[166]) h.pt3dadd(-606, -306, -34, 1.1, sec = self.dend[166]) h.pt3dadd(-608.5, -306, -34, 1.1, sec = self.dend[166]) h.pt3dadd(-611.5, -306, -32, 1.8, sec = self.dend[166]) h.pt3dadd(-613.5, -306, -36, 2, sec = self.dend[166]) h.pt3dadd(-617.5, -306.5, -37.5, 1.3, sec = self.dend[166]) h.pt3dadd(-620.5, -306.5, -37.5, 1, sec = self.dend[166]) h.pt3dadd(-623.5, -306.5, -37.5, 1, sec = self.dend[166]) h.pt3dadd(-626.5, -306.5, -34, 2.8, sec = self.dend[166]) h.pt3dadd(-629.5, -306.5, -34, 0.5, sec = self.dend[166]) h.pt3dadd(-631.5, -309.5, -32, 0.7, sec = self.dend[166]) h.pt3dadd(-635, -309.5, -32, 0.7, sec = self.dend[166]) h.pt3dadd(-637.5, -310, -32, 2.1, sec = self.dend[166]) h.pt3dadd(-640.5, -312.5, -36, 3.2, sec = self.dend[166]) h.pt3dadd(-641.5, -312.5, -36, 2.1, sec = self.dend[166]) h.pt3dadd(-644.5, -313.5, -36, 1, sec = self.dend[166]) h.pt3dadd(-648, -315, -36, 1, sec = self.dend[166]) h.pt3dadd(-652, -313, -34, 1, sec = self.dend[166]) h.pt3dadd(-655, -313, -34, 1, sec = self.dend[166]) h.pt3dadd(-658, -313.5, -37.5, 2.8, sec = self.dend[166]) h.pt3dadd(-660.5, -314.5, -36, 4, sec = self.dend[166]) h.pt3dadd(-664, -315.5, -39.5, 1.9, sec = self.dend[166]) h.pt3dadd(-666, -315.5, -39.5, 1.1, sec = self.dend[166]) h.pt3dadd(-671, -317.5, -37.5, 0.7, sec = self.dend[166]) h.pt3dadd(-674.5, -317.5, -36, 0.7, sec = self.dend[166]) h.pt3dadd(-677, -319.5, -39.5, 0.7, sec = self.dend[166]) h.pt3dadd(-678.5, -319.5, -39.5, 1.9, sec = self.dend[166]) h.pt3dadd(-681, -321.5, -39.5, 3.1, sec = self.dend[166]) h.pt3dadd(-682.5, -327.5, -45.5, 1.4, sec = self.dend[166]) h.pt3dadd(-683.5, -329, -43, 1.4, sec = self.dend[166]) h.pt3dadd(-684.5, -329.5, -45.5, 0.4, sec = self.dend[166]) h.pt3dadd(-685, -330.5, -48.5, 0.1, sec = self.dend[166]) h.pt3dadd(-686, -332.5, -48.5, 0.1, sec = self.dend[166]) h.pt3dadd(-687, -333, -51.5, 1.9, sec = self.dend[166]) h.pt3dadd(-687, -335.5, -51.5, 1.9, sec = self.dend[166]) h.pt3dadd(-686, -336.5, -51.5, 1.9, sec = self.dend[166]) h.pt3dadd(-688.5, -337, -51.5, 0.7, sec = self.dend[166]) h.pt3dadd(-690, -338.5, -54.5, 1.1, sec = self.dend[166]) h.pt3dadd(-692, -339.5, -54.5, 1.3, sec = self.dend[166]) h.pt3dadd(-693, -341.5, -54.5, 1.6, sec = self.dend[166]) h.pt3dadd(-694, -341.5, -54.5, 2.1, sec = self.dend[166]) h.pt3dadd(-694.5, -344.5, -54.5, 1.5, sec = self.dend[166]) h.pt3dadd(-694.5, -346.5, -57.5, 1.2, sec = self.dend[166]) h.pt3dadd(-695, -347.5, -63.5, 0.2, sec = self.dend[166]) h.pt3dadd(-699, -347.5, -60.5, 0.2, sec = self.dend[166]) h.pt3dadd(-698.5, -350, -60.5, 0.1, sec = self.dend[166]) h.pt3dadd(-698.5, -351.5, -63.5, 1.7, sec = self.dend[166]) h.pt3dadd(-699, -353, -60.5, 2.3, sec = self.dend[166]) h.pt3dadd(-700.5, -355.5, -63.5, 1.4, sec = self.dend[166]) h.pt3dadd(-701.5, -356, -63.5, 0.4, sec = self.dend[166]) h.pt3dadd(-703, -357.5, -63.5, 0.4, sec = self.dend[166]) h.pt3dadd(-704, -359, -63.5, 0.4, sec = self.dend[166]) h.pt3dadd(-707.5, -359.5, -69, 0.4, sec = self.dend[166]) h.pt3dadd(-707.5, -360, -66.5, 0.5, sec = self.dend[166]) h.pt3dadd(-708.5, -365, -69, 0.6, sec = self.dend[166]) h.pt3dadd(-712, -365, -71, 0.3, sec = self.dend[166]) h.pt3dadd(-714.5, -365, -71, 0.3, sec = self.dend[166]) h.pt3dadd(-715, -367, -66.5, 0.7, sec = self.dend[166]) h.pt3dadd(-715.5, -369, -69, 1.3, sec = self.dend[166]) h.pt3dadd(-716, -370.5, -71, 1.7, sec = self.dend[166]) h.pt3dadd(-717.5, -371, -76, 2.3, sec = self.dend[166]) h.pt3dadd(-720, -372.5, -76, 1.2, sec = self.dend[166]) h.pt3dadd(-722, -374.5, -76, 0.7, sec = self.dend[166]) h.pt3dadd(-722.5, -374.5, -78.5, 0.3, sec = self.dend[166]) h.pt3dadd(-726, -374.5, -78.5, 0.3, sec = self.dend[166]) h.pt3dadd(-727, -375.5, -78.5, 1.1, sec = self.dend[166]) h.pt3dadd(-727.5, -376.5, -78.5, 1.6, sec = self.dend[166]) h.pt3dadd(-727.5, -379, -76, 2.5, sec = self.dend[166]) h.pt3dadd(-727.5, -381.5, -80.5, 1.6, sec = self.dend[166]) h.pt3dadd(-730.5, -381.5, -80.5, 0.8, sec = self.dend[166]) h.pt3dadd(-732.5, -382, -80.5, 1, sec = self.dend[166]) h.pt3dadd(-734.5, -383, -80.5, 1.6, sec = self.dend[166]) h.pt3dadd(-736, -384.5, -85.5, 2.7, sec = self.dend[166]) h.pt3dadd(-738, -385, -85.5, 1.5, sec = self.dend[166]) h.pt3dadd(-740.5, -386, -80.5, 0.4, sec = self.dend[166]) h.pt3dadd(-741.5, -388.5, -83, 0.4, sec = self.dend[166]) h.pt3dadd(-742.5, -389, -80.5, 1.5, sec = self.dend[166]) h.pt3dadd(-742.5, -390.5, -80.5, 1.7, sec = self.dend[166]) h.pt3dadd(-744, -393, -80.5, 1.7, sec = self.dend[166]) h.pt3dadd(-743, -393, -85.5, 0.6, sec = self.dend[166]) h.pt3dadd(-744, -394.5, -83, 0.6, sec = self.dend[166]) h.pt3dadd(-744, -397, -83, 0.6, sec = self.dend[166]) h.pt3dadd(-744.5, -398.5, -88, 2.1, sec = self.dend[166]) h.pt3dadd(-746, -399, -85.5, 3, sec = self.dend[166]) h.pt3dadd(-746, -401.5, -85.5, 1.4, sec = self.dend[166]) h.pt3dadd(-746, -403.5, -90, 0.9, sec = self.dend[166]) h.pt3dadd(-745.5, -404, -92.5, 0.9, sec = self.dend[166]) h.pt3dadd(-745.5, -406, -92.5, 0.9, sec = self.dend[166]) h.pt3dadd(-747, -406, -92.5, 1.6, sec = self.dend[166]) h.pt3dadd(-749, -406, -90, 1.7, sec = self.dend[166]) h.pt3dadd(-751.5, -407.5, -92.5, 1.9, sec = self.dend[166]) h.pt3dadd(-753.5, -409, -97.5, 0.8, sec = self.dend[166]) h.pt3dclear(sec = self.dend[167]) h.pt3dadd(-515.5, -231.5, -11, 2.5, sec = self.dend[167]) h.pt3dadd(-517, -232, -11, 0.1, sec = self.dend[167]) h.pt3dadd(-519, -233, -11, 1.4, sec = self.dend[167]) h.pt3dadd(-519.5, -233.5, -10, 1, sec = self.dend[167]) h.pt3dadd(-520.5, -234, -10, 0.1, sec = self.dend[167]) h.pt3dadd(-522, -234.5, -10, 1.6, sec = self.dend[167]) h.pt3dadd(-522.5, -235.5, -10, 2.3, sec = self.dend[167]) h.pt3dadd(-524, -236.5, -9, 1, sec = self.dend[167]) h.pt3dadd(-524.5, -237.5, -8, 0.3, sec = self.dend[167]) h.pt3dadd(-525.5, -240, -9, 0.3, sec = self.dend[167]) h.pt3dadd(-525.5, -242, -8, 1.3, sec = self.dend[167]) h.pt3dadd(-525.5, -244.5, -8, 1.8, sec = self.dend[167]) h.pt3dadd(-526, -245.5, -8, 0.9, sec = self.dend[167]) h.pt3dadd(-527, -248, -8, 0.1, sec = self.dend[167]) h.pt3dadd(-528.5, -251.5, -8, 0.1, sec = self.dend[167]) h.pt3dadd(-530, -253.5, -8, 1.5, sec = self.dend[167]) h.pt3dadd(-530, -253.5, -6.5, 2.4, sec = self.dend[167]) h.pt3dadd(-531.5, -254.5, -6.5, 0.8, sec = self.dend[167]) h.pt3dadd(-532.5, -254.5, -6.5, 0.5, sec = self.dend[167]) h.pt3dadd(-534, -256.5, -6.5, 0.3, sec = self.dend[167]) h.pt3dadd(-536.5, -257.5, -6.5, 0.1, sec = self.dend[167]) h.pt3dadd(-535.5, -259.5, -6.5, 0.1, sec = self.dend[167]) h.pt3dadd(-535.5, -261, -5.5, 0.9, sec = self.dend[167]) h.pt3dadd(-536, -262.5, -5.5, 2.4, sec = self.dend[167]) h.pt3dadd(-537.5, -264.5, -4.5, 0.5, sec = self.dend[167]) h.pt3dadd(-542, -266.5, -4.5, 0.3, sec = self.dend[167]) h.pt3dadd(-543.5, -266.5, -4.5, 0.7, sec = self.dend[167]) h.pt3dadd(-545, -266.5, -4.5, 1.2, sec = self.dend[167]) h.pt3dadd(-546.5, -266.5, -4.5, 0.8, sec = self.dend[167]) h.pt3dadd(-548.5, -267, -4.5, 0.4, sec = self.dend[167]) h.pt3dadd(-549.5, -267, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-550.5, -267.5, -3.5, 1.6, sec = self.dend[167]) h.pt3dadd(-552.5, -267.5, -3.5, 3.2, sec = self.dend[167]) h.pt3dadd(-555, -269.5, -3.5, 0.2, sec = self.dend[167]) h.pt3dadd(-557.5, -270.5, -3.5, 0.3, sec = self.dend[167]) h.pt3dadd(-559.5, -270.5, -2, 0.5, sec = self.dend[167]) h.pt3dadd(-560, -272.5, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-564, -274.5, -1, 0.1, sec = self.dend[167]) h.pt3dadd(-565, -274.5, -1, 2.2, sec = self.dend[167]) h.pt3dadd(-567, -274.5, -2, 2.8, sec = self.dend[167]) h.pt3dadd(-569, -274.5, -2, 1.4, sec = self.dend[167]) h.pt3dadd(-570, -274.5, -2, 0.5, sec = self.dend[167]) h.pt3dadd(-571.5, -277.5, -2, 0.6, sec = self.dend[167]) h.pt3dadd(-572, -277.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-572, -280, -1, 0.6, sec = self.dend[167]) h.pt3dadd(-574, -281.5, -3.5, 1.9, sec = self.dend[167]) h.pt3dadd(-575, -283, -3.5, 1.2, sec = self.dend[167]) h.pt3dadd(-575.5, -283, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-578, -287.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-579, -287.5, -2, 0.2, sec = self.dend[167]) h.pt3dadd(-581.5, -288.5, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-582.5, -289.5, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-586, -290.5, -2, 1.7, sec = self.dend[167]) h.pt3dadd(-586.5, -292.5, -4.5, 0.1, sec = self.dend[167]) h.pt3dadd(-587.5, -293.5, -2, 1, sec = self.dend[167]) h.pt3dadd(-590.5, -297.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-590.5, -298.5, -2, 0.4, sec = self.dend[167]) h.pt3dadd(-590.5, -301, -3.5, 1.2, sec = self.dend[167]) h.pt3dadd(-591.5, -302, -3.5, 0.5, sec = self.dend[167]) h.pt3dadd(-592, -302.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-591, -307.5, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-591.5, -307.5, -3.5, 1.2, sec = self.dend[167]) h.pt3dadd(-590, -310, -3.5, 1.1, sec = self.dend[167]) h.pt3dadd(-590, -312.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-591, -314.5, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-591, -315, -1, 0.6, sec = self.dend[167]) h.pt3dadd(-591, -318, -2, 1.2, sec = self.dend[167]) h.pt3dadd(-591, -319, -2, 0.5, sec = self.dend[167]) h.pt3dadd(-591, -321, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-592, -322, -2, 0.1, sec = self.dend[167]) h.pt3dadd(-592.5, -323.5, -3.5, 1.2, sec = self.dend[167]) h.pt3dadd(-592.5, -325.5, -2, 0.7, sec = self.dend[167]) h.pt3dadd(-592.5, -326, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-592, -331.5, -3.5, 0.1, sec = self.dend[167]) h.pt3dadd(-592, -331, -5.5, 1.6, sec = self.dend[167]) h.pt3dadd(-592, -333.5, -5.5, 1.9, sec = self.dend[167]) h.pt3dadd(-592.5, -334, -5.5, 0.2, sec = self.dend[167]) h.pt3dadd(-592.5, -336.5, -5.5, 0.1, sec = self.dend[167]) h.pt3dadd(-593, -337.5, -4.5, 1.6, sec = self.dend[167]) h.pt3dadd(-594.5, -338.5, -5.5, 0.1, sec = self.dend[167]) h.pt3dadd(-594.5, -340, -4.5, 0.1, sec = self.dend[167]) h.pt3dadd(-594.5, -341.5, -2, 1.3, sec = self.dend[167]) h.pt3dadd(-595.5, -344.5, -6.5, 0.1, sec = self.dend[167]) h.pt3dadd(-595, -345, -3.5, 0.5, sec = self.dend[167]) h.pt3dadd(-595.5, -345.5, -4.5, 0.1, sec = self.dend[167]) h.pt3dclear(sec = self.dend[168]) h.pt3dadd(-509, -202.5, -17.5, 5.4, sec = self.dend[168]) h.pt3dadd(-514, -201.5, -17.5, 1.9, sec = self.dend[168]) h.pt3dadd(-518, -202.5, -17.5, 2.1, sec = self.dend[168]) h.pt3dadd(-522, -203, -17.5, 1.7, sec = self.dend[168]) h.pt3dadd(-523.5, -203, -17.5, 2.2, sec = self.dend[168]) h.pt3dadd(-526, -203, -17.5, 3.4, sec = self.dend[168]) h.pt3dadd(-530, -205, -18, 1.9, sec = self.dend[168]) h.pt3dadd(-531.5, -205, -18, 1.9, sec = self.dend[168]) h.pt3dadd(-533.5, -205, -17.5, 2.6, sec = self.dend[168]) h.pt3dadd(-535, -205, -17.5, 1.6, sec = self.dend[168]) h.pt3dadd(-537, -205, -17.5, 1.3, sec = self.dend[168]) h.pt3dadd(-538.5, -205, -17, 1.3, sec = self.dend[168]) h.pt3dadd(-540.5, -205, -17.5, 2.4, sec = self.dend[168]) h.pt3dadd(-543.5, -206.5, -16, 4.2, sec = self.dend[168]) h.pt3dadd(-546.5, -206.5, -17.5, 2.5, sec = self.dend[168]) h.pt3dadd(-549.5, -205.5, -19, 1.3, sec = self.dend[168]) h.pt3dadd(-553.5, -204.5, -19, 2.3, sec = self.dend[168]) h.pt3dadd(-558, -204.5, -17, 2.6, sec = self.dend[168]) h.pt3dadd(-562.5, -205, -17, 3.3, sec = self.dend[168]) h.pt3dadd(-566.5, -205, -15.5, 3.8, sec = self.dend[168]) h.pt3dadd(-569.5, -205, -15.5, 3.3, sec = self.dend[168]) h.pt3dadd(-571, -205, -16, 4.3, sec = self.dend[168]) h.pt3dclear(sec = self.dend[169]) h.pt3dadd(-571, -205, -16, 4.3, sec = self.dend[169]) h.pt3dadd(-575.5, -208.5, -6, 0.1, sec = self.dend[169]) h.pt3dadd(-576.5, -211, -6, 1, sec = self.dend[169]) h.pt3dadd(-579.5, -212, -6.5, 0.1, sec = self.dend[169]) h.pt3dadd(-581, -214.5, -6, 0.1, sec = self.dend[169]) h.pt3dadd(-583, -215.5, -6.5, 1.6, sec = self.dend[169]) h.pt3dadd(-584.5, -217, -7.5, 0.1, sec = self.dend[169]) h.pt3dadd(-588.5, -220, -6.5, 0.1, sec = self.dend[169]) h.pt3dadd(-591, -220.5, -5.5, 1.3, sec = self.dend[169]) h.pt3dadd(-592.5, -222.5, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-596, -225, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-600, -229, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-600.5, -229, -4.5, 2.1, sec = self.dend[169]) h.pt3dadd(-602, -232, -6, 0.1, sec = self.dend[169]) h.pt3dadd(-603, -234, -4.5, 2.1, sec = self.dend[169]) h.pt3dadd(-604, -234.5, -6, 0.1, sec = self.dend[169]) h.pt3dadd(-604, -237, -4.5, 0.1, sec = self.dend[169]) h.pt3dadd(-606.5, -239, -4.5, 0.1, sec = self.dend[169]) h.pt3dadd(-607, -241, -4, 2.2, sec = self.dend[169]) h.pt3dadd(-611, -244.5, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-613.5, -246, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-616, -246, -4, 2.4, sec = self.dend[169]) h.pt3dadd(-616, -249, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-619, -251, -5.5, 0.1, sec = self.dend[169]) h.pt3dadd(-620, -251, -4, 1.4, sec = self.dend[169]) h.pt3dclear(sec = self.dend[170]) h.pt3dadd(-571, -205, -16, 4.3, sec = self.dend[170]) h.pt3dadd(-578, -205, -18, 1.9, sec = self.dend[170]) h.pt3dadd(-580, -203, -17, 1.6, sec = self.dend[170]) h.pt3dadd(-582.5, -202, -16, 2.2, sec = self.dend[170]) h.pt3dadd(-585.5, -200.5, -16, 2.2, sec = self.dend[170]) h.pt3dadd(-588, -201, -16, 0.9, sec = self.dend[170]) h.pt3dadd(-590.5, -205, -17.5, 0.9, sec = self.dend[170]) h.pt3dadd(-593.5, -205, -16, 0.9, sec = self.dend[170]) h.pt3dadd(-595.5, -206, -16, 2.8, sec = self.dend[170]) h.pt3dadd(-599, -207.5, -16, 4.1, sec = self.dend[170]) h.pt3dadd(-602.5, -209, -15.5, 2.8, sec = self.dend[170]) h.pt3dadd(-606.5, -210, -15.5, 2.1, sec = self.dend[170]) h.pt3dadd(-609, -211, -15.5, 1.6, sec = self.dend[170]) h.pt3dadd(-611.5, -211, -15.5, 1.1, sec = self.dend[170]) h.pt3dadd(-616.5, -211.5, -15.5, 1.3, sec = self.dend[170]) h.pt3dadd(-621, -213, -15.5, 1.3, sec = self.dend[170]) h.pt3dadd(-625.5, -213, -15, 1.3, sec = self.dend[170]) h.pt3dadd(-629, -213, -14, 2.7, sec = self.dend[170]) h.pt3dadd(-634, -214.5, -14, 5, sec = self.dend[170]) h.pt3dclear(sec = self.dend[171]) h.pt3dadd(-634, -214.5, -14, 5, sec = self.dend[171]) h.pt3dadd(-637.5, -220.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-641.5, -221.5, -11.5, 0.1, sec = self.dend[171]) h.pt3dadd(-644.5, -224.5, -10, 1.4, sec = self.dend[171]) h.pt3dadd(-645, -224.5, -10, 1.8, sec = self.dend[171]) h.pt3dadd(-647.5, -225.5, -10, 0.8, sec = self.dend[171]) h.pt3dadd(-651.5, -226.5, -10, 0.6, sec = self.dend[171]) h.pt3dadd(-654, -226.5, -10, 0.6, sec = self.dend[171]) h.pt3dadd(-657, -226.5, -10, 0.6, sec = self.dend[171]) h.pt3dadd(-659, -226.5, -10, 1.2, sec = self.dend[171]) h.pt3dadd(-662.5, -227, -10, 0.4, sec = self.dend[171]) h.pt3dadd(-665.5, -229.5, -9.5, 0.4, sec = self.dend[171]) h.pt3dadd(-667.5, -231.5, -8.5, 2.4, sec = self.dend[171]) h.pt3dadd(-670.5, -233.5, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-671, -235, -9.5, 0.3, sec = self.dend[171]) h.pt3dadd(-673.5, -236.5, -9.5, 0.3, sec = self.dend[171]) h.pt3dadd(-677.5, -236.5, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-681, -236.5, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-681, -237.5, -11, 1.8, sec = self.dend[171]) h.pt3dadd(-683, -237.5, -10, 3.2, sec = self.dend[171]) h.pt3dadd(-686, -237.5, -13, 0.4, sec = self.dend[171]) h.pt3dadd(-692.5, -237.5, -11.5, 0.4, sec = self.dend[171]) h.pt3dadd(-693, -237.5, -11.5, 0.4, sec = self.dend[171]) h.pt3dadd(-695.5, -238.5, -11.5, 2.4, sec = self.dend[171]) h.pt3dadd(-699, -238.5, -11.5, 0.9, sec = self.dend[171]) h.pt3dadd(-702, -239, -11.5, 0.4, sec = self.dend[171]) h.pt3dadd(-705, -239, -12, 0.4, sec = self.dend[171]) h.pt3dadd(-706.5, -240.5, -12, 0.4, sec = self.dend[171]) h.pt3dadd(-708, -241.5, -12, 0.4, sec = self.dend[171]) h.pt3dadd(-708, -242.5, -11, 1.6, sec = self.dend[171]) h.pt3dadd(-711.5, -242.5, -11, 3.3, sec = self.dend[171]) h.pt3dadd(-713, -244.5, -11, 1.2, sec = self.dend[171]) h.pt3dadd(-715, -244.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-719, -244.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-719.5, -245.5, -9.5, 0.9, sec = self.dend[171]) h.pt3dadd(-721, -246.5, -10, 0.1, sec = self.dend[171]) h.pt3dadd(-723.5, -246.5, -9.5, 0.1, sec = self.dend[171]) h.pt3dadd(-726, -247, -9.5, 2.6, sec = self.dend[171]) h.pt3dadd(-727, -247.5, -9.5, 2.8, sec = self.dend[171]) h.pt3dadd(-728, -248, -9.5, 1.5, sec = self.dend[171]) h.pt3dadd(-731, -249, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-735.5, -249, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-737, -249, -10, 1.3, sec = self.dend[171]) h.pt3dadd(-740, -249, -10, 2.8, sec = self.dend[171]) h.pt3dadd(-741, -251.5, -9.5, 1.4, sec = self.dend[171]) h.pt3dadd(-743.5, -251.5, -11.5, 0.1, sec = self.dend[171]) h.pt3dadd(-746.5, -251.5, -11.5, 0.1, sec = self.dend[171]) h.pt3dadd(-748, -256, -9.5, 2.1, sec = self.dend[171]) h.pt3dadd(-751.5, -256, -9.5, 0.1, sec = self.dend[171]) h.pt3dadd(-754.5, -256, -9.5, 0.1, sec = self.dend[171]) h.pt3dadd(-757.5, -259.5, -10, 3.4, sec = self.dend[171]) h.pt3dadd(-759, -259.5, -10, 0.1, sec = self.dend[171]) h.pt3dadd(-761, -261, -10, 2, sec = self.dend[171]) h.pt3dadd(-764, -263, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-766.5, -263.5, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-769, -263.5, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-770.5, -264, -10, 0.3, sec = self.dend[171]) h.pt3dadd(-773, -265.5, -9.5, 1.7, sec = self.dend[171]) h.pt3dadd(-775, -268.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-777, -268.5, -10, 0.1, sec = self.dend[171]) h.pt3dadd(-781, -270.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-783, -271.5, -17.5, 1.6, sec = self.dend[171]) h.pt3dadd(-786.5, -273, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-787, -273, -11, 0.3, sec = self.dend[171]) h.pt3dadd(-789, -274, -11, 1.2, sec = self.dend[171]) h.pt3dadd(-790, -275, -11, 0.4, sec = self.dend[171]) h.pt3dadd(-791.5, -275.5, -11, 0.4, sec = self.dend[171]) h.pt3dadd(-793, -277, -11, 1.5, sec = self.dend[171]) h.pt3dadd(-794.5, -277.5, -11, 1.8, sec = self.dend[171]) h.pt3dadd(-795.5, -278, -11, 1.3, sec = self.dend[171]) h.pt3dadd(-797, -279, -11, 0.3, sec = self.dend[171]) h.pt3dadd(-798.5, -279, -11, 0.3, sec = self.dend[171]) h.pt3dadd(-800, -279, -11, 1.2, sec = self.dend[171]) h.pt3dadd(-802.5, -279, -11, 1.8, sec = self.dend[171]) h.pt3dadd(-803, -278.5, -11, 1.5, sec = self.dend[171]) h.pt3dadd(-804, -278.5, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-806, -280, -11, 0.1, sec = self.dend[171]) h.pt3dadd(-807.5, -281, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-810, -282, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-811, -282, -17.5, 2.4, sec = self.dend[171]) h.pt3dadd(-812.5, -282, -17.5, 3, sec = self.dend[171]) h.pt3dadd(-814.5, -282, -17.5, 1.4, sec = self.dend[171]) h.pt3dadd(-815.5, -282, -17.5, 0.2, sec = self.dend[171]) h.pt3dadd(-819, -282, -17.5, 0.2, sec = self.dend[171]) h.pt3dadd(-820, -282.5, -17.5, 0.2, sec = self.dend[171]) h.pt3dadd(-822, -284.5, -17.5, 1.2, sec = self.dend[171]) h.pt3dadd(-823.5, -285, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-824.5, -286, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-825.5, -287.5, -17.5, 1.6, sec = self.dend[171]) h.pt3dadd(-827, -289.5, -17.5, 2.9, sec = self.dend[171]) h.pt3dadd(-828, -290.5, -17.5, 1.6, sec = self.dend[171]) h.pt3dadd(-830, -290.5, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-832, -292, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-834, -292, -17.5, 0.9, sec = self.dend[171]) h.pt3dadd(-835.5, -292, -23.5, 0.8, sec = self.dend[171]) h.pt3dadd(-837.5, -293.5, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-840, -293.5, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-840.5, -294.5, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-841, -295, -23.5, 0.9, sec = self.dend[171]) h.pt3dadd(-844, -296.5, -23.5, 1.8, sec = self.dend[171]) h.pt3dadd(-846, -298.5, -23.5, 0.9, sec = self.dend[171]) h.pt3dadd(-847, -298.5, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-848.5, -298.5, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-849.5, -300, -17.5, 1.5, sec = self.dend[171]) h.pt3dadd(-851.5, -300, -23.5, 2.4, sec = self.dend[171]) h.pt3dadd(-854, -301, -23.5, 0.7, sec = self.dend[171]) h.pt3dadd(-855, -301, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-856.5, -301, -23.5, 0.3, sec = self.dend[171]) h.pt3dadd(-858.5, -301, -23.5, 0.7, sec = self.dend[171]) h.pt3dadd(-860, -301.5, -23.5, 0.8, sec = self.dend[171]) h.pt3dadd(-861.5, -301.5, -17.5, 0.8, sec = self.dend[171]) h.pt3dadd(-863, -301.5, -17.5, 1.1, sec = self.dend[171]) h.pt3dadd(-864, -300.5, -23.5, 1.5, sec = self.dend[171]) h.pt3dadd(-865.5, -300.5, -23.5, 1.5, sec = self.dend[171]) h.pt3dadd(-866.5, -300.5, -17.5, 1.4, sec = self.dend[171]) h.pt3dadd(-868.5, -300.5, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-870, -300.5, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-871, -300.5, -23.5, 1, sec = self.dend[171]) h.pt3dadd(-873, -300.5, -23.5, 0.9, sec = self.dend[171]) h.pt3dadd(-874, -300.5, -23.5, 0.9, sec = self.dend[171]) h.pt3dadd(-875.5, -300.5, -23.5, 1.7, sec = self.dend[171]) h.pt3dadd(-877, -300.5, -23.5, 2, sec = self.dend[171]) h.pt3dadd(-880, -300.5, -23.5, 0.7, sec = self.dend[171]) h.pt3dadd(-884, -300.5, -23.5, 0.7, sec = self.dend[171]) h.pt3dadd(-886.5, -300.5, -17.5, 1.9, sec = self.dend[171]) h.pt3dadd(-888, -300.5, -17.5, 2.2, sec = self.dend[171]) h.pt3dadd(-890.5, -302, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-891.5, -302, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-893.5, -303, -17.5, 0.9, sec = self.dend[171]) h.pt3dadd(-895.5, -305, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-897, -305, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-900, -306, -17.5, 0.9, sec = self.dend[171]) h.pt3dadd(-902.5, -307.5, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-904, -308, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-907, -309.5, -17.5, 0.3, sec = self.dend[171]) h.pt3dadd(-908.5, -309.5, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-910, -310.5, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-912.5, -311, -17.5, 1.7, sec = self.dend[171]) h.pt3dadd(-914, -312, -23.5, 0.8, sec = self.dend[171]) h.pt3dadd(-915.5, -313.5, -23.5, 0.1, sec = self.dend[171]) h.pt3dadd(-918, -314.5, -23.5, 0.1, sec = self.dend[171]) h.pt3dadd(-921, -316, -17.5, 1, sec = self.dend[171]) h.pt3dadd(-923.5, -316.5, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-926.5, -318, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-926.5, -319, -17.5, 1, sec = self.dend[171]) h.pt3dadd(-928.5, -321, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-930, -322.5, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-931.5, -323.5, -17.5, 1.1, sec = self.dend[171]) h.pt3dadd(-932.5, -325, -17.5, 0.1, sec = self.dend[171]) h.pt3dadd(-933.5, -327, -17.5, 0.1, sec = self.dend[171]) h.pt3dclear(sec = self.dend[172]) h.pt3dadd(-634, -214.5, -14, 5, sec = self.dend[172]) h.pt3dadd(-639.5, -214.5, -15, 1.4, sec = self.dend[172]) h.pt3dadd(-645, -214.5, -17, 1.4, sec = self.dend[172]) h.pt3dadd(-646, -214.5, -16, 2.3, sec = self.dend[172]) h.pt3dadd(-648, -214.5, -15.5, 2.5, sec = self.dend[172]) h.pt3dadd(-649, -214.5, -15.5, 1.6, sec = self.dend[172]) h.pt3dadd(-654, -214.5, -15.5, 1.2, sec = self.dend[172]) h.pt3dadd(-658.5, -214.5, -15.5, 1.2, sec = self.dend[172]) h.pt3dadd(-660.5, -214.5, -15, 2.9, sec = self.dend[172]) h.pt3dadd(-663, -213.5, -15.5, 3.3, sec = self.dend[172]) h.pt3dadd(-666.5, -213.5, -15, 2.5, sec = self.dend[172]) h.pt3dadd(-670.5, -213.5, -14, 1.6, sec = self.dend[172]) h.pt3dadd(-674, -213.5, -16, 1.6, sec = self.dend[172]) h.pt3dadd(-675.5, -212.5, -15.5, 2, sec = self.dend[172]) h.pt3dadd(-678.5, -212, -15, 2.9, sec = self.dend[172]) h.pt3dadd(-682, -212, -16, 1.7, sec = self.dend[172]) h.pt3dadd(-684.5, -212, -16, 0.9, sec = self.dend[172]) h.pt3dadd(-687.5, -211.5, -16, 0.9, sec = self.dend[172]) h.pt3dadd(-691, -210, -15.5, 2.8, sec = self.dend[172]) h.pt3dclear(sec = self.dend[173]) h.pt3dadd(-691, -210, -15.5, 2.8, sec = self.dend[173]) h.pt3dadd(-699, -207.5, -15, 1.1, sec = self.dend[173]) h.pt3dadd(-702.5, -207.5, -17, 1.8, sec = self.dend[173]) h.pt3dadd(-705.5, -214, -17, 0.5, sec = self.dend[173]) h.pt3dadd(-710.5, -214, -17, 0.5, sec = self.dend[173]) h.pt3dadd(-715.5, -210, -17, 0.5, sec = self.dend[173]) h.pt3dadd(-718.5, -210, -15, 1.5, sec = self.dend[173]) h.pt3dadd(-723, -210, -15.5, 0.4, sec = self.dend[173]) h.pt3dadd(-726.5, -207, -15.5, 0.5, sec = self.dend[173]) h.pt3dadd(-735.5, -205, -15, 2, sec = self.dend[173]) h.pt3dadd(-738, -202.5, -15, 0.2, sec = self.dend[173]) h.pt3dadd(-739.5, -202.5, -15, 0.2, sec = self.dend[173]) h.pt3dadd(-742.5, -202, -15, 1.9, sec = self.dend[173]) h.pt3dadd(-744, -198, -15, 0.1, sec = self.dend[173]) h.pt3dadd(-748, -201.5, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-751, -202, -12, 2, sec = self.dend[173]) h.pt3dadd(-751, -205, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-757.5, -208.5, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-760, -209.5, -13, 1.6, sec = self.dend[173]) h.pt3dadd(-762.5, -210.5, -15, 0.1, sec = self.dend[173]) h.pt3dadd(-764.5, -216.5, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-766.5, -219, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-765.5, -222, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-764.5, -224, -12, 1.5, sec = self.dend[173]) h.pt3dadd(-764.5, -226.5, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-764.5, -232, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-765.5, -232, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-767.5, -232.5, -13.5, 0.7, sec = self.dend[173]) h.pt3dadd(-768, -234.5, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-768.5, -238, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-770.5, -241, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-773, -243, -12, 0.6, sec = self.dend[173]) h.pt3dadd(-779, -243.5, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-782.5, -244.5, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-785.5, -245.5, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-788.5, -247, -11.5, 0.1, sec = self.dend[173]) h.pt3dadd(-791, -250.5, -13.5, 0.9, sec = self.dend[173]) h.pt3dadd(-793, -252, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-796, -254, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-799, -254, -13.5, 0.1, sec = self.dend[173]) h.pt3dadd(-802, -254, -14, 1, sec = self.dend[173]) h.pt3dadd(-804, -254, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-804, -254.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-806.5, -254.5, -15, 0.1, sec = self.dend[173]) h.pt3dadd(-807, -257, -15.5, 0.1, sec = self.dend[173]) h.pt3dadd(-809, -258.5, -15, 0.1, sec = self.dend[173]) h.pt3dadd(-811.5, -260.5, -15, 0.1, sec = self.dend[173]) h.pt3dadd(-814.5, -265, -15.5, 0.1, sec = self.dend[173]) h.pt3dadd(-815.5, -265, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-818.5, -265, -12, 1.3, sec = self.dend[173]) h.pt3dadd(-821.5, -267, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-824, -267.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-829.5, -267.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-831, -267.5, -13, 0.1, sec = self.dend[173]) h.pt3dadd(-833.5, -268.5, -12, 0.1, sec = self.dend[173]) h.pt3dadd(-837, -268.5, -13.5, 1.3, sec = self.dend[173]) h.pt3dadd(-839, -268.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-841.5, -268.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-846.5, -269.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-850, -269.5, -14, 0.1, sec = self.dend[173]) h.pt3dadd(-855, -273, -12, 0.1, sec = self.dend[173]) h.pt3dadd(-857, -273, -12, 0.8, sec = self.dend[173]) h.pt3dadd(-858.5, -273.5, -12, 0.9, sec = self.dend[173]) h.pt3dadd(-860, -275, -10, 1.8, sec = self.dend[173]) h.pt3dadd(-863.5, -276.5, -10, 0.7, sec = self.dend[173]) h.pt3dadd(-864, -277.5, -10, 0.6, sec = self.dend[173]) h.pt3dadd(-865.5, -277.5, -10, 0.6, sec = self.dend[173]) h.pt3dadd(-866, -277.5, -10, 1.6, sec = self.dend[173]) h.pt3dadd(-867, -277.5, -10, 2.1, sec = self.dend[173]) h.pt3dadd(-869, -277.5, -10, 1.2, sec = self.dend[173]) h.pt3dadd(-871, -277.5, -10, 0.6, sec = self.dend[173]) h.pt3dadd(-873, -276, -7.5, 0.7, sec = self.dend[173]) h.pt3dadd(-875.5, -274.5, -7.5, 1.1, sec = self.dend[173]) h.pt3dadd(-877, -274.5, -8.5, 1.1, sec = self.dend[173]) h.pt3dadd(-880, -274.5, -6.5, 1.1, sec = self.dend[173]) h.pt3dadd(-883, -275, -6.5, 0.7, sec = self.dend[173]) h.pt3dadd(-885, -275, -7.5, 0.6, sec = self.dend[173]) h.pt3dadd(-885.5, -274.5, -7.5, 1.2, sec = self.dend[173]) h.pt3dadd(-888, -273, -7.5, 2.2, sec = self.dend[173]) h.pt3dadd(-890, -273, -7.5, 1.2, sec = self.dend[173]) h.pt3dadd(-892.5, -272.5, -7.5, 0.7, sec = self.dend[173]) h.pt3dadd(-896, -271, -7.5, 0.7, sec = self.dend[173]) h.pt3dadd(-900, -272.5, -7.5, 0.7, sec = self.dend[173]) h.pt3dadd(-901, -272.5, -7.5, 1.9, sec = self.dend[173]) h.pt3dadd(-902.5, -272.5, -7.5, 2.7, sec = self.dend[173]) h.pt3dadd(-905, -272.5, -7.5, 1.6, sec = self.dend[173]) h.pt3dadd(-906.5, -272.5, -6.5, 0.6, sec = self.dend[173]) h.pt3dadd(-906.5, -272, -6.5, 0.6, sec = self.dend[173]) h.pt3dadd(-909.5, -272, -6.5, 0.5, sec = self.dend[173]) h.pt3dadd(-912, -272, -5.5, 1.7, sec = self.dend[173]) h.pt3dadd(-912.5, -272, -5.5, 2.7, sec = self.dend[173]) h.pt3dadd(-913.5, -272, -4, 1.2, sec = self.dend[173]) h.pt3dadd(-914.5, -271, -6.5, 0.1, sec = self.dend[173]) h.pt3dadd(-918.5, -268, -5.5, 0.1, sec = self.dend[173]) h.pt3dadd(-919, -269.5, -3, 1.7, sec = self.dend[173]) h.pt3dadd(-920, -269.5, -3, 2.3, sec = self.dend[173]) h.pt3dadd(-921.5, -269.5, -3, 1.7, sec = self.dend[173]) h.pt3dadd(-922.5, -267.5, -2, 0.9, sec = self.dend[173]) h.pt3dadd(-923, -265.5, -2, 0.7, sec = self.dend[173]) h.pt3dadd(-925.5, -263, -3, 0.7, sec = self.dend[173]) h.pt3dadd(-927, -261, -3, 1.9, sec = self.dend[173]) h.pt3dadd(-929, -261, -3, 2.3, sec = self.dend[173]) h.pt3dadd(-930.5, -262, -3, 0.9, sec = self.dend[173]) h.pt3dadd(-933, -262, -3, 0.6, sec = self.dend[173]) h.pt3dadd(-935.5, -263, -3, 0.6, sec = self.dend[173]) h.pt3dadd(-938.5, -263, -3, 0.8, sec = self.dend[173]) h.pt3dadd(-942.5, -261, -3, 0.7, sec = self.dend[173]) h.pt3dadd(-946.5, -263.5, -3, 0.7, sec = self.dend[173]) h.pt3dadd(-949, -265, -3, 0.7, sec = self.dend[173]) h.pt3dadd(-950, -265, -3, 1.6, sec = self.dend[173]) h.pt3dadd(-952, -265.5, -2, 1.6, sec = self.dend[173]) h.pt3dadd(-954, -268.5, -2, 1.4, sec = self.dend[173]) h.pt3dadd(-954, -271.5, -2, 1, sec = self.dend[173]) h.pt3dadd(-957, -271.5, -2, 0.6, sec = self.dend[173]) h.pt3dadd(-961.5, -273.5, -3, 0.6, sec = self.dend[173]) h.pt3dadd(-962, -276, -2, 0.6, sec = self.dend[173]) h.pt3dadd(-964, -272, -4, 0.6, sec = self.dend[173]) h.pt3dadd(-965.5, -274.5, -4, 0.6, sec = self.dend[173]) h.pt3dadd(-966.5, -274.5, -2, 1.2, sec = self.dend[173]) h.pt3dadd(-973, -274.5, -3, 0.6, sec = self.dend[173]) h.pt3dadd(-971, -279, -2, 0.9, sec = self.dend[173]) h.pt3dadd(-973, -280.5, -7.5, 0.8, sec = self.dend[173]) h.pt3dadd(-973.5, -279.5, -6.5, 0.5, sec = self.dend[173]) h.pt3dadd(-976, -279.5, -5.5, 1.3, sec = self.dend[173]) h.pt3dadd(-977.5, -279.5, -5.5, 1.3, sec = self.dend[173]) h.pt3dadd(-979.5, -281.5, -7.5, 0.9, sec = self.dend[173]) h.pt3dadd(-979.5, -283, -7.5, 0.2, sec = self.dend[173]) h.pt3dadd(-979.5, -286, -7.5, 0.2, sec = self.dend[173]) h.pt3dadd(-980.5, -286, -7.5, 1.2, sec = self.dend[173]) h.pt3dadd(-982, -287.5, -8.5, 1.7, sec = self.dend[173]) h.pt3dadd(-983, -289, -10, 0.4, sec = self.dend[173]) h.pt3dadd(-983.5, -291.5, -10, 0.4, sec = self.dend[173]) h.pt3dadd(-984.5, -291.5, -10, 1.5, sec = self.dend[173]) h.pt3dadd(-985, -291.5, -10, 1.5, sec = self.dend[173]) h.pt3dadd(-986, -291.5, -10, 0.9, sec = self.dend[173]) h.pt3dadd(-987, -291, -10, 0.1, sec = self.dend[173]) h.pt3dadd(-990, -291, -10, 0.1, sec = self.dend[173]) h.pt3dadd(-992, -290.5, -10, 0.1, sec = self.dend[173]) h.pt3dadd(-993, -288.5, -8.5, 1.3, sec = self.dend[173]) h.pt3dadd(-993, -291, -7.5, 1.3, sec = self.dend[173]) h.pt3dadd(-993, -294, -7.5, 0.7, sec = self.dend[173]) h.pt3dadd(-993, -295.5, -7.5, 0.1, sec = self.dend[173]) h.pt3dadd(-990.5, -298, -7.5, 0.1, sec = self.dend[173]) h.pt3dadd(-988, -300.5, -7.5, 0.1, sec = self.dend[173]) h.pt3dadd(-988.5, -301.5, -7.5, 0.5, sec = self.dend[173]) h.pt3dadd(-989.5, -304, -7.5, 1.2, sec = self.dend[173]) h.pt3dadd(-989.5, -306, -7.5, 1.2, sec = self.dend[173]) h.pt3dadd(-989, -307.5, -7.5, 0.1, sec = self.dend[173]) h.pt3dadd(-988, -308.5, -7.5, 0.1, sec = self.dend[173]) h.pt3dadd(-986.5, -309.5, -8.5, 0.1, sec = self.dend[173]) h.pt3dadd(-985.5, -310.5, -8.5, 0.1, sec = self.dend[173]) h.pt3dadd(-985.5, -313, -8.5, 0.1, sec = self.dend[173]) h.pt3dadd(-984, -316, -8.5, 0.1, sec = self.dend[173]) h.pt3dadd(-984, -317, -8.5, 0.1, sec = self.dend[173]) h.pt3dadd(-983, -318.5, -11, 0.1, sec = self.dend[173]) h.pt3dadd(-982, -318.5, -7.5, 1.6, sec = self.dend[173]) h.pt3dadd(-980.5, -320, -8.5, 1.2, sec = self.dend[173]) h.pt3dadd(-979.5, -321.5, -8.5, 0.6, sec = self.dend[173]) h.pt3dclear(sec = self.dend[174]) h.pt3dadd(-691, -210, -15.5, 2.8, sec = self.dend[174]) h.pt3dadd(-698, -210, -15, 0.7, sec = self.dend[174]) h.pt3dadd(-701.5, -210, -15, 0.7, sec = self.dend[174]) h.pt3dadd(-704, -210.5, -13.5, 2.6, sec = self.dend[174]) h.pt3dadd(-707, -210.5, -13, 4.3, sec = self.dend[174]) h.pt3dadd(-711.5, -211.5, -14, 1.6, sec = self.dend[174]) h.pt3dadd(-717, -212, -13.5, 1.8, sec = self.dend[174]) h.pt3dadd(-719.5, -212, -14, 3.4, sec = self.dend[174]) h.pt3dadd(-722.5, -212, -14, 0.4, sec = self.dend[174]) h.pt3dadd(-726, -212, -14, 0.4, sec = self.dend[174]) h.pt3dadd(-727.5, -212, -14, 2.5, sec = self.dend[174]) h.pt3dadd(-730.5, -212, -13, 0.7, sec = self.dend[174]) h.pt3dadd(-733, -211, -13, 0.7, sec = self.dend[174]) h.pt3dadd(-737.5, -210, -12, 0.7, sec = self.dend[174]) h.pt3dadd(-740, -210, -13.5, 0.7, sec = self.dend[174]) h.pt3dadd(-739.5, -209, -11.5, 2.9, sec = self.dend[174]) h.pt3dadd(-743, -209, -12, 4.3, sec = self.dend[174]) h.pt3dadd(-747, -209, -13.5, 0.8, sec = self.dend[174]) h.pt3dadd(-753, -208.5, -13.5, 0.9, sec = self.dend[174]) h.pt3dadd(-755, -206.5, -12, 0.9, sec = self.dend[174]) h.pt3dadd(-757.5, -206, -13, 0.9, sec = self.dend[174]) h.pt3dadd(-759, -206.5, -13, 2.9, sec = self.dend[174]) h.pt3dadd(-762.5, -206.5, -14, 0.5, sec = self.dend[174]) h.pt3dadd(-765, -206.5, -13, 2.5, sec = self.dend[174]) h.pt3dadd(-766.5, -206, -13, 3.8, sec = self.dend[174]) h.pt3dadd(-770, -203.5, -13.5, 1.8, sec = self.dend[174]) h.pt3dadd(-770.5, -203.5, -13, 0.3, sec = self.dend[174]) h.pt3dadd(-772.5, -203.5, -14, 0.3, sec = self.dend[174]) h.pt3dadd(-773, -202.5, -13.5, 1.8, sec = self.dend[174]) h.pt3dadd(-774.5, -202, -13, 2.7, sec = self.dend[174]) h.pt3dadd(-777.5, -200, -14, 0.2, sec = self.dend[174]) h.pt3dadd(-781, -200, -13.5, 0.2, sec = self.dend[174]) h.pt3dadd(-783, -200, -13.5, 3, sec = self.dend[174]) h.pt3dadd(-784.5, -200, -13.5, 1.6, sec = self.dend[174]) h.pt3dadd(-786.5, -200, -13, 0.3, sec = self.dend[174]) h.pt3dadd(-789, -200, -13, 0.3, sec = self.dend[174]) h.pt3dadd(-791, -200, -12, 2.2, sec = self.dend[174]) h.pt3dadd(-793.5, -200, -13, 4.2, sec = self.dend[174]) h.pt3dadd(-796.5, -198, -13, 2, sec = self.dend[174]) h.pt3dadd(-798.5, -198, -13, 0.4, sec = self.dend[174]) h.pt3dadd(-801.5, -197.5, -13, 0.5, sec = self.dend[174]) h.pt3dadd(-804.5, -197.5, -12, 0.5, sec = self.dend[174]) h.pt3dadd(-807, -195.5, -13, 0.5, sec = self.dend[174]) h.pt3dadd(-809, -195.5, -11.5, 2, sec = self.dend[174]) h.pt3dadd(-810.5, -196.5, -13, 3.7, sec = self.dend[174]) h.pt3dadd(-814.5, -196, -11.5, 1.1, sec = self.dend[174]) h.pt3dadd(-818, -194, -13, 1.1, sec = self.dend[174]) h.pt3dadd(-820.5, -193.5, -11, 2.1, sec = self.dend[174]) h.pt3dadd(-822, -193.5, -11.5, 2.5, sec = self.dend[174]) h.pt3dadd(-826, -193.5, -11.5, 0.7, sec = self.dend[174]) h.pt3dadd(-827.5, -194, -11, 0.7, sec = self.dend[174]) h.pt3dadd(-829.5, -194, -12, 3.2, sec = self.dend[174]) h.pt3dadd(-833.5, -194, -11.5, 0.3, sec = self.dend[174]) h.pt3dadd(-835.5, -194, -11.5, 0.3, sec = self.dend[174]) h.pt3dadd(-836.5, -194, -12, 2.7, sec = self.dend[174]) h.pt3dadd(-839.5, -194, -12, 3.8, sec = self.dend[174]) h.pt3dadd(-843, -194, -12, 2.1, sec = self.dend[174]) h.pt3dadd(-843.5, -194, -11.5, 0.7, sec = self.dend[174]) h.pt3dadd(-846.5, -192, -12, 0.9, sec = self.dend[174]) h.pt3dadd(-848, -192, -12, 0.9, sec = self.dend[174]) h.pt3dadd(-850, -192, -11.5, 2.1, sec = self.dend[174]) h.pt3dadd(-855, -192, -11.5, 0.3, sec = self.dend[174]) h.pt3dadd(-860, -190.5, -11, 0.3, sec = self.dend[174]) h.pt3dadd(-862.5, -190.5, -11, 0.3, sec = self.dend[174]) h.pt3dadd(-868, -188, -11.5, 2, sec = self.dend[174]) h.pt3dadd(-872, -189, -11.5, 0.5, sec = self.dend[174]) h.pt3dadd(-875, -189, -11.5, 0.5, sec = self.dend[174]) h.pt3dadd(-880.5, -189, -11, 0.6, sec = self.dend[174]) h.pt3dadd(-883, -189, -10, 2.8, sec = self.dend[174]) h.pt3dadd(-887.5, -188.5, -10, 0.8, sec = self.dend[174]) h.pt3dadd(-891, -188.5, -10, 1.3, sec = self.dend[174]) h.pt3dadd(-893, -186, -10, 1.3, sec = self.dend[174]) h.pt3dadd(-895.5, -185.5, -11, 1.2, sec = self.dend[174]) h.pt3dadd(-897.5, -185.5, -9.5, 0.6, sec = self.dend[174]) h.pt3dadd(-900, -185.5, -11, 1, sec = self.dend[174]) h.pt3dadd(-903.5, -184, -10, 0.4, sec = self.dend[174]) h.pt3dadd(-907, -182, -10, 0.4, sec = self.dend[174]) h.pt3dadd(-909, -182.5, -10, 0.5, sec = self.dend[174]) h.pt3dadd(-913, -182.5, -10, 0.5, sec = self.dend[174]) h.pt3dadd(-916.5, -185, -10, 1.5, sec = self.dend[174]) h.pt3dadd(-921.5, -186, -11.5, 1.1, sec = self.dend[174]) h.pt3dadd(-927, -188, -11, 1.1, sec = self.dend[174]) h.pt3dadd(-931.5, -188, -9.5, 1.1, sec = self.dend[174]) h.pt3dadd(-932.5, -190.5, -9.5, 1.1, sec = self.dend[174]) h.pt3dclear(sec = self.dend[175]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[175]) h.pt3dadd(44, 6.5, -5.5, 15.9, sec = self.dend[175]) h.pt3dadd(44, 4, -5, 14.1, sec = self.dend[175]) h.pt3dadd(44.5, 1.5, -3, 11.2, sec = self.dend[175]) h.pt3dadd(45, -0.5, -4, 10.1, sec = self.dend[175]) h.pt3dadd(48, -6, -4, 10.7, sec = self.dend[175]) h.pt3dadd(47.5, -9, -2, 11, sec = self.dend[175]) h.pt3dadd(49.5, -13, -2, 11.9, sec = self.dend[175]) h.pt3dadd(50.5, -16.5, -2, 14.3, sec = self.dend[175]) h.pt3dadd(51.5, -18.5, -3, 13.7, sec = self.dend[175]) h.pt3dclear(sec = self.dend[176]) h.pt3dadd(51.5, -18.5, -3, 13.7, sec = self.dend[176]) h.pt3dadd(50.5, -29, -1, 6.3, sec = self.dend[176]) h.pt3dadd(51, -34, 0, 6.5, sec = self.dend[176]) h.pt3dadd(52.5, -37.5, 0, 6.8, sec = self.dend[176]) h.pt3dadd(52.5, -40, 0, 7.9, sec = self.dend[176]) h.pt3dadd(52.5, -43, 0, 9, sec = self.dend[176]) h.pt3dadd(52, -47, 0, 9.7, sec = self.dend[176]) h.pt3dadd(54, -50, -2, 8.6, sec = self.dend[176]) h.pt3dadd(54.5, -53, -3, 7.6, sec = self.dend[176]) h.pt3dadd(55, -56.5, -3, 6.7, sec = self.dend[176]) h.pt3dadd(57, -58, -3, 6.8, sec = self.dend[176]) h.pt3dadd(59, -60.5, -4, 6.6, sec = self.dend[176]) h.pt3dadd(63, -64, -5, 6.8, sec = self.dend[176]) h.pt3dadd(66, -67, -5, 7, sec = self.dend[176]) h.pt3dadd(69.5, -71, -5, 7.4, sec = self.dend[176]) h.pt3dadd(72, -75, -5, 7.4, sec = self.dend[176]) h.pt3dadd(75, -76, -5.5, 7.3, sec = self.dend[176]) h.pt3dadd(78, -80.5, -6.5, 7.1, sec = self.dend[176]) h.pt3dadd(80, -83.5, -5.5, 6.2, sec = self.dend[176]) h.pt3dadd(84.5, -86.5, -5.5, 5.4, sec = self.dend[176]) h.pt3dadd(88, -90, -6.5, 6.2, sec = self.dend[176]) h.pt3dadd(91, -93.5, -5.5, 5.5, sec = self.dend[176]) h.pt3dadd(93.5, -96, -6.5, 5.7, sec = self.dend[176]) h.pt3dadd(94.5, -100, -6.5, 5.1, sec = self.dend[176]) h.pt3dadd(95, -101, -6.5, 4.1, sec = self.dend[176]) h.pt3dadd(96.5, -103.5, -5.5, 3.3, sec = self.dend[176]) h.pt3dadd(98.5, -104, -6.5, 3.8, sec = self.dend[176]) h.pt3dadd(102, -105.5, -6.5, 4.3, sec = self.dend[176]) h.pt3dadd(104, -106, -6.5, 5, sec = self.dend[176]) h.pt3dadd(108, -109, -6.5, 5.1, sec = self.dend[176]) h.pt3dadd(111.5, -110.5, -6.5, 5.8, sec = self.dend[176]) h.pt3dadd(115, -112.5, -6.5, 5.5, sec = self.dend[176]) h.pt3dadd(119, -114.5, -7.5, 4.6, sec = self.dend[176]) h.pt3dadd(122.5, -115.5, -8.5, 4.2, sec = self.dend[176]) h.pt3dadd(125.5, -118, -8.5, 4.7, sec = self.dend[176]) h.pt3dadd(129.5, -119, -8.5, 5.1, sec = self.dend[176]) h.pt3dadd(132.5, -120.5, -8.5, 5.3, sec = self.dend[176]) h.pt3dadd(135, -122, -6.5, 4.9, sec = self.dend[176]) h.pt3dadd(138, -123, -6.5, 4.9, sec = self.dend[176]) h.pt3dadd(140, -124, -6.5, 5.7, sec = self.dend[176]) h.pt3dadd(143.5, -126, -6.5, 5.8, sec = self.dend[176]) h.pt3dadd(146, -127.5, -5.5, 4.9, sec = self.dend[176]) h.pt3dadd(148.5, -128, -3, 4.6, sec = self.dend[176]) h.pt3dadd(151, -129, -4, 4.8, sec = self.dend[176]) h.pt3dadd(154, -129.5, -5, 5.5, sec = self.dend[176]) h.pt3dadd(157.5, -132.5, -5, 5.7, sec = self.dend[176]) h.pt3dadd(161, -133.5, -5.5, 6.2, sec = self.dend[176]) h.pt3dadd(162, -134.5, -5.5, 6, sec = self.dend[176]) h.pt3dadd(166.5, -134.5, -5.5, 5.3, sec = self.dend[176]) h.pt3dadd(168, -138, -5.5, 4.4, sec = self.dend[176]) h.pt3dadd(168.5, -138.5, -5.5, 5.2, sec = self.dend[176]) h.pt3dadd(171.5, -139.5, -5.5, 5.2, sec = self.dend[176]) h.pt3dadd(175.5, -142, -5.5, 5.4, sec = self.dend[176]) h.pt3dadd(178.5, -143.5, -5.5, 5, sec = self.dend[176]) h.pt3dadd(181.5, -146.5, -6.5, 4.7, sec = self.dend[176]) h.pt3dadd(185, -149.5, -6.5, 4.9, sec = self.dend[176]) h.pt3dadd(186.5, -150, -6.5, 5, sec = self.dend[176]) h.pt3dadd(189, -153.5, -6.5, 5, sec = self.dend[176]) h.pt3dadd(191, -154.5, -6.5, 5.3, sec = self.dend[176]) h.pt3dadd(193.5, -154.5, -6.5, 5.3, sec = self.dend[176]) h.pt3dadd(196.5, -158, -6.5, 5.5, sec = self.dend[176]) h.pt3dadd(198, -161.5, -2, 6, sec = self.dend[176]) h.pt3dclear(sec = self.dend[177]) h.pt3dadd(198, -161.5, -2, 6, sec = self.dend[177]) h.pt3dadd(201, -168.5, -2, 5, sec = self.dend[177]) h.pt3dadd(202.5, -171.5, -2, 5, sec = self.dend[177]) h.pt3dadd(203.5, -174.5, -2, 5.5, sec = self.dend[177]) h.pt3dadd(204.5, -177.5, 0, 6.3, sec = self.dend[177]) h.pt3dadd(204.5, -180.5, 0, 4.9, sec = self.dend[177]) h.pt3dadd(205.5, -184, 6.5, 5.8, sec = self.dend[177]) h.pt3dadd(207, -189, 6.5, 5.3, sec = self.dend[177]) h.pt3dadd(207.5, -195, 0, 5.3, sec = self.dend[177]) h.pt3dadd(208, -202, 0, 5.3, sec = self.dend[177]) h.pt3dadd(208, -208, 0, 5.3, sec = self.dend[177]) h.pt3dadd(208, -210.5, 1, 5, sec = self.dend[177]) h.pt3dadd(210, -220, 1, 5, sec = self.dend[177]) h.pt3dadd(211.5, -229.5, 2, 5, sec = self.dend[177]) h.pt3dadd(213, -238.5, 1, 5, sec = self.dend[177]) h.pt3dadd(216, -247.5, 1, 5, sec = self.dend[177]) h.pt3dadd(218.5, -254.5, 1, 5, sec = self.dend[177]) h.pt3dadd(221, -261, 2, 5, sec = self.dend[177]) h.pt3dadd(224.5, -270, 2, 5, sec = self.dend[177]) h.pt3dadd(225, -275, 3, 5, sec = self.dend[177]) h.pt3dadd(227.5, -281.5, 3, 5, sec = self.dend[177]) h.pt3dadd(230.5, -287, 3, 5, sec = self.dend[177]) h.pt3dadd(234, -292, 3, 5, sec = self.dend[177]) h.pt3dadd(238.5, -294.5, 3, 5, sec = self.dend[177]) h.pt3dadd(243, -297.5, 3, 5, sec = self.dend[177]) h.pt3dadd(247, -299, 3, 5, sec = self.dend[177]) h.pt3dadd(252.5, -304, 2, 5, sec = self.dend[177]) h.pt3dadd(256.5, -306, 2, 5, sec = self.dend[177]) h.pt3dadd(263, -310.5, 2, 5, sec = self.dend[177]) h.pt3dadd(268.5, -314, 2, 5, sec = self.dend[177]) h.pt3dadd(273, -317, 1, 5, sec = self.dend[177]) h.pt3dadd(274.5, -322, 3, 5, sec = self.dend[177]) h.pt3dadd(279, -326, 6.5, 3.7, sec = self.dend[177]) h.pt3dadd(281, -328, 7.5, 4.4, sec = self.dend[177]) h.pt3dadd(283, -332.5, 6.5, 4.9, sec = self.dend[177]) h.pt3dadd(285, -336, 6.5, 4.6, sec = self.dend[177]) h.pt3dadd(287.5, -340, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(289.5, -342.5, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(289.5, -346, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(291, -349, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(291, -352.5, 5.5, 4.4, sec = self.dend[177]) h.pt3dadd(292, -354.5, 5.5, 4.3, sec = self.dend[177]) h.pt3dadd(293.5, -357.5, 5.5, 4.3, sec = self.dend[177]) h.pt3dadd(296.5, -358.5, 5.5, 4.3, sec = self.dend[177]) h.pt3dadd(296.5, -361.5, 5.5, 3.7, sec = self.dend[177]) h.pt3dadd(295.5, -366.5, 5.5, 3.6, sec = self.dend[177]) h.pt3dadd(294.5, -370, 5.5, 4, sec = self.dend[177]) h.pt3dadd(294, -373, 5.5, 3.7, sec = self.dend[177]) h.pt3dadd(292.5, -376, 5.5, 3.6, sec = self.dend[177]) h.pt3dadd(292.5, -379, 5.5, 3.4, sec = self.dend[177]) h.pt3dadd(294.5, -384, 5.5, 3.4, sec = self.dend[177]) h.pt3dadd(295, -386, 5.5, 3.6, sec = self.dend[177]) h.pt3dadd(295, -389, 5.5, 4, sec = self.dend[177]) h.pt3dadd(295, -391, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(297.5, -392.5, 5.5, 4.3, sec = self.dend[177]) h.pt3dadd(297.5, -396.5, 5.5, 3.6, sec = self.dend[177]) h.pt3dadd(297, -399, 5.5, 3.2, sec = self.dend[177]) h.pt3dadd(297.5, -401.5, 5.5, 3.8, sec = self.dend[177]) h.pt3dadd(297.5, -403, 5.5, 4.6, sec = self.dend[177]) h.pt3dadd(298.5, -407.5, 5, 4.7, sec = self.dend[177]) h.pt3dadd(298.5, -412, 5, 5.2, sec = self.dend[177]) h.pt3dadd(299, -414.5, 5, 4, sec = self.dend[177]) h.pt3dadd(301.5, -422, 6.5, 3.3, sec = self.dend[177]) h.pt3dadd(303, -425, 6.5, 3.3, sec = self.dend[177]) h.pt3dadd(303, -430, 13, 3.6, sec = self.dend[177]) h.pt3dadd(303, -433.5, 13, 4, sec = self.dend[177]) h.pt3dadd(303, -435.5, 14, 4, sec = self.dend[177]) h.pt3dadd(303, -439, 14, 4.4, sec = self.dend[177]) h.pt3dadd(303, -443, 14, 5.1, sec = self.dend[177]) h.pt3dadd(304.5, -445.5, 14, 4.3, sec = self.dend[177]) h.pt3dadd(305, -448, 15.5, 3.4, sec = self.dend[177]) h.pt3dadd(305.5, -449.5, 15.5, 2.8, sec = self.dend[177]) h.pt3dadd(305.5, -452, 15, 2.8, sec = self.dend[177]) h.pt3dadd(304.5, -454, 15.5, 2.3, sec = self.dend[177]) h.pt3dadd(303, -457.5, 15.5, 2.1, sec = self.dend[177]) h.pt3dadd(303, -460, 15.5, 2.7, sec = self.dend[177]) h.pt3dadd(302, -462, 15.5, 3.4, sec = self.dend[177]) h.pt3dadd(302, -465, 15.5, 3.8, sec = self.dend[177]) h.pt3dadd(302, -473.5, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(299.5, -479.5, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(299, -483, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(297.5, -487, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(294, -492, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(291.5, -500, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(289.5, -509, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(285, -515, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(283.5, -524, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(281.5, -530.5, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(279, -540, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(276.5, -550, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(276.5, -556, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(274.5, -564, 18.5, 3.8, sec = self.dend[177]) h.pt3dadd(271.5, -573.5, 17.5, 3.8, sec = self.dend[177]) h.pt3dadd(270, -584, 18.5, 3.7, sec = self.dend[177]) h.pt3dadd(267, -593.5, 18.5, 3.7, sec = self.dend[177]) h.pt3dadd(266.5, -599.5, 20, 3.1, sec = self.dend[177]) h.pt3dadd(266.5, -605, 18.5, 2.8, sec = self.dend[177]) h.pt3dadd(266.5, -610, 18.5, 2.8, sec = self.dend[177]) h.pt3dadd(266.5, -615, 18.5, 2.8, sec = self.dend[177]) h.pt3dadd(266.5, -621, 18.5, 3.2, sec = self.dend[177]) h.pt3dadd(266.5, -623, 18.5, 2.7, sec = self.dend[177]) h.pt3dadd(266.5, -627, 18.5, 2.6, sec = self.dend[177]) h.pt3dadd(267.5, -628.5, 18.5, 2.2, sec = self.dend[177]) h.pt3dadd(267.5, -632.5, 18.5, 2.4, sec = self.dend[177]) h.pt3dadd(267.5, -636.5, 18.5, 2.9, sec = self.dend[177]) h.pt3dadd(267.5, -639.5, 18.5, 2.7, sec = self.dend[177]) h.pt3dadd(267, -643.5, 18.5, 2.5, sec = self.dend[177]) h.pt3dadd(267, -647.5, 18.5, 2.5, sec = self.dend[177]) h.pt3dadd(267, -650.5, 18.5, 2.5, sec = self.dend[177]) h.pt3dadd(267, -653, 18.5, 2.8, sec = self.dend[177]) h.pt3dadd(265.5, -657, 18.5, 2, sec = self.dend[177]) h.pt3dadd(265, -658.5, 18.5, 2.5, sec = self.dend[177]) h.pt3dadd(265, -661.5, 18.5, 2.6, sec = self.dend[177]) h.pt3dadd(264.5, -664, 18.5, 2.6, sec = self.dend[177]) h.pt3dadd(263.5, -667, 18.5, 2.6, sec = self.dend[177]) h.pt3dadd(262.5, -669.5, 18.5, 2.7, sec = self.dend[177]) h.pt3dadd(261.5, -672.5, 18.5, 3, sec = self.dend[177]) h.pt3dadd(261.5, -675, 18.5, 2.5, sec = self.dend[177]) h.pt3dadd(261.5, -676.5, 18.5, 2, sec = self.dend[177]) h.pt3dadd(261.5, -679, 18.5, 2.1, sec = self.dend[177]) h.pt3dadd(261, -683, 18.5, 2.6, sec = self.dend[177]) h.pt3dadd(259.5, -687, 18.5, 3.3, sec = self.dend[177]) h.pt3dadd(258, -690, 18.5, 3.3, sec = self.dend[177]) h.pt3dadd(255.5, -694, 19.5, 3.3, sec = self.dend[177]) h.pt3dadd(256, -696, 20, 2.8, sec = self.dend[177]) h.pt3dadd(255, -698, 20, 2.8, sec = self.dend[177]) h.pt3dadd(255.5, -699, 19.5, 2.3, sec = self.dend[177]) h.pt3dadd(255.5, -702, 19.5, 2.2, sec = self.dend[177]) h.pt3dadd(253.5, -706.5, 19.5, 2.2, sec = self.dend[177]) h.pt3dadd(255.5, -713.5, 19.5, 2.2, sec = self.dend[177]) h.pt3dadd(259, -721, 20, 2.6, sec = self.dend[177]) h.pt3dadd(260.5, -725.5, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(264, -728, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(267.5, -734, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(267.5, -739.5, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(268, -743, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(268.5, -746, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(272.5, -749.5, 19.5, 2.9, sec = self.dend[177]) h.pt3dadd(271.5, -752.5, 19.5, 3.5, sec = self.dend[177]) h.pt3dadd(271.5, -756.5, 19.5, 3.2, sec = self.dend[177]) h.pt3dadd(271.5, -760.5, 19.5, 2.8, sec = self.dend[177]) h.pt3dadd(270.5, -763.5, 19.5, 3.1, sec = self.dend[177]) h.pt3dadd(270.5, -765.5, 19.5, 2.5, sec = self.dend[177]) h.pt3dadd(270.5, -768, 19.5, 2.1, sec = self.dend[177]) h.pt3dadd(271, -770, 22, 1.6, sec = self.dend[177]) h.pt3dadd(272, -773, 20, 1.6, sec = self.dend[177]) h.pt3dadd(271, -775.5, 22, 3.5, sec = self.dend[177]) h.pt3dadd(271, -779, 22, 2.8, sec = self.dend[177]) h.pt3dadd(270.5, -781, 22, 2.4, sec = self.dend[177]) h.pt3dadd(270.5, -783, 22, 2.1, sec = self.dend[177]) h.pt3dadd(271, -786, 21, 2.2, sec = self.dend[177]) h.pt3dadd(271, -789.5, 21, 2.7, sec = self.dend[177]) h.pt3dadd(271, -792.5, 21, 2.8, sec = self.dend[177]) h.pt3dadd(271.5, -797, 21, 2.7, sec = self.dend[177]) h.pt3dadd(272, -800.5, 21, 2.2, sec = self.dend[177]) h.pt3dadd(272, -801.5, 21, 1.8, sec = self.dend[177]) h.pt3dadd(270.5, -803, 21, 2.7, sec = self.dend[177]) h.pt3dadd(270, -807, 21, 3.3, sec = self.dend[177]) h.pt3dadd(269, -810, 21, 2.2, sec = self.dend[177]) h.pt3dadd(269, -811, 21, 1.9, sec = self.dend[177]) h.pt3dadd(270.5, -814.5, 21, 2.4, sec = self.dend[177]) h.pt3dadd(271.5, -818.5, 22, 1.7, sec = self.dend[177]) h.pt3dadd(273, -825.5, 22, 1.6, sec = self.dend[177]) h.pt3dadd(273, -830, 22, 1.6, sec = self.dend[177]) h.pt3dadd(273, -837, 22, 1.6, sec = self.dend[177]) h.pt3dadd(274.5, -841, 25, 1.7, sec = self.dend[177]) h.pt3dadd(276, -846.5, 21, 1.7, sec = self.dend[177]) h.pt3dadd(276.5, -852, 22, 1.7, sec = self.dend[177]) h.pt3dadd(277.5, -854.5, 21, 1.7, sec = self.dend[177]) h.pt3dadd(280.5, -860.5, 22, 1.7, sec = self.dend[177]) h.pt3dadd(281, -864, 22, 1.7, sec = self.dend[177]) h.pt3dadd(283.5, -868, 22, 1.6, sec = self.dend[177]) h.pt3dadd(284.5, -871, 22, 1.6, sec = self.dend[177]) h.pt3dadd(287, -875.5, 22, 1.6, sec = self.dend[177]) h.pt3dadd(289, -878, 22, 1.6, sec = self.dend[177]) h.pt3dadd(289.5, -881, 22, 1.6, sec = self.dend[177]) h.pt3dadd(290.5, -883, 19.5, 1.6, sec = self.dend[177]) h.pt3dadd(291, -886.5, 12, 1.6, sec = self.dend[177]) h.pt3dadd(291.5, -888.5, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(289.5, -892.5, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(289.5, -899, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(289.5, -906, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(288.5, -910.5, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(289, -915.5, 17.5, 1.6, sec = self.dend[177]) h.pt3dadd(290.5, -918, 17.5, 1.8, sec = self.dend[177]) h.pt3dadd(289, -922, 17.5, 3.4, sec = self.dend[177]) h.pt3dadd(289.5, -926.5, 17.5, 3.7, sec = self.dend[177]) h.pt3dadd(289.5, -929, 17.5, 2.7, sec = self.dend[177]) h.pt3dadd(288, -931.5, 17.5, 1.9, sec = self.dend[177]) h.pt3dadd(288, -934, 17.5, 1.8, sec = self.dend[177]) h.pt3dadd(288.5, -936, 23, 2, sec = self.dend[177]) h.pt3dadd(288.5, -937, 24, 2.7, sec = self.dend[177]) h.pt3dadd(288, -940, 20, 0.9, sec = self.dend[177]) h.pt3dadd(288, -942, 20, 0.9, sec = self.dend[177]) h.pt3dadd(288, -943.5, 20, 1.4, sec = self.dend[177]) h.pt3dadd(288, -945.5, 20, 1.8, sec = self.dend[177]) h.pt3dadd(287.5, -949.5, 20, 2, sec = self.dend[177]) h.pt3dadd(286.5, -950.5, 20, 0.9, sec = self.dend[177]) h.pt3dadd(286.5, -955.5, 20, 1.1, sec = self.dend[177]) h.pt3dadd(286, -958.5, 20, 2, sec = self.dend[177]) h.pt3dadd(286, -962, 14, 2.6, sec = self.dend[177]) h.pt3dadd(286, -966.5, 14, 2.6, sec = self.dend[177]) h.pt3dadd(288, -968.5, 14, 2.6, sec = self.dend[177]) h.pt3dadd(286.5, -973, 14, 2.1, sec = self.dend[177]) h.pt3dadd(286.5, -976, 14, 2.1, sec = self.dend[177]) h.pt3dadd(285.5, -979.5, 14, 2.1, sec = self.dend[177]) h.pt3dadd(285.5, -984.5, 14, 1.8, sec = self.dend[177]) h.pt3dadd(285.5, -986.5, 14, 0.8, sec = self.dend[177]) h.pt3dadd(286, -992, 14, 0.9, sec = self.dend[177]) h.pt3dadd(286, -997.5, 14, 0.9, sec = self.dend[177]) h.pt3dadd(286, -1001.5, 14, 0.9, sec = self.dend[177]) h.pt3dadd(285.5, -1005.5, 8.5, 0.7, sec = self.dend[177]) h.pt3dadd(285.5, -1009, 8.5, 1, sec = self.dend[177]) h.pt3dadd(286, -1013, 8.5, 1.3, sec = self.dend[177]) h.pt3dadd(285, -1018.5, 8.5, 1.3, sec = self.dend[177]) h.pt3dadd(285.5, -1025, 7.5, 1.1, sec = self.dend[177]) h.pt3dadd(285.5, -1028, 7.5, 0.9, sec = self.dend[177]) h.pt3dadd(285.5, -1029.5, 7.5, 0.7, sec = self.dend[177]) h.pt3dadd(286.5, -1031.5, 6.5, 0.9, sec = self.dend[177]) h.pt3dadd(286.5, -1035.5, 6.5, 1.2, sec = self.dend[177]) h.pt3dadd(286, -1039.5, 6.5, 1.8, sec = self.dend[177]) h.pt3dadd(285, -1043.5, 6.5, 0.8, sec = self.dend[177]) h.pt3dadd(283, -1047.5, 6.5, 1, sec = self.dend[177]) h.pt3dadd(282.5, -1053, 6.5, 0.9, sec = self.dend[177]) h.pt3dadd(282.5, -1057, 6.5, 0.9, sec = self.dend[177]) h.pt3dadd(281.5, -1061.5, 6.5, 0.9, sec = self.dend[177]) h.pt3dadd(281.5, -1067, 6.5, 0.7, sec = self.dend[177]) h.pt3dadd(280.5, -1068.5, 6.5, 0.5, sec = self.dend[177]) h.pt3dadd(280, -1071.5, 7.5, 0.5, sec = self.dend[177]) h.pt3dadd(281, -1074.5, 17.5, 0.9, sec = self.dend[177]) h.pt3dadd(281, -1076.5, 21, 0.3, sec = self.dend[177]) h.pt3dadd(280, -1080, 22, 0.3, sec = self.dend[177]) h.pt3dadd(280, -1081, 21, 0.3, sec = self.dend[177]) h.pt3dadd(282, -1089, 22, 0.2, sec = self.dend[177]) h.pt3dadd(280.5, -1093.5, 22, 0.2, sec = self.dend[177]) h.pt3dadd(279.5, -1096, 22, 0.1, sec = self.dend[177]) h.pt3dadd(277, -1098.5, 22, 0.1, sec = self.dend[177]) h.pt3dadd(277, -1101, 22, 1.4, sec = self.dend[177]) h.pt3dadd(278, -1101, 15.5, 1.4, sec = self.dend[177]) h.pt3dadd(278, -1104.5, 16.5, 0.7, sec = self.dend[177]) h.pt3dadd(278.5, -1110, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(278.5, -1116, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(278.5, -1121, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(278.5, -1125, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(278.5, -1129.5, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(278, -1131.5, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(277.5, -1137, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(277, -1141.5, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(276, -1147, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(277, -1149, 16.5, 2.1, sec = self.dend[177]) h.pt3dadd(276.5, -1150, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(276.5, -1155, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(275, -1160, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(276, -1161.5, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(276, -1164, 17.5, 1.4, sec = self.dend[177]) h.pt3dadd(275.5, -1165.5, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(275.5, -1172, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(274.5, -1177.5, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(274.5, -1183, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(274, -1190, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(274, -1194.5, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(275, -1200, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(276, -1203.5, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(274, -1205.5, 18.5, 2.1, sec = self.dend[177]) h.pt3dadd(271.5, -1206, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(269, -1210.5, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(269, -1218, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(268, -1224, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(265.5, -1229.5, 17.5, 0.1, sec = self.dend[177]) h.pt3dadd(263.5, -1236, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(261.5, -1243, 16.5, 0.1, sec = self.dend[177]) h.pt3dadd(261.5, -1246.5, 9.5, 0.1, sec = self.dend[177]) h.pt3dadd(263, -1253, 11, 0.1, sec = self.dend[177]) h.pt3dadd(263, -1260.5, 11, 0.1, sec = self.dend[177]) h.pt3dadd(263, -1266.5, 11, 0.1, sec = self.dend[177]) h.pt3dadd(261, -1271, 11, 0.1, sec = self.dend[177]) h.pt3dadd(261, -1276.5, 11, 0.1, sec = self.dend[177]) h.pt3dadd(260.5, -1278, 12, 0.1, sec = self.dend[177]) h.pt3dadd(260.5, -1283, 12, 0.1, sec = self.dend[177]) h.pt3dadd(260.5, -1287, 12, 0.1, sec = self.dend[177]) h.pt3dadd(261, -1290, 13, 1.8, sec = self.dend[177]) h.pt3dadd(257.5, -1294, 11, 0.1, sec = self.dend[177]) h.pt3dadd(256.5, -1301.5, 11, 0.1, sec = self.dend[177]) h.pt3dadd(256.5, -1308, 11, 0.1, sec = self.dend[177]) h.pt3dadd(256.5, -1313, 11, 0.1, sec = self.dend[177]) h.pt3dadd(256.5, -1318.5, 12, 0.1, sec = self.dend[177]) h.pt3dadd(256.5, -1324, 13, 0.1, sec = self.dend[177]) h.pt3dadd(255, -1328, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(255.5, -1332.5, 15, 0.1, sec = self.dend[177]) h.pt3dadd(255.5, -1338, 15.5, 0.1, sec = self.dend[177]) h.pt3dadd(252.5, -1340.5, 19.5, 0.1, sec = self.dend[177]) h.pt3dclear(sec = self.dend[178]) h.pt3dadd(198, -161.5, -2, 6, sec = self.dend[178]) h.pt3dadd(200.5, -164, -5, 3.2, sec = self.dend[178]) h.pt3dadd(204, -166.5, -5, 3.2, sec = self.dend[178]) h.pt3dadd(206.5, -166.5, -5.5, 4.3, sec = self.dend[178]) h.pt3dadd(209.5, -165.5, -6.5, 5, sec = self.dend[178]) h.pt3dadd(213.5, -166, -5, 4.1, sec = self.dend[178]) h.pt3dadd(216.5, -166.5, -5, 3.7, sec = self.dend[178]) h.pt3dadd(219, -168, -5, 3.7, sec = self.dend[178]) h.pt3dadd(220.5, -169, -6.5, 4, sec = self.dend[178]) h.pt3dadd(221.5, -170.5, -5.5, 3.6, sec = self.dend[178]) h.pt3dadd(223.5, -171, -5.5, 3.6, sec = self.dend[178]) h.pt3dadd(226.5, -173, -5.5, 3.8, sec = self.dend[178]) h.pt3dadd(229.5, -175.5, -5.5, 3.7, sec = self.dend[178]) h.pt3dadd(231.5, -178, -5, 2.7, sec = self.dend[178]) h.pt3dadd(232, -178, -5, 2.5, sec = self.dend[178]) h.pt3dadd(234, -178, -5.5, 2.5, sec = self.dend[178]) h.pt3dadd(235.5, -181.5, -5.5, 2.8, sec = self.dend[178]) h.pt3dadd(236, -184.5, -5.5, 3.1, sec = self.dend[178]) h.pt3dadd(238.5, -184.5, -5.5, 4.3, sec = self.dend[178]) h.pt3dadd(239.5, -185, -5.5, 4.3, sec = self.dend[178]) h.pt3dadd(241.5, -188, -10, 4.6, sec = self.dend[178]) h.pt3dadd(242, -190.5, -12, 4.6, sec = self.dend[178]) h.pt3dadd(244, -191.5, -11, 4.9, sec = self.dend[178]) h.pt3dadd(246.5, -194, -11, 4.6, sec = self.dend[178]) h.pt3dadd(250, -197.5, -11, 3.8, sec = self.dend[178]) h.pt3dadd(252, -200, -11, 2.7, sec = self.dend[178]) h.pt3dadd(253.5, -202.5, -11, 2.5, sec = self.dend[178]) h.pt3dadd(254.5, -206, -12, 2.5, sec = self.dend[178]) h.pt3dadd(255, -207.5, -11, 2.5, sec = self.dend[178]) h.pt3dadd(257, -208.5, -12, 2.5, sec = self.dend[178]) h.pt3dadd(257, -208.5, -11, 2.5, sec = self.dend[178]) h.pt3dadd(258, -210.5, -14.5, 2.8, sec = self.dend[178]) h.pt3dadd(260.5, -210, -14.5, 2.8, sec = self.dend[178]) h.pt3dadd(261, -212, -15.5, 2.8, sec = self.dend[178]) h.pt3dadd(262.5, -215, -15.5, 2.8, sec = self.dend[178]) h.pt3dadd(263.5, -216.5, -15.5, 2.8, sec = self.dend[178]) h.pt3dadd(264, -218.5, -15.5, 2.7, sec = self.dend[178]) h.pt3dadd(266.5, -219, -15.5, 2.7, sec = self.dend[178]) h.pt3dadd(267.5, -220, -16.5, 2.5, sec = self.dend[178]) h.pt3dadd(270, -221, -16.5, 2.7, sec = self.dend[178]) h.pt3dadd(271, -222.5, -16.5, 3.5, sec = self.dend[178]) h.pt3dadd(273, -224, -19, 3.6, sec = self.dend[178]) h.pt3dadd(276, -225, -19, 3.8, sec = self.dend[178]) h.pt3dadd(278, -227.5, -19, 4.4, sec = self.dend[178]) h.pt3dadd(281.5, -229, -19, 4.6, sec = self.dend[178]) h.pt3dadd(282, -231.5, -19, 4.6, sec = self.dend[178]) h.pt3dadd(286, -237.5, -20, 3.1, sec = self.dend[178]) h.pt3dadd(290.5, -240, -20, 3.1, sec = self.dend[178]) h.pt3dadd(293.5, -242.5, -20, 3.1, sec = self.dend[178]) h.pt3dadd(296.5, -245, -20, 3.8, sec = self.dend[178]) h.pt3dadd(299, -246.5, -20, 3.8, sec = self.dend[178]) h.pt3dadd(302, -248, -20, 3.4, sec = self.dend[178]) h.pt3dadd(304, -248.5, -21.5, 3.3, sec = self.dend[178]) h.pt3dadd(306.5, -250.5, -21, 2.5, sec = self.dend[178]) h.pt3dadd(309, -250.5, -21, 2, sec = self.dend[178]) h.pt3dadd(311.5, -250.5, -21, 2.2, sec = self.dend[178]) h.pt3dadd(313, -250.5, -21, 2.6, sec = self.dend[178]) h.pt3dadd(315.5, -252.5, -22, 3.1, sec = self.dend[178]) h.pt3dadd(318.5, -252.5, -22, 4, sec = self.dend[178]) h.pt3dadd(321, -255, -21, 3.5, sec = self.dend[178]) h.pt3dadd(323.5, -256.5, -23, 3.1, sec = self.dend[178]) h.pt3dadd(326.5, -258, -22, 1.9, sec = self.dend[178]) h.pt3dadd(328, -258, -23, 1.5, sec = self.dend[178]) h.pt3dadd(329.5, -259, -23, 1.5, sec = self.dend[178]) h.pt3dadd(331.5, -261, -23, 2.7, sec = self.dend[178]) h.pt3dadd(334.5, -261, -23, 4, sec = self.dend[178]) h.pt3dadd(337, -262.5, -22, 4.6, sec = self.dend[178]) h.pt3dclear(sec = self.dend[179]) h.pt3dadd(337, -262.5, -22, 4.6, sec = self.dend[179]) h.pt3dadd(340.5, -260.5, -23, 1, sec = self.dend[179]) h.pt3dadd(343.5, -260, -23, 1.3, sec = self.dend[179]) h.pt3dadd(344.5, -259, -23, 1.3, sec = self.dend[179]) h.pt3dadd(346, -259, -23, 1.6, sec = self.dend[179]) h.pt3dadd(348.5, -258.5, -23, 2.3, sec = self.dend[179]) h.pt3dadd(350.5, -258.5, -24, 3.4, sec = self.dend[179]) h.pt3dadd(353.5, -259.5, -24, 1.5, sec = self.dend[179]) h.pt3dadd(355.5, -260, -24, 0.9, sec = self.dend[179]) h.pt3dadd(357, -260, -24, 0.9, sec = self.dend[179]) h.pt3dadd(358, -260.5, -23.5, 1.7, sec = self.dend[179]) h.pt3dadd(359, -262.5, -23, 1.9, sec = self.dend[179]) h.pt3dadd(361.5, -264, -23, 1.1, sec = self.dend[179]) h.pt3dadd(365, -264, -29.5, 2, sec = self.dend[179]) h.pt3dadd(366.5, -264, -29.5, 2, sec = self.dend[179]) h.pt3dadd(368, -265, -29.5, 1.8, sec = self.dend[179]) h.pt3dadd(369, -266, -29.5, 1.7, sec = self.dend[179]) h.pt3dadd(369.5, -266, -29.5, 1.4, sec = self.dend[179]) h.pt3dadd(371, -266, -29.5, 1.8, sec = self.dend[179]) h.pt3dadd(372.5, -266, -29.5, 1.8, sec = self.dend[179]) h.pt3dadd(373.5, -267.5, -29.5, 2.3, sec = self.dend[179]) h.pt3dadd(374, -270, -35.5, 2.3, sec = self.dend[179]) h.pt3dadd(376, -270, -35.5, 2.1, sec = self.dend[179]) h.pt3dadd(377, -270, -35.5, 2, sec = self.dend[179]) h.pt3dadd(377, -271, -35.5, 1.2, sec = self.dend[179]) h.pt3dadd(379.5, -272, -35.5, 2.5, sec = self.dend[179]) h.pt3dadd(380, -272, -35.5, 3, sec = self.dend[179]) h.pt3dadd(381.5, -272.5, -35.5, 1.7, sec = self.dend[179]) h.pt3dadd(382.5, -273, -35.5, 0.8, sec = self.dend[179]) h.pt3dadd(385, -272.5, -35.5, 0.8, sec = self.dend[179]) h.pt3dadd(385, -275, -35.5, 0.8, sec = self.dend[179]) h.pt3dadd(386, -276, -35.5, 0.8, sec = self.dend[179]) h.pt3dadd(386.5, -276, -35.5, 1.8, sec = self.dend[179]) h.pt3dadd(387.5, -277.5, -35.5, 2.6, sec = self.dend[179]) h.pt3dadd(389, -280, -42, 1.9, sec = self.dend[179]) h.pt3dadd(390, -282, -48, 1.8, sec = self.dend[179]) h.pt3dadd(391, -283, -48, 2.6, sec = self.dend[179]) h.pt3dadd(392.5, -283, -48, 3.1, sec = self.dend[179]) h.pt3dadd(393.5, -284.5, -48, 2.8, sec = self.dend[179]) h.pt3dadd(396, -286, -54.5, 2.1, sec = self.dend[179]) h.pt3dadd(397.5, -288, -54.5, 1.6, sec = self.dend[179]) h.pt3dadd(400, -290, -54.5, 1.4, sec = self.dend[179]) h.pt3dadd(401.5, -292, -56, 0.3, sec = self.dend[179]) h.pt3dadd(401, -294, -48.5, 0.3, sec = self.dend[179]) h.pt3dadd(404.5, -294, -56, 2.3, sec = self.dend[179]) h.pt3dadd(406, -294.5, -56, 2.8, sec = self.dend[179]) h.pt3dadd(406, -295.5, -60, 1.9, sec = self.dend[179]) h.pt3dadd(407.5, -297, -60, 0.6, sec = self.dend[179]) h.pt3dadd(409.5, -297, -60, 0.6, sec = self.dend[179]) h.pt3dadd(409.5, -299, -60, 0.6, sec = self.dend[179]) h.pt3dadd(411.5, -299.5, -58, 0.7, sec = self.dend[179]) h.pt3dadd(414.5, -299, -62, 0.8, sec = self.dend[179]) h.pt3dadd(414.5, -300, -60, 0.8, sec = self.dend[179]) h.pt3dadd(415, -302, -60, 1.6, sec = self.dend[179]) h.pt3dadd(417, -302.5, -58, 3.1, sec = self.dend[179]) h.pt3dadd(418, -303.5, -62, 3.4, sec = self.dend[179]) h.pt3dadd(419, -305, -62, 2.4, sec = self.dend[179]) h.pt3dadd(419.5, -306, -64, 1, sec = self.dend[179]) h.pt3dadd(420, -306, -66, 0.4, sec = self.dend[179]) h.pt3dadd(421.5, -308, -66, 0.4, sec = self.dend[179]) h.pt3dadd(422, -308, -66, 0.4, sec = self.dend[179]) h.pt3dadd(423.5, -308.5, -64, 0.7, sec = self.dend[179]) h.pt3dadd(425, -308.5, -64, 1.2, sec = self.dend[179]) h.pt3dadd(425.5, -309.5, -64, 1.8, sec = self.dend[179]) h.pt3dadd(426, -311.5, -64, 1.4, sec = self.dend[179]) h.pt3dadd(427, -312, -66, 1.1, sec = self.dend[179]) h.pt3dadd(428, -314, -66, 0.6, sec = self.dend[179]) h.pt3dadd(430.5, -315.5, -66, 0.9, sec = self.dend[179]) h.pt3dadd(432, -317.5, -66, 0.9, sec = self.dend[179]) h.pt3dadd(432.5, -318.5, -66, 0.9, sec = self.dend[179]) h.pt3dadd(434, -320, -67.5, 1.2, sec = self.dend[179]) h.pt3dadd(434.5, -321, -67.5, 1.9, sec = self.dend[179]) h.pt3dadd(436.5, -324, -67.5, 1.6, sec = self.dend[179]) h.pt3dadd(437.5, -325, -71.5, 1.2, sec = self.dend[179]) h.pt3dadd(438, -325, -71.5, 0.6, sec = self.dend[179]) h.pt3dadd(439, -326.5, -73.5, 0.7, sec = self.dend[179]) h.pt3dadd(440.5, -327, -71.5, 1.4, sec = self.dend[179]) h.pt3dadd(441.5, -328.5, -71.5, 2, sec = self.dend[179]) h.pt3dadd(441.5, -330, -73.5, 1.6, sec = self.dend[179]) h.pt3dadd(442.5, -331, -71.5, 1.3, sec = self.dend[179]) h.pt3dadd(445.5, -331.5, -71.5, 0.4, sec = self.dend[179]) h.pt3dadd(445, -332.5, -71.5, 0.9, sec = self.dend[179]) h.pt3dadd(446, -333.5, -77.5, 1.1, sec = self.dend[179]) h.pt3dadd(447.5, -334.5, -77.5, 1.8, sec = self.dend[179]) h.pt3dadd(449, -336.5, -80.5, 1.1, sec = self.dend[179]) h.pt3dadd(449.5, -336.5, -83.5, 0.8, sec = self.dend[179]) h.pt3dadd(451.5, -338, -80.5, 0.8, sec = self.dend[179]) h.pt3dadd(452.5, -340, -80.5, 0.6, sec = self.dend[179]) h.pt3dadd(452.5, -341.5, -83.5, 0.4, sec = self.dend[179]) h.pt3dadd(452.5, -343, -83.5, 1.9, sec = self.dend[179]) h.pt3dadd(454, -345, -83.5, 2.5, sec = self.dend[179]) h.pt3dadd(454, -346.5, -83.5, 1.8, sec = self.dend[179]) h.pt3dadd(454.5, -348.5, -83.5, 1.1, sec = self.dend[179]) h.pt3dadd(453.5, -348.5, -83.5, 0.6, sec = self.dend[179]) h.pt3dadd(454, -350, -86.5, 0.6, sec = self.dend[179]) h.pt3dadd(454.5, -351, -83.5, 1.1, sec = self.dend[179]) h.pt3dadd(454.5, -353, -83.5, 1.9, sec = self.dend[179]) h.pt3dadd(455, -354, -83.5, 1.7, sec = self.dend[179]) h.pt3dadd(454.5, -356, -86.5, 0.5, sec = self.dend[179]) h.pt3dadd(454.5, -357.5, -86.5, 0.7, sec = self.dend[179]) h.pt3dadd(454, -359.5, -86.5, 0.7, sec = self.dend[179]) h.pt3dadd(453.5, -362.5, -86.5, 1.4, sec = self.dend[179]) h.pt3dadd(455, -365, -86.5, 1.2, sec = self.dend[179]) h.pt3dadd(455, -365, -89, 0.6, sec = self.dend[179]) h.pt3dadd(456.5, -366.5, -89, 0.6, sec = self.dend[179]) h.pt3dadd(457.5, -368, -89, 0.7, sec = self.dend[179]) h.pt3dadd(457.5, -370.5, -89, 0.5, sec = self.dend[179]) h.pt3dadd(458.5, -372, -89, 0.5, sec = self.dend[179]) h.pt3dadd(460, -373, -86.5, 0.4, sec = self.dend[179]) h.pt3dadd(461, -374.5, -89, 0.3, sec = self.dend[179]) h.pt3dadd(462, -375.5, -89, 0.5, sec = self.dend[179]) h.pt3dadd(463.5, -378, -89, 2.2, sec = self.dend[179]) h.pt3dadd(464.5, -378.5, -89, 0.9, sec = self.dend[179]) h.pt3dadd(466, -380.5, -89, 0.3, sec = self.dend[179]) h.pt3dadd(468, -381, -89, 0.1, sec = self.dend[179]) h.pt3dadd(469.5, -383.5, -92, 0.1, sec = self.dend[179]) h.pt3dadd(471, -383.5, -92, 0.1, sec = self.dend[179]) h.pt3dadd(471.5, -385, -92, 1.2, sec = self.dend[179]) h.pt3dadd(475, -387, -92, 1.9, sec = self.dend[179]) h.pt3dadd(476, -387, -95, 1.6, sec = self.dend[179]) h.pt3dadd(477.5, -387, -92, 1.3, sec = self.dend[179]) h.pt3dadd(480, -387, -95, 0.9, sec = self.dend[179]) h.pt3dadd(484.5, -389.5, -93, 0.7, sec = self.dend[179]) h.pt3dadd(486, -390, -93, 0.7, sec = self.dend[179]) h.pt3dadd(487, -392, -100, 1.6, sec = self.dend[179]) h.pt3dadd(487.5, -392.5, -97.5, 2.6, sec = self.dend[179]) h.pt3dadd(488.5, -396, -95, 1.4, sec = self.dend[179]) h.pt3dadd(489, -396, -100, 1, sec = self.dend[179]) h.pt3dadd(490, -398.5, -100, 1, sec = self.dend[179]) h.pt3dadd(490.5, -398.5, -100, 1, sec = self.dend[179]) h.pt3dadd(492.5, -400, -97.5, 1, sec = self.dend[179]) h.pt3dadd(492.5, -401.5, -100, 0.8, sec = self.dend[179]) h.pt3dadd(492.5, -403, -102.5, 0.8, sec = self.dend[179]) h.pt3dadd(493, -403, -100, 1.1, sec = self.dend[179]) h.pt3dadd(492, -404.5, -109.5, 1.6, sec = self.dend[179]) h.pt3dadd(493.5, -406, -114, 1.6, sec = self.dend[179]) h.pt3dadd(496, -406, -119, 1.6, sec = self.dend[179]) h.pt3dadd(494, -408, -112, 1.6, sec = self.dend[179]) h.pt3dadd(492, -408, -112, 1.6, sec = self.dend[179]) h.pt3dadd(490, -408, -123.5, 1.6, sec = self.dend[179]) h.pt3dclear(sec = self.dend[180]) h.pt3dadd(337, -262.5, -22, 4.6, sec = self.dend[180]) h.pt3dadd(339.5, -266, -24, 1.5, sec = self.dend[180]) h.pt3dadd(341.5, -268, -23.5, 1.9, sec = self.dend[180]) h.pt3dadd(344, -270.5, -24, 1.9, sec = self.dend[180]) h.pt3dadd(346.5, -273, -24, 2.1, sec = self.dend[180]) h.pt3dadd(347.5, -275, -24, 3.1, sec = self.dend[180]) h.pt3dadd(348.5, -278, -25, 3.8, sec = self.dend[180]) h.pt3dadd(350.5, -278, -25.5, 2.5, sec = self.dend[180]) h.pt3dadd(353.5, -280.5, -26, 1.4, sec = self.dend[180]) h.pt3dadd(355.5, -281, -26, 1.2, sec = self.dend[180]) h.pt3dadd(356.5, -284.5, -26, 1, sec = self.dend[180]) h.pt3dadd(359, -285, -27, 1, sec = self.dend[180]) h.pt3dadd(362, -287, -33, 1.8, sec = self.dend[180]) h.pt3dadd(362.5, -289, -33, 2.4, sec = self.dend[180]) h.pt3dadd(364.5, -289, -33, 2.8, sec = self.dend[180]) h.pt3dadd(366, -290.5, -33, 2.1, sec = self.dend[180]) h.pt3dadd(367.5, -291, -33, 1.4, sec = self.dend[180]) h.pt3dadd(370, -292, -33, 1.4, sec = self.dend[180]) h.pt3dadd(372, -292, -33, 2.4, sec = self.dend[180]) h.pt3dadd(373, -292, -33, 2.5, sec = self.dend[180]) h.pt3dadd(375, -292, -33, 2.7, sec = self.dend[180]) h.pt3dadd(376.5, -293, -33, 2.7, sec = self.dend[180]) h.pt3dadd(379, -293, -33, 1.6, sec = self.dend[180]) h.pt3dadd(381.5, -293.5, -39.5, 1.4, sec = self.dend[180]) h.pt3dadd(384, -293.5, -39.5, 1.7, sec = self.dend[180]) h.pt3dadd(385, -293.5, -39.5, 2.1, sec = self.dend[180]) h.pt3dadd(388, -293.5, -39.5, 2.6, sec = self.dend[180]) h.pt3dadd(390, -294, -39.5, 2.5, sec = self.dend[180]) h.pt3dadd(392, -294, -39.5, 1.5, sec = self.dend[180]) h.pt3dadd(393.5, -294.5, -39.5, 2, sec = self.dend[180]) h.pt3dadd(395.5, -294.5, -39.5, 2.5, sec = self.dend[180]) h.pt3dadd(397.5, -294.5, -39.5, 2.5, sec = self.dend[180]) h.pt3dadd(400, -294.5, -39.5, 1.6, sec = self.dend[180]) h.pt3dadd(402, -294, -39.5, 1.6, sec = self.dend[180]) h.pt3dadd(403.5, -293.5, -39.5, 1.6, sec = self.dend[180]) h.pt3dadd(405.5, -293.5, -39.5, 1.4, sec = self.dend[180]) h.pt3dadd(409, -296, -45.5, 1.3, sec = self.dend[180]) h.pt3dadd(410.5, -296.5, -39.5, 1, sec = self.dend[180]) h.pt3dadd(412.5, -296.5, -39.5, 2.2, sec = self.dend[180]) h.pt3dadd(414.5, -297, -39.5, 3.3, sec = self.dend[180]) h.pt3dadd(417, -298, -45.5, 2.2, sec = self.dend[180]) h.pt3dadd(418.5, -300.5, -45.5, 1.6, sec = self.dend[180]) h.pt3dadd(418, -300.5, -45.5, 1.3, sec = self.dend[180]) h.pt3dadd(421, -300.5, -52, 1.5, sec = self.dend[180]) h.pt3dadd(423.5, -301, -52, 1.5, sec = self.dend[180]) h.pt3dadd(425.5, -301.5, -52, 2.2, sec = self.dend[180]) h.pt3dadd(427, -301.5, -52, 4.3, sec = self.dend[180]) h.pt3dadd(429, -305, -45.5, 2.3, sec = self.dend[180]) h.pt3dadd(431.5, -306, -52, 1.5, sec = self.dend[180]) h.pt3dadd(435, -307, -52, 1.3, sec = self.dend[180]) h.pt3dadd(437, -309, -52, 1.8, sec = self.dend[180]) h.pt3dadd(438.5, -311, -45.5, 1.9, sec = self.dend[180]) h.pt3dadd(439.5, -310.5, -45.5, 3.1, sec = self.dend[180]) h.pt3dadd(441.5, -310.5, -52, 2.8, sec = self.dend[180]) h.pt3dadd(442.5, -310.5, -52, 1.6, sec = self.dend[180]) h.pt3dadd(443.5, -310, -52, 1.1, sec = self.dend[180]) h.pt3dadd(445, -308, -52, 1.1, sec = self.dend[180]) h.pt3dadd(445.5, -305, -58, 1.2, sec = self.dend[180]) h.pt3dadd(448.5, -306, -58, 1.3, sec = self.dend[180]) h.pt3dadd(450, -306, -63.5, 1.3, sec = self.dend[180]) h.pt3dadd(453, -306.5, -63.5, 1.3, sec = self.dend[180]) h.pt3dadd(454.5, -308, -63.5, 1.3, sec = self.dend[180]) h.pt3dadd(457.5, -308, -61.5, 1.7, sec = self.dend[180]) h.pt3dadd(462.5, -310, -61.5, 1.3, sec = self.dend[180]) h.pt3dadd(463, -310.5, -61.5, 1.5, sec = self.dend[180]) h.pt3dadd(466, -312, -60, 1.5, sec = self.dend[180]) h.pt3dadd(468.5, -312, -63.5, 1.5, sec = self.dend[180]) h.pt3dadd(472, -312, -63.5, 1.5, sec = self.dend[180]) h.pt3dadd(475, -313, -65.5, 0.9, sec = self.dend[180]) h.pt3dadd(477.5, -313, -65.5, 0.8, sec = self.dend[180]) h.pt3dadd(480.5, -313, -65.5, 0.8, sec = self.dend[180]) h.pt3dadd(483, -314.5, -63.5, 1.8, sec = self.dend[180]) h.pt3dadd(486.5, -315, -63.5, 3, sec = self.dend[180]) h.pt3dadd(487, -316.5, -65.5, 1.6, sec = self.dend[180]) h.pt3dadd(488.5, -316.5, -67.5, 0.6, sec = self.dend[180]) h.pt3dadd(489.5, -317, -65.5, 2.7, sec = self.dend[180]) h.pt3dadd(494, -319, -67.5, 2.4, sec = self.dend[180]) h.pt3dclear(sec = self.dend[181]) h.pt3dadd(494, -319, -67.5, 2.4, sec = self.dend[181]) h.pt3dadd(496, -317, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(502, -317, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(505.5, -317, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(509, -319, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(512, -320, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(516, -320, -61.5, 0.1, sec = self.dend[181]) h.pt3dadd(519.5, -320, -65.5, 0.1, sec = self.dend[181]) h.pt3dadd(524, -319.5, -67.5, 0.1, sec = self.dend[181]) h.pt3dadd(528.5, -317, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(530, -315.5, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(533.5, -314.5, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(538, -314.5, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(541, -312.5, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(544, -311, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(547.5, -309, -69.5, 0.1, sec = self.dend[181]) h.pt3dadd(549.5, -305, -71.5, 0.1, sec = self.dend[181]) h.pt3dadd(549.5, -303, -71.5, 0.1, sec = self.dend[181]) h.pt3dadd(554, -302.5, -71.5, 0.1, sec = self.dend[181]) h.pt3dadd(559, -302.5, -71.5, 0.1, sec = self.dend[181]) h.pt3dadd(561, -300, -71.5, 0.1, sec = self.dend[181]) h.pt3dadd(561.5, -297.5, -73, 0.1, sec = self.dend[181]) h.pt3dclear(sec = self.dend[182]) h.pt3dadd(494, -319, -67.5, 2.4, sec = self.dend[182]) h.pt3dadd(498, -319, -71.5, 2.4, sec = self.dend[182]) h.pt3dadd(501.5, -319.5, -71.5, 0.6, sec = self.dend[182]) h.pt3dadd(503.5, -319.5, -73, 0.6, sec = self.dend[182]) h.pt3dadd(506, -322, -73, 0.6, sec = self.dend[182]) h.pt3dadd(508.5, -322, -71.5, 1.7, sec = self.dend[182]) h.pt3dadd(509.5, -322, -71.5, 4.3, sec = self.dend[182]) h.pt3dadd(513, -322.5, -75, 1.3, sec = self.dend[182]) h.pt3dadd(515, -322.5, -71.5, 0.9, sec = self.dend[182]) h.pt3dadd(517.5, -323.5, -75, 0.6, sec = self.dend[182]) h.pt3dadd(519, -324, -75, 1.6, sec = self.dend[182]) h.pt3dadd(520, -326.5, -71.5, 0.1, sec = self.dend[182]) h.pt3dadd(522.5, -328.5, -71.5, 0.1, sec = self.dend[182]) h.pt3dadd(523.5, -328, -71.5, 1.1, sec = self.dend[182]) h.pt3dadd(525, -329, -71.5, 0.1, sec = self.dend[182]) h.pt3dadd(529, -329, -75, 0.1, sec = self.dend[182]) h.pt3dadd(532.5, -329, -75, 0.1, sec = self.dend[182]) h.pt3dadd(535.5, -328.5, -71.5, 2.7, sec = self.dend[182]) h.pt3dadd(539.5, -324, -77, 0.3, sec = self.dend[182]) h.pt3dadd(543, -324, -77, 1.5, sec = self.dend[182]) h.pt3dadd(545, -325, -77, 1.7, sec = self.dend[182]) h.pt3dadd(546, -325, -80, 1.9, sec = self.dend[182]) h.pt3dadd(548, -325, -80, 1.9, sec = self.dend[182]) h.pt3dadd(549.5, -325.5, -80, 0.7, sec = self.dend[182]) h.pt3dadd(551, -325.5, -83, 0.7, sec = self.dend[182]) h.pt3dadd(551.5, -329, -83, 1.2, sec = self.dend[182]) h.pt3dadd(553.5, -329.5, -83, 1.9, sec = self.dend[182]) h.pt3dadd(554.5, -331.5, -83, 1.1, sec = self.dend[182]) h.pt3dadd(555, -331.5, -83, 0.7, sec = self.dend[182]) h.pt3dadd(557, -331.5, -83, 0.6, sec = self.dend[182]) h.pt3dadd(557.5, -333, -83, 1.6, sec = self.dend[182]) h.pt3dadd(558, -333, -89, 2.4, sec = self.dend[182]) h.pt3dadd(560, -334.5, -89, 0.7, sec = self.dend[182]) h.pt3dadd(560.5, -334.5, -89, 0.3, sec = self.dend[182]) h.pt3dadd(560.5, -335.5, -91.5, 0.3, sec = self.dend[182]) h.pt3dadd(560.5, -336.5, -94.5, 1.2, sec = self.dend[182]) h.pt3dadd(561, -338, -91.5, 1.6, sec = self.dend[182]) h.pt3dadd(563, -338.5, -94.5, 0.6, sec = self.dend[182]) h.pt3dadd(564, -339.5, -91.5, 1.8, sec = self.dend[182]) h.pt3dadd(565, -341.5, -94.5, 3.4, sec = self.dend[182]) h.pt3dadd(567, -341.5, -94.5, 1.8, sec = self.dend[182]) h.pt3dadd(567.5, -343, -97.5, 0.3, sec = self.dend[182]) h.pt3dadd(570, -343, -97.5, 0.3, sec = self.dend[182]) h.pt3dadd(571.5, -343.5, -94.5, 1.4, sec = self.dend[182]) h.pt3dadd(572.5, -345, -97.5, 1.7, sec = self.dend[182]) h.pt3dadd(573.5, -345, -97.5, 2.6, sec = self.dend[182]) h.pt3dadd(574.5, -346.5, -97.5, 1.4, sec = self.dend[182]) h.pt3dadd(575, -348, -97.5, 0.9, sec = self.dend[182]) h.pt3dadd(576.5, -348, -97.5, 0.4, sec = self.dend[182]) h.pt3dadd(580, -348, -97.5, 0.4, sec = self.dend[182]) h.pt3dadd(581.5, -348, -103.5, 1.4, sec = self.dend[182]) h.pt3dadd(582, -348, -97.5, 1.8, sec = self.dend[182]) h.pt3dadd(585, -348, -97.5, 0.4, sec = self.dend[182]) h.pt3dadd(586.5, -349, -103.5, 0.4, sec = self.dend[182]) h.pt3dadd(587.5, -349, -103.5, 1.6, sec = self.dend[182]) h.pt3dadd(589.5, -349.5, -103.5, 2.1, sec = self.dend[182]) h.pt3dadd(590.5, -349.5, -106.5, 0.9, sec = self.dend[182]) h.pt3dadd(592.5, -351.5, -97.5, 0.5, sec = self.dend[182]) h.pt3dadd(596.5, -352, -97.5, 0.8, sec = self.dend[182]) h.pt3dadd(597, -352.5, -95, 0.8, sec = self.dend[182]) h.pt3dadd(598, -353.5, -102, 0.8, sec = self.dend[182]) h.pt3dadd(602, -353, -102, 0.2, sec = self.dend[182]) h.pt3dadd(602, -355, -104.5, 0.2, sec = self.dend[182]) h.pt3dadd(602.5, -358, -104.5, 0.2, sec = self.dend[182]) h.pt3dadd(603, -358, -107, 0.2, sec = self.dend[182]) h.pt3dadd(605, -358.5, -102, 1, sec = self.dend[182]) h.pt3dadd(606, -357, -107, 1.6, sec = self.dend[182]) h.pt3dadd(608, -357.5, -107, 1.9, sec = self.dend[182]) h.pt3dadd(608.5, -358, -107, 1.4, sec = self.dend[182]) h.pt3dadd(610, -359, -107, 1.1, sec = self.dend[182]) h.pt3dadd(610.5, -359, -107, 0.1, sec = self.dend[182]) h.pt3dadd(613, -359, -111.5, 0.1, sec = self.dend[182]) h.pt3dadd(615, -357.5, -111.5, 0.1, sec = self.dend[182]) h.pt3dadd(616.5, -357.5, -111.5, 1.9, sec = self.dend[182]) h.pt3dadd(618.5, -357.5, -109, 3.3, sec = self.dend[182]) h.pt3dadd(621, -357.5, -111.5, 1.8, sec = self.dend[182]) h.pt3dadd(622.5, -357.5, -111.5, 0.6, sec = self.dend[182]) h.pt3dadd(624, -357.5, -114, 0.7, sec = self.dend[182]) h.pt3dadd(626, -357.5, -114, 1.6, sec = self.dend[182]) h.pt3dadd(627.5, -358, -111.5, 2.2, sec = self.dend[182]) h.pt3dadd(628, -359, -111.5, 1.3, sec = self.dend[182]) h.pt3dadd(630.5, -359, -114, 0.7, sec = self.dend[182]) h.pt3dadd(632, -359, -118.5, 0.6, sec = self.dend[182]) h.pt3dadd(633.5, -358, -121, 0.6, sec = self.dend[182]) h.pt3dadd(634, -359, -121, 1.4, sec = self.dend[182]) h.pt3dadd(634, -360, -121, 1.6, sec = self.dend[182]) h.pt3dadd(636, -359, -121, 1.4, sec = self.dend[182]) h.pt3dadd(637.5, -359, -123.5, 1.4, sec = self.dend[182]) h.pt3dadd(639, -357.5, -121, 2, sec = self.dend[182]) h.pt3dadd(641, -356.5, -121, 1.7, sec = self.dend[182]) h.pt3dclear(sec = self.dend[183]) h.pt3dadd(51.5, -18.5, -3, 13.7, sec = self.dend[183]) h.pt3dadd(57.5, -24, -2, 7.8, sec = self.dend[183]) h.pt3dadd(61.5, -28, -2, 8.2, sec = self.dend[183]) h.pt3dadd(64, -31, -2, 8.4, sec = self.dend[183]) h.pt3dadd(67, -36, -5, 7.9, sec = self.dend[183]) h.pt3dadd(71, -41, -5, 7.7, sec = self.dend[183]) h.pt3dadd(73, -43.5, -4, 7.7, sec = self.dend[183]) h.pt3dadd(75, -46, -5, 8.4, sec = self.dend[183]) h.pt3dadd(77.5, -49, -5, 7.9, sec = self.dend[183]) h.pt3dadd(79, -51.5, -5.5, 7.7, sec = self.dend[183]) h.pt3dadd(80, -53, -6.5, 7.3, sec = self.dend[183]) h.pt3dadd(83, -54.5, -7.5, 7.1, sec = self.dend[183]) h.pt3dadd(85, -56.5, -7.5, 7.1, sec = self.dend[183]) h.pt3dadd(87.5, -57.5, -7.5, 6.3, sec = self.dend[183]) h.pt3dadd(89, -58.5, -7.5, 6.3, sec = self.dend[183]) h.pt3dadd(89.5, -60.5, -7.5, 5.7, sec = self.dend[183]) h.pt3dadd(90.5, -61, -7.5, 6, sec = self.dend[183]) h.pt3dadd(92, -63.5, -7.5, 6.1, sec = self.dend[183]) h.pt3dadd(93.5, -65, -7.5, 6.3, sec = self.dend[183]) h.pt3dadd(94, -68, -10, 6.8, sec = self.dend[183]) h.pt3dadd(97.5, -74.5, -10, 5.7, sec = self.dend[183]) h.pt3dadd(98.5, -75.5, -11, 6.3, sec = self.dend[183]) h.pt3dadd(101.5, -78.5, -12.5, 5.4, sec = self.dend[183]) h.pt3dadd(103.5, -81.5, -13.5, 5, sec = self.dend[183]) h.pt3dadd(105, -84, -13.5, 4.6, sec = self.dend[183]) h.pt3dadd(107, -85, -13.5, 5.7, sec = self.dend[183]) h.pt3dadd(110, -86.5, -12.5, 6.7, sec = self.dend[183]) h.pt3dadd(112, -89.5, -14.5, 7, sec = self.dend[183]) h.pt3dadd(114, -92, -14.5, 7, sec = self.dend[183]) h.pt3dadd(116.5, -95, -14.5, 7.6, sec = self.dend[183]) h.pt3dadd(119, -97, -15.5, 8.3, sec = self.dend[183]) h.pt3dadd(120.5, -98, -15.5, 8.8, sec = self.dend[183]) h.pt3dclear(sec = self.dend[184]) h.pt3dadd(120.5, -98, -15.5, 8.8, sec = self.dend[184]) h.pt3dadd(119, -104.5, -17, 4.6, sec = self.dend[184]) h.pt3dadd(118, -108, -18, 4.3, sec = self.dend[184]) h.pt3dadd(117, -112, -18, 4.1, sec = self.dend[184]) h.pt3dadd(115, -113.5, -18, 4.1, sec = self.dend[184]) h.pt3dadd(113, -117.5, -17.5, 3.8, sec = self.dend[184]) h.pt3dadd(113, -119.5, -17.5, 3.6, sec = self.dend[184]) h.pt3dadd(113, -122.5, -17.5, 3.2, sec = self.dend[184]) h.pt3dadd(113, -125.5, -17.5, 3.3, sec = self.dend[184]) h.pt3dadd(111.5, -127.5, -18, 3.5, sec = self.dend[184]) h.pt3dadd(109, -131, -18, 3.6, sec = self.dend[184]) h.pt3dadd(110.5, -133.5, -18, 3.2, sec = self.dend[184]) h.pt3dadd(110.5, -135.5, -18, 3.2, sec = self.dend[184]) h.pt3dadd(109, -138, -19.5, 2.9, sec = self.dend[184]) h.pt3dadd(109, -141, -19, 3.1, sec = self.dend[184]) h.pt3dadd(107.5, -144.5, -20, 2.9, sec = self.dend[184]) h.pt3dadd(106, -147.5, -20, 3.4, sec = self.dend[184]) h.pt3dadd(104.5, -151, -21, 3.6, sec = self.dend[184]) h.pt3dadd(103.5, -155, -21, 4.4, sec = self.dend[184]) h.pt3dadd(101, -160, -21, 5.2, sec = self.dend[184]) h.pt3dadd(101, -163.5, -21, 5.2, sec = self.dend[184]) h.pt3dadd(101, -166.5, -21, 4.8, sec = self.dend[184]) h.pt3dadd(100, -169, -21.5, 4.6, sec = self.dend[184]) h.pt3dadd(100, -172.5, -21, 5, sec = self.dend[184]) h.pt3dadd(100, -174.5, -20, 5.2, sec = self.dend[184]) h.pt3dadd(101.5, -179.5, -21, 5.2, sec = self.dend[184]) h.pt3dadd(101, -181.5, -21.5, 5.2, sec = self.dend[184]) h.pt3dadd(101, -185, -21.5, 5.6, sec = self.dend[184]) h.pt3dclear(sec = self.dend[185]) h.pt3dadd(101, -185, -21.5, 5.6, sec = self.dend[185]) h.pt3dadd(104, -185, -27.5, 0.2, sec = self.dend[185]) h.pt3dadd(106.5, -185, -27.5, 1, sec = self.dend[185]) h.pt3dadd(108, -185.5, -27.5, 0.1, sec = self.dend[185]) h.pt3dadd(109.5, -186, -27.5, 0.1, sec = self.dend[185]) h.pt3dadd(111.5, -186, -27.5, 0.1, sec = self.dend[185]) h.pt3dadd(113, -186.5, -21.5, 1.4, sec = self.dend[185]) h.pt3dadd(113.5, -186.5, -21.5, 2.5, sec = self.dend[185]) h.pt3dadd(115, -186.5, -21.5, 1.4, sec = self.dend[185]) h.pt3dadd(116, -186.5, -27.5, 0.2, sec = self.dend[185]) h.pt3dadd(118, -186.5, -27.5, 0.2, sec = self.dend[185]) h.pt3dadd(120, -186.5, -27.5, 0.2, sec = self.dend[185]) h.pt3dadd(122.5, -186.5, -21.5, 1.4, sec = self.dend[185]) h.pt3dclear(sec = self.dend[186]) h.pt3dadd(101, -185, -21.5, 5.6, sec = self.dend[186]) h.pt3dadd(100.5, -189.5, -21.5, 5.8, sec = self.dend[186]) h.pt3dadd(99.5, -191.5, -21.5, 5.3, sec = self.dend[186]) h.pt3dadd(98, -193, -27.5, 4.9, sec = self.dend[186]) h.pt3dadd(97, -196.5, -27.5, 4.4, sec = self.dend[186]) h.pt3dadd(95, -199, -27.5, 4.1, sec = self.dend[186]) h.pt3dadd(93, -201, -27.5, 3.8, sec = self.dend[186]) h.pt3dadd(91.5, -203, -34, 3.6, sec = self.dend[186]) h.pt3dadd(90, -206.5, -34, 4.1, sec = self.dend[186]) h.pt3dadd(89, -208, -27.5, 4, sec = self.dend[186]) h.pt3dadd(88, -210.5, -34, 4.3, sec = self.dend[186]) h.pt3dclear(sec = self.dend[187]) h.pt3dadd(88, -210.5, -34, 4.3, sec = self.dend[187]) h.pt3dadd(85, -215.5, -40, 2, sec = self.dend[187]) h.pt3dadd(84, -214, -34, 2, sec = self.dend[187]) h.pt3dadd(82.5, -214, -40, 2.5, sec = self.dend[187]) h.pt3dadd(81, -214, -40, 3, sec = self.dend[187]) h.pt3dadd(80, -214, -40, 2.5, sec = self.dend[187]) h.pt3dadd(79.5, -215, -40, 2, sec = self.dend[187]) h.pt3dadd(80, -217, -40, 1.1, sec = self.dend[187]) h.pt3dadd(80.5, -218.5, -46.5, 1.3, sec = self.dend[187]) h.pt3dadd(78.5, -218.5, -46.5, 1.3, sec = self.dend[187]) h.pt3dadd(77.5, -219.5, -46.5, 1.6, sec = self.dend[187]) h.pt3dadd(77.5, -220.5, -46.5, 2.1, sec = self.dend[187]) h.pt3dadd(76, -222, -46.5, 1.6, sec = self.dend[187]) h.pt3dadd(75, -224, -46.5, 2.4, sec = self.dend[187]) h.pt3dadd(74, -225.5, -46.5, 3, sec = self.dend[187]) h.pt3dadd(74, -226, -46.5, 2, sec = self.dend[187]) h.pt3dadd(73.5, -228, -46.5, 2.1, sec = self.dend[187]) h.pt3dadd(70.5, -229.5, -50.5, 1.2, sec = self.dend[187]) h.pt3dadd(69, -230.5, -50.5, 1.2, sec = self.dend[187]) h.pt3dadd(68, -232.5, -52.5, 1.1, sec = self.dend[187]) h.pt3dadd(66.5, -234, -52.5, 1.1, sec = self.dend[187]) h.pt3dadd(65.5, -235, -52.5, 1.5, sec = self.dend[187]) h.pt3dadd(64.5, -236.5, -50.5, 1.9, sec = self.dend[187]) h.pt3dadd(64.5, -238.5, -50.5, 2.2, sec = self.dend[187]) h.pt3dadd(63.5, -239.5, -50.5, 1.5, sec = self.dend[187]) h.pt3dadd(63, -241.5, -50.5, 1.4, sec = self.dend[187]) h.pt3dadd(61.5, -242.5, -54.5, 2.5, sec = self.dend[187]) h.pt3dadd(60.5, -244, -52.5, 3.4, sec = self.dend[187]) h.pt3dadd(58.5, -245, -52.5, 2.4, sec = self.dend[187]) h.pt3dadd(57.5, -246.5, -54.5, 1.6, sec = self.dend[187]) h.pt3dadd(57, -248, -52.5, 1.2, sec = self.dend[187]) h.pt3dadd(57, -249.5, -52.5, 1.1, sec = self.dend[187]) h.pt3dadd(55.5, -251, -50.5, 1.3, sec = self.dend[187]) h.pt3dadd(55, -252.5, -54.5, 1.4, sec = self.dend[187]) h.pt3dadd(53.5, -254, -52.5, 2, sec = self.dend[187]) h.pt3dadd(53.5, -256.5, -54.5, 2.8, sec = self.dend[187]) h.pt3dadd(52.5, -257, -54.5, 3.4, sec = self.dend[187]) h.pt3dadd(51, -257, -54.5, 2.9, sec = self.dend[187]) h.pt3dadd(49, -258.5, -56.5, 1.8, sec = self.dend[187]) h.pt3dadd(48, -260, -58, 1, sec = self.dend[187]) h.pt3dadd(46.5, -260.5, -54.5, 1.5, sec = self.dend[187]) h.pt3dadd(46.5, -262.5, -54.5, 1.8, sec = self.dend[187]) h.pt3dadd(46.5, -264.5, -60, 1.9, sec = self.dend[187]) h.pt3dadd(46.5, -265.5, -56.5, 2.1, sec = self.dend[187]) h.pt3dadd(44, -266.5, -56.5, 1.7, sec = self.dend[187]) h.pt3dadd(44, -268, -58, 1.4, sec = self.dend[187]) h.pt3dadd(44, -270.5, -58, 1.4, sec = self.dend[187]) h.pt3dadd(44, -271.5, -58, 1.5, sec = self.dend[187]) h.pt3dadd(43.5, -272.5, -56.5, 2.3, sec = self.dend[187]) h.pt3dadd(43.5, -273.5, -60, 3.1, sec = self.dend[187]) h.pt3dadd(42.5, -275.5, -62, 3.1, sec = self.dend[187]) h.pt3dadd(41, -277.5, -68, 3.1, sec = self.dend[187]) h.pt3dadd(39, -279, -71, 1.2, sec = self.dend[187]) h.pt3dadd(38, -279.5, -71, 0.3, sec = self.dend[187]) h.pt3dadd(37, -280.5, -65, 0.5, sec = self.dend[187]) h.pt3dadd(36.5, -280.5, -65, 1.3, sec = self.dend[187]) h.pt3dadd(35, -281.5, -65, 2.9, sec = self.dend[187]) h.pt3dadd(34.5, -281.5, -65, 4.1, sec = self.dend[187]) h.pt3dadd(32, -281.5, -65, 1.8, sec = self.dend[187]) h.pt3dadd(30.5, -281.5, -71, 0.2, sec = self.dend[187]) h.pt3dadd(30, -282.5, -71, 0.2, sec = self.dend[187]) h.pt3dadd(30, -284.5, -71, 0.2, sec = self.dend[187]) h.pt3dadd(26.5, -284.5, -68, 2.4, sec = self.dend[187]) h.pt3dadd(25.5, -285.5, -77, 0.8, sec = self.dend[187]) h.pt3dadd(25, -286.5, -74, 1.2, sec = self.dend[187]) h.pt3dadd(23, -286.5, -74, 1.9, sec = self.dend[187]) h.pt3dadd(22.5, -287, -74, 2.9, sec = self.dend[187]) h.pt3dadd(20.5, -288.5, -77, 1.7, sec = self.dend[187]) h.pt3dadd(20, -290, -77, 1.2, sec = self.dend[187]) h.pt3dadd(18, -291.5, -82.5, 2, sec = self.dend[187]) h.pt3dadd(18, -292.5, -77, 2, sec = self.dend[187]) h.pt3dadd(16, -294.5, -79.5, 1.9, sec = self.dend[187]) h.pt3dadd(15, -294.5, -79.5, 1.3, sec = self.dend[187]) h.pt3dadd(14, -294.5, -79.5, 1.3, sec = self.dend[187]) h.pt3dadd(13.5, -295.5, -82.5, 1.8, sec = self.dend[187]) h.pt3dadd(12.5, -296, -82.5, 2.7, sec = self.dend[187]) h.pt3dadd(10, -299, -88.5, 1.3, sec = self.dend[187]) h.pt3dadd(9.5, -299.5, -88.5, 1.3, sec = self.dend[187]) h.pt3dadd(9, -301.5, -88.5, 0.9, sec = self.dend[187]) h.pt3dadd(5.5, -301, -86, 1.4, sec = self.dend[187]) h.pt3dadd(4, -301, -91, 1.4, sec = self.dend[187]) h.pt3dadd(2.5, -299.5, -91, 0.6, sec = self.dend[187]) h.pt3dadd(1.5, -299.5, -91, 0.6, sec = self.dend[187]) h.pt3dadd(-0.5, -299.5, -91, 0.9, sec = self.dend[187]) h.pt3dadd(-1.5, -297.5, -91, 1.3, sec = self.dend[187]) h.pt3dadd(-4, -297.5, -91, 1.3, sec = self.dend[187]) h.pt3dadd(-4.5, -299, -91, 1.8, sec = self.dend[187]) h.pt3dadd(-6.5, -299, -93.5, 2.9, sec = self.dend[187]) h.pt3dadd(-8.5, -299, -93.5, 0.1, sec = self.dend[187]) h.pt3dadd(-10.5, -299.5, -95.5, 0.6, sec = self.dend[187]) h.pt3dadd(-11.5, -300, -95.5, 1.1, sec = self.dend[187]) h.pt3dadd(-12, -302, -98, 3.6, sec = self.dend[187]) h.pt3dadd(-14, -302, -98, 0.1, sec = self.dend[187]) h.pt3dadd(-16.5, -303, -98, 0.7, sec = self.dend[187]) h.pt3dadd(-17.5, -304.5, -98, 0.9, sec = self.dend[187]) h.pt3dadd(-19.5, -306, -103, 1.9, sec = self.dend[187]) h.pt3dadd(-21.5, -307.5, -103, 0.7, sec = self.dend[187]) h.pt3dadd(-22.5, -309.5, -103, 1.5, sec = self.dend[187]) h.pt3dadd(-25, -311, -105, 2.1, sec = self.dend[187]) h.pt3dadd(-26, -311, -103, 1.4, sec = self.dend[187]) h.pt3dadd(-28, -311.5, -107.5, 0.6, sec = self.dend[187]) h.pt3dadd(-30, -312, -107.5, 0.6, sec = self.dend[187]) h.pt3dadd(-32, -313.5, -107.5, 0.7, sec = self.dend[187]) h.pt3dadd(-34.5, -314.5, -107.5, 0.5, sec = self.dend[187]) h.pt3dadd(-37, -316, -107.5, 0.5, sec = self.dend[187]) h.pt3dclear(sec = self.dend[188]) h.pt3dadd(88, -210.5, -34, 4.3, sec = self.dend[188]) h.pt3dadd(87, -215, -34, 3.3, sec = self.dend[188]) h.pt3dadd(86.5, -217.5, -34, 3.5, sec = self.dend[188]) h.pt3dadd(85.5, -220.5, -34, 3.5, sec = self.dend[188]) h.pt3dadd(84.5, -223, -34, 2.5, sec = self.dend[188]) h.pt3dadd(84.5, -224.5, -34, 2.8, sec = self.dend[188]) h.pt3dadd(83.5, -225.5, -34, 3.3, sec = self.dend[188]) h.pt3dadd(82.5, -228, -40, 2.8, sec = self.dend[188]) h.pt3dadd(81, -230.5, -34, 2.8, sec = self.dend[188]) h.pt3dadd(80.5, -232.5, -34, 3.3, sec = self.dend[188]) h.pt3dadd(79.5, -233.5, -40, 3.3, sec = self.dend[188]) h.pt3dadd(78.5, -235, -40, 2.4, sec = self.dend[188]) h.pt3dadd(77, -238, -40, 2.2, sec = self.dend[188]) h.pt3dadd(75.5, -240, -40, 2.2, sec = self.dend[188]) h.pt3dadd(75, -242.5, -40, 1.9, sec = self.dend[188]) h.pt3dadd(74.5, -244, -40, 2.5, sec = self.dend[188]) h.pt3dadd(74.5, -247.5, -34, 4.5, sec = self.dend[188]) h.pt3dadd(74.5, -250, -46.5, 6.1, sec = self.dend[188]) h.pt3dadd(74, -252.5, -40, 6.8, sec = self.dend[188]) h.pt3dclear(sec = self.dend[189]) h.pt3dadd(74, -252.5, -40, 6.8, sec = self.dend[189]) h.pt3dadd(71, -253.5, -34, 2.7, sec = self.dend[189]) h.pt3dadd(69.5, -255.5, -40, 1.6, sec = self.dend[189]) h.pt3dadd(69, -258, -40, 1.5, sec = self.dend[189]) h.pt3dadd(68.5, -260.5, -40, 1.3, sec = self.dend[189]) h.pt3dadd(68.5, -261, -40, 1.3, sec = self.dend[189]) h.pt3dadd(68.5, -262.5, -40, 1.6, sec = self.dend[189]) h.pt3dadd(69, -264.5, -40, 2.3, sec = self.dend[189]) h.pt3dadd(69.5, -266, -40, 1.5, sec = self.dend[189]) h.pt3dadd(69.5, -267, -40, 1.1, sec = self.dend[189]) h.pt3dadd(69.5, -269.5, -40, 1.1, sec = self.dend[189]) h.pt3dadd(69.5, -270, -40, 1.4, sec = self.dend[189]) h.pt3dadd(69.5, -271.5, -46.5, 1.9, sec = self.dend[189]) h.pt3dadd(69, -273, -46.5, 1.1, sec = self.dend[189]) h.pt3dadd(69, -276, -40, 2, sec = self.dend[189]) h.pt3dadd(67.5, -277, -46.5, 3.3, sec = self.dend[189]) h.pt3dadd(67, -279.5, -46.5, 4.1, sec = self.dend[189]) h.pt3dadd(68, -283, -50.5, 0.9, sec = self.dend[189]) h.pt3dadd(68, -286, -48.5, 0.7, sec = self.dend[189]) h.pt3dadd(68.5, -288.5, -48.5, 1.5, sec = self.dend[189]) h.pt3dadd(68, -291.5, -46.5, 1, sec = self.dend[189]) h.pt3dadd(68, -293.5, -46.5, 1.2, sec = self.dend[189]) h.pt3dadd(67.5, -295, -48.5, 1.9, sec = self.dend[189]) h.pt3dadd(67.5, -295.5, -46.5, 2.5, sec = self.dend[189]) h.pt3dadd(67.5, -298, -52, 1.2, sec = self.dend[189]) h.pt3dadd(67, -301, -52, 0.7, sec = self.dend[189]) h.pt3dadd(66.5, -302, -48.5, 1.3, sec = self.dend[189]) h.pt3dadd(66.5, -303.5, -50.5, 2.2, sec = self.dend[189]) h.pt3dadd(66.5, -306, -46.5, 2.7, sec = self.dend[189]) h.pt3dadd(67.5, -307.5, -48.5, 2.9, sec = self.dend[189]) h.pt3dadd(67.5, -309.5, -48.5, 2.3, sec = self.dend[189]) h.pt3dadd(67.5, -310.5, -52, 1.1, sec = self.dend[189]) h.pt3dadd(67, -312, -52, 0.2, sec = self.dend[189]) h.pt3dadd(68, -314.5, -52, 0.4, sec = self.dend[189]) h.pt3dadd(67.5, -314.5, -50.5, 1.3, sec = self.dend[189]) h.pt3dadd(68, -316, -46.5, 2, sec = self.dend[189]) h.pt3dadd(68, -316, -52, 2.7, sec = self.dend[189]) h.pt3dadd(67.5, -318.5, -52, 2.7, sec = self.dend[189]) h.pt3dadd(67, -321, -52, 2.7, sec = self.dend[189]) h.pt3dadd(67, -322, -54, 1.4, sec = self.dend[189]) h.pt3dadd(67.5, -323.5, -54, 0.4, sec = self.dend[189]) h.pt3dadd(66.5, -325, -54, 1, sec = self.dend[189]) h.pt3dadd(66, -325.5, -54, 0.4, sec = self.dend[189]) h.pt3dadd(66.5, -327, -54, 0.4, sec = self.dend[189]) h.pt3dadd(66, -329.5, -54, 0.4, sec = self.dend[189]) h.pt3dadd(65.5, -332, -56, 0.4, sec = self.dend[189]) h.pt3dadd(65.5, -332, -52, 1.4, sec = self.dend[189]) h.pt3dadd(65, -335, -58, 3.4, sec = self.dend[189]) h.pt3dadd(65.5, -337, -58, 1.9, sec = self.dend[189]) h.pt3dadd(66, -340.5, -58, 1.7, sec = self.dend[189]) h.pt3dadd(66.5, -342, -58, 1.6, sec = self.dend[189]) h.pt3dadd(66.5, -343.5, -58, 1.1, sec = self.dend[189]) h.pt3dadd(66.5, -345.5, -58, 0.9, sec = self.dend[189]) h.pt3dadd(66.5, -346.5, -58, 0.7, sec = self.dend[189]) h.pt3dadd(66.5, -347.5, -58, 1.6, sec = self.dend[189]) h.pt3dadd(67, -350, -58, 2.4, sec = self.dend[189]) h.pt3dadd(66.5, -350.5, -58, 2.5, sec = self.dend[189]) h.pt3dadd(66.5, -351.5, -58, 1.5, sec = self.dend[189]) h.pt3dadd(66.5, -354, -58, 1.2, sec = self.dend[189]) h.pt3dadd(67, -355.5, -60, 0.9, sec = self.dend[189]) h.pt3dadd(66.5, -360, -57, 0.7, sec = self.dend[189]) h.pt3dadd(66.5, -360.5, -60, 1.2, sec = self.dend[189]) h.pt3dadd(66.5, -363.5, -60, 1.2, sec = self.dend[189]) h.pt3dadd(66, -364.5, -60, 0.8, sec = self.dend[189]) h.pt3dadd(65, -366, -60, 0.6, sec = self.dend[189]) h.pt3dadd(64.5, -366.5, -60, 0.6, sec = self.dend[189]) h.pt3dadd(63, -369, -63, 0.7, sec = self.dend[189]) h.pt3dadd(63, -370, -66, 1.3, sec = self.dend[189]) h.pt3dadd(62, -371.5, -66, 2.5, sec = self.dend[189]) h.pt3dadd(61, -373, -66, 2.7, sec = self.dend[189]) h.pt3dadd(60.5, -374, -66, 2.7, sec = self.dend[189]) h.pt3dadd(58.5, -376, -66, 1.3, sec = self.dend[189]) h.pt3dadd(58, -377, -66, 0.5, sec = self.dend[189]) h.pt3dadd(57, -379, -66, 0.7, sec = self.dend[189]) h.pt3dadd(56, -381, -66, 0.9, sec = self.dend[189]) h.pt3dadd(55.5, -382.5, -66, 2, sec = self.dend[189]) h.pt3dadd(54.5, -384, -66, 2.8, sec = self.dend[189]) h.pt3dadd(54, -384.5, -66, 3.4, sec = self.dend[189]) h.pt3dadd(53, -386.5, -66, 2.1, sec = self.dend[189]) h.pt3dadd(51, -389.5, -66, 1.1, sec = self.dend[189]) h.pt3dadd(49, -391, -72, 1.1, sec = self.dend[189]) h.pt3dadd(47.5, -392.5, -72, 1.1, sec = self.dend[189]) h.pt3dadd(44.5, -393.5, -72, 1.2, sec = self.dend[189]) h.pt3dadd(42.5, -394.5, -72, 1.4, sec = self.dend[189]) h.pt3dadd(40.5, -396, -72, 1.5, sec = self.dend[189]) h.pt3dadd(39, -396.5, -75, 1.3, sec = self.dend[189]) h.pt3dadd(38, -397, -75, 0.9, sec = self.dend[189]) h.pt3dadd(35.5, -398, -75, 0.6, sec = self.dend[189]) h.pt3dadd(33, -399, -72, 0.7, sec = self.dend[189]) h.pt3dadd(32, -399.5, -75, 1.3, sec = self.dend[189]) h.pt3dadd(32, -401, -80.5, 2.3, sec = self.dend[189]) h.pt3dadd(33, -402.5, -77.5, 2.9, sec = self.dend[189]) h.pt3dadd(33.5, -403.5, -77.5, 2.6, sec = self.dend[189]) h.pt3dadd(34, -407, -80.5, 0.9, sec = self.dend[189]) h.pt3dadd(34.5, -409.5, -86.5, 0.9, sec = self.dend[189]) h.pt3dadd(32.5, -414, -84, 1.3, sec = self.dend[189]) h.pt3dadd(31, -414, -84, 1.7, sec = self.dend[189]) h.pt3dadd(29.5, -414.5, -84, 0.9, sec = self.dend[189]) h.pt3dadd(29, -417, -86.5, 0.6, sec = self.dend[189]) h.pt3dadd(28, -419.5, -86.5, 0.6, sec = self.dend[189]) h.pt3dadd(28, -420, -86.5, 0.3, sec = self.dend[189]) h.pt3dadd(27, -421, -91, 0.3, sec = self.dend[189]) h.pt3dadd(27, -422.5, -88.5, 2.2, sec = self.dend[189]) h.pt3dadd(25.5, -422.5, -86.5, 2, sec = self.dend[189]) h.pt3dadd(25, -423.5, -91, 0.4, sec = self.dend[189]) h.pt3dadd(25.5, -426, -91, 0.2, sec = self.dend[189]) h.pt3dadd(27, -428, -86.5, 2, sec = self.dend[189]) h.pt3dadd(25.5, -430, -88.5, 2.2, sec = self.dend[189]) h.pt3dclear(sec = self.dend[190]) h.pt3dadd(25.5, -430, -88.5, 2.2, sec = self.dend[190]) h.pt3dadd(22.5, -434, -86.5, 0.1, sec = self.dend[190]) h.pt3dadd(20.5, -434, -86.5, 0.1, sec = self.dend[190]) h.pt3dadd(19.5, -434, -86.5, 1.3, sec = self.dend[190]) h.pt3dadd(17.5, -434.5, -84, 1.8, sec = self.dend[190]) h.pt3dadd(15.5, -435, -84, 0.3, sec = self.dend[190]) h.pt3dadd(13, -435.5, -93.5, 0.3, sec = self.dend[190]) h.pt3dadd(11.5, -436, -86.5, 1.2, sec = self.dend[190]) h.pt3dadd(10.5, -436.5, -88.5, 1.6, sec = self.dend[190]) h.pt3dadd(9.5, -438.5, -88.5, 1.2, sec = self.dend[190]) h.pt3dadd(7.5, -439, -88.5, 0.2, sec = self.dend[190]) h.pt3dadd(4.5, -439.5, -88.5, 0.2, sec = self.dend[190]) h.pt3dadd(1.5, -439.5, -88.5, 0.2, sec = self.dend[190]) h.pt3dadd(0, -439.5, -84, 1.1, sec = self.dend[190]) h.pt3dadd(-2, -439.5, -88.5, 1.8, sec = self.dend[190]) h.pt3dadd(-4.5, -441, -86.5, 1, sec = self.dend[190]) h.pt3dadd(-6.5, -441, -86.5, 0.1, sec = self.dend[190]) h.pt3dadd(-8.5, -443.5, -86.5, 0.1, sec = self.dend[190]) h.pt3dadd(-9, -445, -88.5, 1.3, sec = self.dend[190]) h.pt3dadd(-10.5, -445.5, -91, 0.5, sec = self.dend[190]) h.pt3dadd(-13, -450, -91, 0.5, sec = self.dend[190]) h.pt3dadd(-14, -449.5, -88.5, 1.9, sec = self.dend[190]) h.pt3dadd(-16.5, -452, -88.5, 0.1, sec = self.dend[190]) h.pt3dadd(-18.5, -453.5, -91, 1, sec = self.dend[190]) h.pt3dadd(-20.5, -453, -88.5, 0.3, sec = self.dend[190]) h.pt3dadd(-23.5, -455.5, -96, 2.2, sec = self.dend[190]) h.pt3dadd(-25, -455.5, -96, 0.3, sec = self.dend[190]) h.pt3dadd(-27.5, -455.5, -96, 0.3, sec = self.dend[190]) h.pt3dadd(-28.5, -455, -93.5, 0.3, sec = self.dend[190]) h.pt3dadd(-31, -455, -91, 1.7, sec = self.dend[190]) h.pt3dadd(-32.5, -455, -98, 2.1, sec = self.dend[190]) h.pt3dadd(-37, -453.5, -98, 0.2, sec = self.dend[190]) h.pt3dadd(-39.5, -452, -98, 0.2, sec = self.dend[190]) h.pt3dadd(-42.5, -452, -98, 2.5, sec = self.dend[190]) h.pt3dadd(-44.5, -453.5, -107.5, 0.1, sec = self.dend[190]) h.pt3dadd(-44.5, -456, -103, 0.1, sec = self.dend[190]) h.pt3dadd(-46, -457, -100.5, 1.3, sec = self.dend[190]) h.pt3dclear(sec = self.dend[191]) h.pt3dadd(25.5, -430, -88.5, 2.2, sec = self.dend[191]) h.pt3dadd(24, -433, -96, 0.8, sec = self.dend[191]) h.pt3dadd(24, -433.5, -91, 0.8, sec = self.dend[191]) h.pt3dadd(23.5, -435.5, -96, 1.5, sec = self.dend[191]) h.pt3dadd(20, -436, -96, 2.1, sec = self.dend[191]) h.pt3dadd(18, -438, -98, 2.5, sec = self.dend[191]) h.pt3dadd(17, -438, -100.5, 2.4, sec = self.dend[191]) h.pt3dadd(15.5, -438.5, -103, 1.7, sec = self.dend[191]) h.pt3dadd(15, -438.5, -103, 0.9, sec = self.dend[191]) h.pt3dadd(13, -441, -103, 0.4, sec = self.dend[191]) h.pt3dadd(7.5, -443, -105.5, 0.5, sec = self.dend[191]) h.pt3dclear(sec = self.dend[192]) h.pt3dadd(74, -252.5, -40, 6.8, sec = self.dend[192]) h.pt3dadd(77, -255.5, -40, 1.6, sec = self.dend[192]) h.pt3dadd(79, -256.5, -40, 1.8, sec = self.dend[192]) h.pt3dadd(80, -257.5, -40, 2.8, sec = self.dend[192]) h.pt3dadd(81, -259.5, -40, 2.8, sec = self.dend[192]) h.pt3dadd(82.5, -261.5, -40, 2.8, sec = self.dend[192]) h.pt3dadd(83, -264, -40, 1.1, sec = self.dend[192]) h.pt3dadd(82.5, -265, -34, 0.8, sec = self.dend[192]) h.pt3dadd(81, -266, -40, 1.9, sec = self.dend[192]) h.pt3dadd(80, -269.5, -40, 0.6, sec = self.dend[192]) h.pt3dadd(77.5, -270, -40, 1.9, sec = self.dend[192]) h.pt3dadd(76.5, -271.5, -40, 0.4, sec = self.dend[192]) h.pt3dadd(76, -272.5, -34, 0.5, sec = self.dend[192]) h.pt3dadd(75, -273.5, -34, 0.9, sec = self.dend[192]) h.pt3dadd(73.5, -274, -34, 1.6, sec = self.dend[192]) h.pt3dadd(73, -276, -40, 2.6, sec = self.dend[192]) h.pt3dadd(71.5, -277.5, -40, 3.1, sec = self.dend[192]) h.pt3dadd(70, -279.5, -40, 2.3, sec = self.dend[192]) h.pt3dadd(68.5, -280, -40, 1.4, sec = self.dend[192]) h.pt3dadd(68, -280.5, -40, 0.8, sec = self.dend[192]) h.pt3dadd(67.5, -283.5, -40, 1.3, sec = self.dend[192]) h.pt3dadd(66.5, -284.5, -40, 1.3, sec = self.dend[192]) h.pt3dadd(64, -285, -40, 1, sec = self.dend[192]) h.pt3dadd(62.5, -286, -40, 1.4, sec = self.dend[192]) h.pt3dadd(61, -287, -46.5, 2.2, sec = self.dend[192]) h.pt3dadd(59.5, -288.5, -40, 2.5, sec = self.dend[192]) h.pt3dadd(58, -290.5, -40, 3.2, sec = self.dend[192]) h.pt3dadd(57, -291.5, -40, 2.9, sec = self.dend[192]) h.pt3dadd(55.5, -292.5, -40, 2.1, sec = self.dend[192]) h.pt3dadd(55, -295, -40, 0.9, sec = self.dend[192]) h.pt3dadd(55, -297, -40, 1.8, sec = self.dend[192]) h.pt3dadd(55.5, -299, -40, 1.4, sec = self.dend[192]) h.pt3dadd(55.5, -302, -40, 1.4, sec = self.dend[192]) h.pt3dadd(54.5, -304.5, -40, 1.1, sec = self.dend[192]) h.pt3dadd(52.5, -306, -40, 1.1, sec = self.dend[192]) h.pt3dadd(50.5, -307.5, -46.5, 1.2, sec = self.dend[192]) h.pt3dadd(48.5, -309, -46.5, 1.3, sec = self.dend[192]) h.pt3dadd(48, -311, -46.5, 1.3, sec = self.dend[192]) h.pt3dadd(48, -312.5, -46.5, 1.2, sec = self.dend[192]) h.pt3dadd(47.5, -314.5, -46.5, 2.2, sec = self.dend[192]) h.pt3dadd(47.5, -315, -46.5, 2.4, sec = self.dend[192]) h.pt3dadd(47.5, -316.5, -46.5, 1.6, sec = self.dend[192]) h.pt3dadd(47.5, -318, -46.5, 0.7, sec = self.dend[192]) h.pt3dadd(47.5, -319.5, -46.5, 0.3, sec = self.dend[192]) h.pt3dadd(47, -323, -46.5, 0.2, sec = self.dend[192]) h.pt3dadd(45, -326.5, -46.5, 0.8, sec = self.dend[192]) h.pt3dadd(44, -327.5, -44.5, 0.9, sec = self.dend[192]) h.pt3dadd(44, -329, -44.5, 0.9, sec = self.dend[192]) h.pt3dadd(43, -331.5, -44.5, 1.1, sec = self.dend[192]) h.pt3dadd(42, -331.5, -42.5, 1.5, sec = self.dend[192]) h.pt3dadd(40.5, -333.5, -42.5, 1.5, sec = self.dend[192]) h.pt3dadd(40, -334.5, -42.5, 3.3, sec = self.dend[192]) h.pt3dadd(38, -336, -48, 1.6, sec = self.dend[192]) h.pt3dadd(36.5, -338.5, -48, 1.4, sec = self.dend[192]) h.pt3dadd(35, -339, -44.5, 1.1, sec = self.dend[192]) h.pt3dadd(34.5, -339.5, -44.5, 0.7, sec = self.dend[192]) h.pt3dadd(33, -340.5, -44.5, 0.7, sec = self.dend[192]) h.pt3dadd(31.5, -342.5, -46.5, 1.1, sec = self.dend[192]) h.pt3dadd(30.5, -345, -46.5, 1.1, sec = self.dend[192]) h.pt3dadd(29.5, -345, -44.5, 1.9, sec = self.dend[192]) h.pt3dadd(28.5, -346, -48, 3.1, sec = self.dend[192]) h.pt3dadd(27, -349, -44.5, 1.4, sec = self.dend[192]) h.pt3dadd(25.5, -350, -48, 1.2, sec = self.dend[192]) h.pt3dadd(25, -353, -48, 0.9, sec = self.dend[192]) h.pt3dadd(25, -355, -48, 1.1, sec = self.dend[192]) h.pt3dadd(24.5, -355.5, -48, 0.8, sec = self.dend[192]) h.pt3dadd(25.5, -356.5, -50, 1.1, sec = self.dend[192]) h.pt3dadd(25.5, -358.5, -50, 1.7, sec = self.dend[192]) h.pt3dadd(25.5, -360, -52, 2.4, sec = self.dend[192]) h.pt3dadd(25.5, -361, -52, 1.6, sec = self.dend[192]) h.pt3dadd(25.5, -364, -50, 1.1, sec = self.dend[192]) h.pt3dadd(25.5, -365, -54, 1, sec = self.dend[192]) h.pt3dadd(25.5, -368, -56, 1.7, sec = self.dend[192]) h.pt3dadd(26.5, -369.5, -56, 1.7, sec = self.dend[192]) h.pt3dadd(26, -371, -58, 1.7, sec = self.dend[192]) h.pt3dadd(26, -372, -58, 1.7, sec = self.dend[192]) h.pt3dadd(27, -373.5, -58, 1.4, sec = self.dend[192]) h.pt3dadd(26.5, -375, -58, 1.1, sec = self.dend[192]) h.pt3dadd(27, -376, -56, 1.6, sec = self.dend[192]) h.pt3dadd(27.5, -379, -56, 0.6, sec = self.dend[192]) h.pt3dadd(28, -380.5, -56, 0.6, sec = self.dend[192]) h.pt3dadd(27.5, -382, -56, 0.7, sec = self.dend[192]) h.pt3dadd(27.5, -382.5, -56, 0.7, sec = self.dend[192]) h.pt3dadd(27, -383.5, -62, 1.2, sec = self.dend[192]) h.pt3dadd(27, -386, -59, 1.2, sec = self.dend[192]) h.pt3dadd(28, -386, -62, 1.3, sec = self.dend[192]) h.pt3dadd(29, -386.5, -65, 0.9, sec = self.dend[192]) h.pt3dadd(29.5, -388.5, -62, 0.2, sec = self.dend[192]) h.pt3dadd(30, -389.5, -62, 0.2, sec = self.dend[192]) h.pt3dadd(31.5, -390.5, -62, 0.2, sec = self.dend[192]) h.pt3dadd(32, -391.5, -62, 1.6, sec = self.dend[192]) h.pt3dadd(33, -394, -62, 2.6, sec = self.dend[192]) h.pt3dadd(33, -394, -68, 0.1, sec = self.dend[192]) h.pt3dadd(34, -395.5, -68, 0.1, sec = self.dend[192]) h.pt3dadd(34.5, -398, -68, 0.9, sec = self.dend[192]) h.pt3dadd(34.5, -400.5, -68, 2.2, sec = self.dend[192]) h.pt3dadd(34.5, -402.5, -68, 1.3, sec = self.dend[192]) h.pt3dadd(35, -403, -68, 0.1, sec = self.dend[192]) h.pt3dadd(35, -405, -65, 0.1, sec = self.dend[192]) h.pt3dadd(34.5, -405, -68, 1.4, sec = self.dend[192]) h.pt3dadd(35, -406.5, -68, 1.9, sec = self.dend[192]) h.pt3dadd(35, -408, -74, 0.8, sec = self.dend[192]) h.pt3dadd(35.5, -409, -74, 0.1, sec = self.dend[192]) h.pt3dadd(36, -409, -74, 0.1, sec = self.dend[192]) h.pt3dadd(36, -409.5, -74, 0.1, sec = self.dend[192]) h.pt3dadd(36, -410.5, -74, 0.1, sec = self.dend[192]) h.pt3dadd(37, -410.5, -74, 0.1, sec = self.dend[192]) h.pt3dadd(37.5, -412, -74, 0.1, sec = self.dend[192]) h.pt3dadd(39, -413, -76.5, 0.1, sec = self.dend[192]) h.pt3dadd(38.5, -416, -79.5, 0.1, sec = self.dend[192]) h.pt3dadd(37, -416.5, -79.5, 0.1, sec = self.dend[192]) h.pt3dadd(37, -417.5, -76.5, 1.3, sec = self.dend[192]) h.pt3dadd(36, -420, -76.5, 1.5, sec = self.dend[192]) h.pt3dadd(35.5, -421.5, -76.5, 1.3, sec = self.dend[192]) h.pt3dadd(35, -424, -76.5, 0.1, sec = self.dend[192]) h.pt3dclear(sec = self.dend[193]) h.pt3dadd(120.5, -98, -15.5, 8.8, sec = self.dend[193]) h.pt3dadd(127, -100, -17, 3.7, sec = self.dend[193]) h.pt3dadd(128.5, -101.5, -17, 3.6, sec = self.dend[193]) h.pt3dadd(131.5, -101.5, -17, 3.8, sec = self.dend[193]) h.pt3dadd(134.5, -101.5, -17, 4.7, sec = self.dend[193]) h.pt3dadd(136.5, -103, -14.5, 4, sec = self.dend[193]) h.pt3dadd(139.5, -103.5, -17, 4.2, sec = self.dend[193]) h.pt3dadd(142, -105, -17, 4.2, sec = self.dend[193]) h.pt3dadd(144, -105.5, -18, 3.7, sec = self.dend[193]) h.pt3dadd(148, -105.5, -18, 3.4, sec = self.dend[193]) h.pt3dadd(149.5, -106.5, -18, 4.2, sec = self.dend[193]) h.pt3dadd(153, -107.5, -15.5, 4, sec = self.dend[193]) h.pt3dadd(157, -107.5, -17, 4.3, sec = self.dend[193]) h.pt3dadd(161, -109.5, -17, 3.6, sec = self.dend[193]) h.pt3dadd(165, -109.5, -17, 4.3, sec = self.dend[193]) h.pt3dadd(169.5, -110, -18, 4.6, sec = self.dend[193]) h.pt3dadd(174.5, -112, -18, 4.6, sec = self.dend[193]) h.pt3dadd(177, -112, -18, 4, sec = self.dend[193]) h.pt3dadd(179.5, -112.5, -18, 3.8, sec = self.dend[193]) h.pt3dadd(182.5, -113, -18, 4, sec = self.dend[193]) h.pt3dadd(185.5, -113, -18, 4, sec = self.dend[193]) h.pt3dadd(189.5, -114.5, -15.5, 4.9, sec = self.dend[193]) h.pt3dadd(193.5, -115, -17, 5, sec = self.dend[193]) h.pt3dadd(198, -116.5, -18, 5.2, sec = self.dend[193]) h.pt3dadd(204.5, -116.5, -18, 4, sec = self.dend[193]) h.pt3dadd(207.5, -116.5, -18, 6, sec = self.dend[193]) h.pt3dclear(sec = self.dend[194]) h.pt3dadd(207.5, -116.5, -18, 6, sec = self.dend[194]) h.pt3dadd(218, -115.5, -14.5, 0.1, sec = self.dend[194]) h.pt3dadd(221.5, -113.5, -16, 0.1, sec = self.dend[194]) h.pt3dadd(223.5, -113.5, -16, 0.1, sec = self.dend[194]) h.pt3dadd(226, -112, -16, 0.1, sec = self.dend[194]) h.pt3dadd(228, -110, -16, 0.1, sec = self.dend[194]) h.pt3dadd(229.5, -108, -16, 0.1, sec = self.dend[194]) h.pt3dadd(232.5, -106.5, -16, 0.1, sec = self.dend[194]) h.pt3dadd(235, -106, -15, 0.1, sec = self.dend[194]) h.pt3dclear(sec = self.dend[195]) h.pt3dadd(207.5, -116.5, -18, 6, sec = self.dend[195]) h.pt3dadd(212.5, -117.5, -18.5, 4.3, sec = self.dend[195]) h.pt3dadd(216.5, -118, -19, 3.8, sec = self.dend[195]) h.pt3dadd(218, -120.5, -19, 3.5, sec = self.dend[195]) h.pt3dadd(222.5, -120.5, -19, 3.6, sec = self.dend[195]) h.pt3dadd(224.5, -121.5, -20.5, 3.9, sec = self.dend[195]) h.pt3dadd(228, -122.5, -19, 3.9, sec = self.dend[195]) h.pt3dadd(230.5, -123.5, -19, 4.5, sec = self.dend[195]) h.pt3dadd(233, -123.5, -20, 4.1, sec = self.dend[195]) h.pt3dadd(236.5, -123.5, -19, 2.7, sec = self.dend[195]) h.pt3dadd(240, -125, -20, 2.8, sec = self.dend[195]) h.pt3dadd(242, -126, -20, 2.8, sec = self.dend[195]) h.pt3dadd(244.5, -126, -20, 3.3, sec = self.dend[195]) h.pt3dadd(247, -126, -20, 4, sec = self.dend[195]) h.pt3dadd(250, -126, -20, 4.5, sec = self.dend[195]) h.pt3dadd(253, -127, -20, 5.9, sec = self.dend[195]) h.pt3dadd(256.5, -127, -20.5, 4.8, sec = self.dend[195]) h.pt3dadd(260, -127.5, -19, 3.3, sec = self.dend[195]) h.pt3dadd(263.5, -127.5, -19, 2.8, sec = self.dend[195]) h.pt3dadd(265, -127.5, -19, 2.1, sec = self.dend[195]) h.pt3dadd(268.5, -127, -19, 2.1, sec = self.dend[195]) h.pt3dadd(270.5, -127, -18.5, 2.8, sec = self.dend[195]) h.pt3dadd(272.5, -127, -18.5, 3.2, sec = self.dend[195]) h.pt3dadd(274.5, -127, -18.5, 4.1, sec = self.dend[195]) h.pt3dadd(278, -127, -20, 4.6, sec = self.dend[195]) h.pt3dadd(282, -127, -20, 4.9, sec = self.dend[195]) h.pt3dadd(285.5, -126.5, -20, 4.9, sec = self.dend[195]) h.pt3dadd(288.5, -126.5, -20.5, 4.6, sec = self.dend[195]) h.pt3dadd(292.5, -126.5, -20.5, 4.1, sec = self.dend[195]) h.pt3dadd(296, -126, -21.5, 4.1, sec = self.dend[195]) h.pt3dadd(298, -126, -21.5, 3.4, sec = self.dend[195]) h.pt3dadd(300, -126, -21.5, 3.6, sec = self.dend[195]) h.pt3dadd(303, -126, -22, 4.1, sec = self.dend[195]) h.pt3dadd(305.5, -126, -22, 5, sec = self.dend[195]) h.pt3dadd(309, -125, -21.5, 5.4, sec = self.dend[195]) h.pt3dadd(312, -125, -21.5, 5.7, sec = self.dend[195]) h.pt3dadd(316, -125, -21.5, 5, sec = self.dend[195]) h.pt3dadd(317.5, -125, -23.5, 4.4, sec = self.dend[195]) h.pt3dadd(319.5, -125, -23.5, 3.4, sec = self.dend[195]) h.pt3dadd(322, -125.5, -23.5, 3.4, sec = self.dend[195]) h.pt3dadd(324.5, -125.5, -23.5, 4, sec = self.dend[195]) h.pt3dadd(328, -125.5, -23.5, 4.3, sec = self.dend[195]) h.pt3dadd(329.5, -125.5, -23.5, 4.6, sec = self.dend[195]) h.pt3dadd(332.5, -125.5, -23.5, 4.6, sec = self.dend[195]) h.pt3dadd(335, -125.5, -23.5, 5.1, sec = self.dend[195]) h.pt3dadd(341, -126.5, -23.5, 4.7, sec = self.dend[195]) h.pt3dadd(345.5, -127, -29.5, 5, sec = self.dend[195]) h.pt3dadd(348, -127.5, -29.5, 5, sec = self.dend[195]) h.pt3dadd(350.5, -127.5, -29.5, 4.3, sec = self.dend[195]) h.pt3dadd(353, -127.5, -29.5, 3.6, sec = self.dend[195]) h.pt3dadd(355.5, -127.5, -29.5, 2.8, sec = self.dend[195]) h.pt3dadd(357.5, -127.5, -29.5, 2.9, sec = self.dend[195]) h.pt3dadd(360, -127.5, -36, 3.3, sec = self.dend[195]) h.pt3dadd(362.5, -126.5, -29.5, 3.3, sec = self.dend[195]) h.pt3dadd(364, -126.5, -29.5, 3.3, sec = self.dend[195]) h.pt3dadd(367, -126.5, -29.5, 3.3, sec = self.dend[195]) h.pt3dadd(370, -126.5, -29.5, 3.7, sec = self.dend[195]) h.pt3dadd(373, -127.5, -29.5, 4.1, sec = self.dend[195]) h.pt3dadd(376, -128, -29.5, 4.8, sec = self.dend[195]) h.pt3dadd(379.5, -128, -29.5, 5.2, sec = self.dend[195]) h.pt3dadd(382.5, -130, -36, 5.8, sec = self.dend[195]) h.pt3dadd(386, -130, -36, 5.5, sec = self.dend[195]) h.pt3dadd(389, -130, -36, 4.6, sec = self.dend[195]) h.pt3dadd(391, -131, -42, 4.4, sec = self.dend[195]) h.pt3dadd(392, -132.5, -42, 2.2, sec = self.dend[195]) h.pt3dadd(395, -132, -42, 3.6, sec = self.dend[195]) h.pt3dadd(397, -132, -42, 4.6, sec = self.dend[195]) h.pt3dadd(399.5, -132.5, -42, 4.9, sec = self.dend[195]) h.pt3dadd(402.5, -133, -42, 4.9, sec = self.dend[195]) h.pt3dadd(405, -133.5, -42, 4.7, sec = self.dend[195]) h.pt3dadd(407.5, -133.5, -42, 4.6, sec = self.dend[195]) h.pt3dadd(410, -133.5, -42, 3.9, sec = self.dend[195]) h.pt3dadd(411, -134.5, -48.5, 3.3, sec = self.dend[195]) h.pt3dadd(412.5, -134.5, -48.5, 3.3, sec = self.dend[195]) h.pt3dadd(415.5, -136, -48.5, 3.4, sec = self.dend[195]) h.pt3dadd(418, -136, -48.5, 4.3, sec = self.dend[195]) h.pt3dadd(421.5, -136, -48.5, 4.9, sec = self.dend[195]) h.pt3dadd(425, -137.5, -48.5, 4.9, sec = self.dend[195]) h.pt3dadd(427, -137.5, -48.5, 4.1, sec = self.dend[195]) h.pt3dadd(430, -138.5, -48.5, 3.8, sec = self.dend[195]) h.pt3dadd(433, -140.5, -48.5, 4.8, sec = self.dend[195]) h.pt3dadd(437, -140.5, -48.5, 4.9, sec = self.dend[195]) h.pt3dadd(440.5, -141.5, -48.5, 4.3, sec = self.dend[195]) h.pt3dadd(443.5, -141.5, -54.5, 4.2, sec = self.dend[195]) h.pt3dadd(444.5, -141.5, -54.5, 3.7, sec = self.dend[195]) h.pt3dadd(446.5, -141.5, -54.5, 3.5, sec = self.dend[195]) h.pt3dadd(448.5, -141.5, -54.5, 3.1, sec = self.dend[195]) h.pt3dadd(450.5, -142, -48.5, 2.8, sec = self.dend[195]) h.pt3dadd(452, -142, -48.5, 2.4, sec = self.dend[195]) h.pt3dadd(456, -142, -54.5, 2.8, sec = self.dend[195]) h.pt3dadd(458, -143.5, -58.5, 1.1, sec = self.dend[195]) h.pt3dadd(461.5, -143, -60.5, 2.9, sec = self.dend[195]) h.pt3dadd(463, -143, -58.5, 5.7, sec = self.dend[195]) h.pt3dadd(467, -143, -58.5, 5.3, sec = self.dend[195]) h.pt3dadd(471.5, -143, -62, 4, sec = self.dend[195]) h.pt3dadd(475, -143, -62, 2.6, sec = self.dend[195]) h.pt3dadd(478, -143, -66, 1.7, sec = self.dend[195]) h.pt3dadd(481.5, -142.5, -66, 2.5, sec = self.dend[195]) h.pt3dadd(482.5, -142, -66, 4, sec = self.dend[195]) h.pt3dadd(485.5, -142, -66, 4.8, sec = self.dend[195]) h.pt3dadd(487, -140, -58.5, 4, sec = self.dend[195]) h.pt3dadd(491, -140, -58.5, 3.3, sec = self.dend[195]) h.pt3dadd(493, -140.5, -58.5, 2.2, sec = self.dend[195]) h.pt3dadd(496, -140.5, -60.5, 1.1, sec = self.dend[195]) h.pt3dadd(499.5, -140.5, -60.5, 1.4, sec = self.dend[195]) h.pt3dadd(502.5, -139.5, -68, 1.7, sec = self.dend[195]) h.pt3dadd(505.5, -139.5, -68, 1.9, sec = self.dend[195]) h.pt3dadd(509, -140.5, -68, 1.9, sec = self.dend[195]) h.pt3dadd(512, -140.5, -68, 1.9, sec = self.dend[195]) h.pt3dadd(517, -141, -68, 3.2, sec = self.dend[195]) h.pt3dclear(sec = self.dend[196]) h.pt3dadd(517, -141, -68, 3.2, sec = self.dend[196]) h.pt3dadd(521, -140, -66, 0.7, sec = self.dend[196]) h.pt3dadd(524.5, -141.5, -66, 0.7, sec = self.dend[196]) h.pt3dadd(528.5, -142, -66, 0.7, sec = self.dend[196]) h.pt3dadd(532.5, -142.5, -68, 0.7, sec = self.dend[196]) h.pt3dadd(535.5, -142.5, -68, 0.7, sec = self.dend[196]) h.pt3dadd(539.5, -142.5, -72, 0.7, sec = self.dend[196]) h.pt3dadd(543.5, -140, -68, 0.9, sec = self.dend[196]) h.pt3dadd(548.5, -140, -68, 0.9, sec = self.dend[196]) h.pt3dadd(553, -139, -68, 0.9, sec = self.dend[196]) h.pt3dadd(555.5, -138.5, -68, 0.9, sec = self.dend[196]) h.pt3dadd(558, -136.5, -68, 1.8, sec = self.dend[196]) h.pt3dadd(559.5, -136.5, -68, 0.9, sec = self.dend[196]) h.pt3dadd(563, -135, -68, 0.9, sec = self.dend[196]) h.pt3dadd(565.5, -135, -68, 0.8, sec = self.dend[196]) h.pt3dadd(567, -135, -68, 0.8, sec = self.dend[196]) h.pt3dadd(570, -135, -68, 1.9, sec = self.dend[196]) h.pt3dadd(573, -135, -68, 1.2, sec = self.dend[196]) h.pt3dadd(575, -135, -68, 0.7, sec = self.dend[196]) h.pt3dadd(576, -135, -68, 0.7, sec = self.dend[196]) h.pt3dadd(577, -135.5, -68, 0.7, sec = self.dend[196]) h.pt3dadd(579, -137, -68, 1.8, sec = self.dend[196]) h.pt3dadd(581.5, -137, -64, 0.5, sec = self.dend[196]) h.pt3dadd(583, -137, -70, 0.5, sec = self.dend[196]) h.pt3dadd(586, -137, -72, 0.5, sec = self.dend[196]) h.pt3dadd(586.5, -137, -70, 0.9, sec = self.dend[196]) h.pt3dadd(586.5, -140, -68, 0.7, sec = self.dend[196]) h.pt3dadd(588.5, -140, -68, 0.5, sec = self.dend[196]) h.pt3dadd(590, -139.5, -70, 1.1, sec = self.dend[196]) h.pt3dadd(590.5, -140, -70, 0.4, sec = self.dend[196]) h.pt3dadd(593, -140.5, -72, 0.8, sec = self.dend[196]) h.pt3dadd(595, -140, -66, 1.8, sec = self.dend[196]) h.pt3dadd(598.5, -140, -66, 2.4, sec = self.dend[196]) h.pt3dadd(599, -140, -69, 1.3, sec = self.dend[196]) h.pt3dadd(600.5, -140, -69, 0.3, sec = self.dend[196]) h.pt3dadd(603, -141, -69, 0.3, sec = self.dend[196]) h.pt3dadd(603.5, -141, -69, 1.3, sec = self.dend[196]) h.pt3dadd(605.5, -141, -69, 1.8, sec = self.dend[196]) h.pt3dadd(606.5, -142, -69, 0.2, sec = self.dend[196]) h.pt3dadd(609.5, -142, -69, 0.2, sec = self.dend[196]) h.pt3dadd(612.5, -143, -69, 0.2, sec = self.dend[196]) h.pt3dadd(615, -143.5, -75, 1.3, sec = self.dend[196]) h.pt3dadd(616.5, -144, -69, 2.8, sec = self.dend[196]) h.pt3dadd(618.5, -144, -69, 0.6, sec = self.dend[196]) h.pt3dadd(623, -144, -69, 0.6, sec = self.dend[196]) h.pt3dadd(625, -144, -75, 0.6, sec = self.dend[196]) h.pt3dadd(628.5, -144.5, -75, 0.6, sec = self.dend[196]) h.pt3dadd(631.5, -144.5, -75, 1.8, sec = self.dend[196]) h.pt3dadd(632.5, -145.5, -72, 3.2, sec = self.dend[196]) h.pt3dadd(633.5, -146.5, -78, 2, sec = self.dend[196]) h.pt3dadd(636, -148.5, -75, 0.1, sec = self.dend[196]) h.pt3dadd(638.5, -149.5, -78, 0.1, sec = self.dend[196]) h.pt3dadd(641.5, -149.5, -78, 1, sec = self.dend[196]) h.pt3dadd(642, -151, -78, 0.1, sec = self.dend[196]) h.pt3dadd(643, -151, -78, 0.1, sec = self.dend[196]) h.pt3dadd(646, -151, -81, 1.3, sec = self.dend[196]) h.pt3dadd(647.5, -151, -81, 0.1, sec = self.dend[196]) h.pt3dadd(651.5, -152.5, -78, 0.1, sec = self.dend[196]) h.pt3dadd(654, -152.5, -81, 0.1, sec = self.dend[196]) h.pt3dadd(655.5, -153.5, -84, 2.4, sec = self.dend[196]) h.pt3dadd(658, -153.5, -84, 0.1, sec = self.dend[196]) h.pt3dadd(660, -154.5, -84, 0.1, sec = self.dend[196]) h.pt3dadd(662, -154.5, -84, 0.1, sec = self.dend[196]) h.pt3dadd(663.5, -156.5, -81, 1.3, sec = self.dend[196]) h.pt3dadd(664.5, -156.5, -81, 1.6, sec = self.dend[196]) h.pt3dadd(666.5, -156.5, -81, 1.1, sec = self.dend[196]) h.pt3dadd(668, -156.5, -84, 0.1, sec = self.dend[196]) h.pt3dadd(670.5, -156.5, -86.5, 0.1, sec = self.dend[196]) h.pt3dadd(672, -156.5, -86.5, 2.1, sec = self.dend[196]) h.pt3dadd(673.5, -156.5, -81, 3.1, sec = self.dend[196]) h.pt3dadd(676.5, -156, -81, 0.1, sec = self.dend[196]) h.pt3dadd(677.5, -156, -81, 0.1, sec = self.dend[196]) h.pt3dadd(679.5, -156, -81, 2.6, sec = self.dend[196]) h.pt3dadd(682.5, -157.5, -86.5, 0.1, sec = self.dend[196]) h.pt3dadd(685, -157.5, -86.5, 0.1, sec = self.dend[196]) h.pt3dadd(687, -158, -84, 1.9, sec = self.dend[196]) h.pt3dadd(689.5, -158, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(690.5, -158, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(694, -160, -89.5, 2.1, sec = self.dend[196]) h.pt3dadd(695.5, -160, -86.5, 0.1, sec = self.dend[196]) h.pt3dadd(697.5, -162, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(699, -162, -92.5, 0.9, sec = self.dend[196]) h.pt3dadd(700, -162, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(702, -162, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(703.5, -162, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(705, -162.5, -89.5, 0.1, sec = self.dend[196]) h.pt3dadd(708, -162.5, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(710.5, -163.5, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(711.5, -163.5, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(713, -165, -92.5, 1.4, sec = self.dend[196]) h.pt3dadd(715, -165, -92.5, 2.5, sec = self.dend[196]) h.pt3dadd(716, -166.5, -92.5, 1.2, sec = self.dend[196]) h.pt3dadd(717.5, -166.5, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(720.5, -166.5, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(721.5, -167, -92.5, 1.6, sec = self.dend[196]) h.pt3dadd(723, -167, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(724, -167, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(725, -167, -92.5, 1.3, sec = self.dend[196]) h.pt3dadd(727.5, -167, -92.5, 1.8, sec = self.dend[196]) h.pt3dadd(729, -168, -92.5, 0.1, sec = self.dend[196]) h.pt3dadd(731.5, -169, -95.5, 0.1, sec = self.dend[196]) h.pt3dadd(733, -169, -95.5, 0.1, sec = self.dend[196]) h.pt3dadd(734.5, -169, -95.5, 0.9, sec = self.dend[196]) h.pt3dadd(735.5, -169, -95.5, 1.5, sec = self.dend[196]) h.pt3dadd(738.5, -170, -95.5, 0.9, sec = self.dend[196]) h.pt3dadd(740, -170.5, -98.5, 0.1, sec = self.dend[196]) h.pt3dadd(741.5, -170, -98.5, 0.1, sec = self.dend[196]) h.pt3dadd(743.5, -171, -98.5, 0.1, sec = self.dend[196]) h.pt3dadd(747, -173.5, -98.5, 0.1, sec = self.dend[196]) h.pt3dadd(747.5, -174, -96, 1, sec = self.dend[196]) h.pt3dadd(749, -174, -93.5, 1.4, sec = self.dend[196]) h.pt3dadd(750.5, -175, -93.5, 0.7, sec = self.dend[196]) h.pt3dadd(751.5, -175, -93.5, 0.1, sec = self.dend[196]) h.pt3dadd(754, -179, -93.5, 0.1, sec = self.dend[196]) h.pt3dadd(754.5, -179, -96, 1.1, sec = self.dend[196]) h.pt3dadd(756.5, -179, -96, 1.6, sec = self.dend[196]) h.pt3dadd(757, -179.5, -96, 0.6, sec = self.dend[196]) h.pt3dadd(759, -181, -93.5, 0.1, sec = self.dend[196]) h.pt3dadd(763, -183, -93.5, 0.1, sec = self.dend[196]) h.pt3dadd(766, -185, -93.5, 0.1, sec = self.dend[196]) h.pt3dadd(767, -186, -93.5, 1.2, sec = self.dend[196]) h.pt3dadd(768, -186, -93.5, 1.7, sec = self.dend[196]) h.pt3dadd(770.5, -185.5, -93.5, 0.9, sec = self.dend[196]) h.pt3dadd(771, -185, -96, 0.1, sec = self.dend[196]) h.pt3dadd(773.5, -186.5, -96, 0.1, sec = self.dend[196]) h.pt3dadd(777.5, -184.5, -91.5, 0.1, sec = self.dend[196]) h.pt3dadd(781.5, -184.5, -96, 0.1, sec = self.dend[196]) h.pt3dadd(782, -185.5, -101, 0.1, sec = self.dend[196]) h.pt3dadd(785, -186, -101, 0.1, sec = self.dend[196]) h.pt3dclear(sec = self.dend[197]) h.pt3dadd(517, -141, -68, 3.2, sec = self.dend[197]) h.pt3dadd(522.5, -142, -70, 2.2, sec = self.dend[197]) h.pt3dadd(525.5, -142, -70, 2.5, sec = self.dend[197]) h.pt3dadd(527, -144, -62, 2.8, sec = self.dend[197]) h.pt3dadd(531, -144.5, -68, 3.4, sec = self.dend[197]) h.pt3dadd(535, -146, -68, 3.2, sec = self.dend[197]) h.pt3dadd(537.5, -146.5, -70, 2.7, sec = self.dend[197]) h.pt3dadd(538.5, -148.5, -72, 2.1, sec = self.dend[197]) h.pt3dadd(540.5, -149.5, -72, 2.1, sec = self.dend[197]) h.pt3dadd(542.5, -151.5, -74, 2.1, sec = self.dend[197]) h.pt3dadd(545.5, -154.5, -80, 2.2, sec = self.dend[197]) h.pt3dadd(548.5, -155, -80, 2.4, sec = self.dend[197]) h.pt3dadd(550.5, -156.5, -80, 2.7, sec = self.dend[197]) h.pt3dadd(553.5, -157, -77, 3.8, sec = self.dend[197]) h.pt3dadd(556, -157, -80, 4.9, sec = self.dend[197]) h.pt3dadd(558.5, -157, -74, 5.7, sec = self.dend[197]) h.pt3dadd(563, -159, -80, 4.3, sec = self.dend[197]) h.pt3dadd(565, -159.5, -80, 2.8, sec = self.dend[197]) h.pt3dadd(566.5, -160, -83, 2.1, sec = self.dend[197]) h.pt3dadd(568.5, -160, -77, 1.4, sec = self.dend[197]) h.pt3dadd(569.5, -162, -77, 2, sec = self.dend[197]) h.pt3dadd(572, -163.5, -77, 2.7, sec = self.dend[197]) h.pt3dadd(575.5, -164.5, -77, 4.1, sec = self.dend[197]) h.pt3dadd(578, -165.5, -80, 4.1, sec = self.dend[197]) h.pt3dadd(579.5, -167, -83, 3.1, sec = self.dend[197]) h.pt3dadd(580.5, -168.5, -80, 2.9, sec = self.dend[197]) h.pt3dadd(583, -170.5, -83, 2.8, sec = self.dend[197]) h.pt3dadd(585, -172.5, -83, 2.2, sec = self.dend[197]) h.pt3dadd(587, -174, -80, 1.7, sec = self.dend[197]) h.pt3dadd(588, -175, -86, 1.5, sec = self.dend[197]) h.pt3dadd(590.5, -175.5, -86, 1.6, sec = self.dend[197]) h.pt3dadd(593, -177.5, -89, 2.2, sec = self.dend[197]) h.pt3dadd(594.5, -179, -89, 3.1, sec = self.dend[197]) h.pt3dadd(598, -180, -89, 3.3, sec = self.dend[197]) h.pt3dadd(599.5, -181, -89, 3.3, sec = self.dend[197]) h.pt3dadd(601, -183.5, -89, 2.3, sec = self.dend[197]) h.pt3dadd(602, -185, -89, 1.7, sec = self.dend[197]) h.pt3dadd(604.5, -186, -89, 2.4, sec = self.dend[197]) h.pt3dadd(606, -188.5, -89, 3.3, sec = self.dend[197]) h.pt3dadd(608.5, -189.5, -89, 4, sec = self.dend[197]) h.pt3dadd(611.5, -192.5, -89, 3.2, sec = self.dend[197]) h.pt3dadd(612.5, -194, -91.5, 2.9, sec = self.dend[197]) h.pt3dadd(614.5, -197, -89, 2.7, sec = self.dend[197]) h.pt3dadd(616.5, -200.5, -89, 2.3, sec = self.dend[197]) h.pt3dadd(618.5, -201.5, -91.5, 1.8, sec = self.dend[197]) h.pt3dadd(620, -203.5, -91.5, 1.7, sec = self.dend[197]) h.pt3dadd(622, -204.5, -91.5, 1.6, sec = self.dend[197]) h.pt3dadd(624, -207, -97.5, 1.8, sec = self.dend[197]) h.pt3dadd(626.5, -209, -97.5, 2.2, sec = self.dend[197]) h.pt3dadd(629, -210.5, -97.5, 3.2, sec = self.dend[197]) h.pt3dadd(631.5, -212, -97.5, 4.3, sec = self.dend[197]) h.pt3dadd(632.5, -213.5, -97.5, 4.7, sec = self.dend[197]) h.pt3dadd(635, -215.5, -97.5, 3.8, sec = self.dend[197]) h.pt3dadd(635.5, -217, -103.5, 3.1, sec = self.dend[197]) h.pt3dadd(637.5, -219.5, -103.5, 2.6, sec = self.dend[197]) h.pt3dadd(638.5, -226.5, -101, 2.2, sec = self.dend[197]) h.pt3dadd(639.5, -229, -108, 2.2, sec = self.dend[197]) h.pt3dadd(642, -231, -108, 2.2, sec = self.dend[197]) h.pt3dadd(642.5, -234, -108, 2.4, sec = self.dend[197]) h.pt3dadd(644.5, -235, -105.5, 3.7, sec = self.dend[197]) h.pt3dadd(647.5, -238, -108, 4.3, sec = self.dend[197]) h.pt3dadd(650, -241.5, -110.5, 4.5, sec = self.dend[197]) h.pt3dadd(652, -246.5, -110.5, 4.5, sec = self.dend[197]) h.pt3dclear(sec = self.dend[198]) h.pt3dadd(652, -246.5, -110.5, 4.5, sec = self.dend[198]) h.pt3dadd(654.5, -251.5, -108, 1.6, sec = self.dend[198]) h.pt3dadd(655, -253, -105.5, 1.9, sec = self.dend[198]) h.pt3dadd(656.5, -255, -105.5, 2.5, sec = self.dend[198]) h.pt3dadd(658, -256.5, -105.5, 3.3, sec = self.dend[198]) h.pt3dadd(658, -258.5, -103.5, 4.7, sec = self.dend[198]) h.pt3dadd(659, -261, -105.5, 3.8, sec = self.dend[198]) h.pt3dadd(659.5, -263.5, -105.5, 1.5, sec = self.dend[198]) h.pt3dadd(660, -266, -105.5, 1.1, sec = self.dend[198]) h.pt3dadd(660.5, -267.5, -105.5, 1.6, sec = self.dend[198]) h.pt3dadd(661.5, -268.5, -105.5, 1.6, sec = self.dend[198]) h.pt3dadd(664, -270.5, -105.5, 2.2, sec = self.dend[198]) h.pt3dadd(665.5, -272, -105.5, 3.6, sec = self.dend[198]) h.pt3dadd(666.5, -274.5, -105.5, 3.8, sec = self.dend[198]) h.pt3dadd(667, -277, -105.5, 3.4, sec = self.dend[198]) h.pt3dadd(669, -279.5, -108, 2.9, sec = self.dend[198]) h.pt3dadd(669.5, -280.5, -110.5, 1.6, sec = self.dend[198]) h.pt3dadd(669.5, -283.5, -108, 1.3, sec = self.dend[198]) h.pt3dadd(672, -284.5, -105.5, 1.5, sec = self.dend[198]) h.pt3dadd(672.5, -286.5, -110.5, 1.9, sec = self.dend[198]) h.pt3dadd(674, -287.5, -110.5, 2.2, sec = self.dend[198]) h.pt3dadd(674, -289.5, -110.5, 2.6, sec = self.dend[198]) h.pt3dadd(674, -291, -110.5, 3.2, sec = self.dend[198]) h.pt3dadd(676, -294, -110.5, 4.1, sec = self.dend[198]) h.pt3dclear(sec = self.dend[199]) h.pt3dadd(676, -294, -110.5, 4.1, sec = self.dend[199]) h.pt3dadd(677.5, -298.5, -110.5, 0.9, sec = self.dend[199]) h.pt3dadd(678.5, -299, -113, 0.9, sec = self.dend[199]) h.pt3dadd(679, -300, -117.5, 0.8, sec = self.dend[199]) h.pt3dadd(679.5, -302, -115, 0.9, sec = self.dend[199]) h.pt3dadd(680, -304, -115, 0.9, sec = self.dend[199]) h.pt3dadd(681, -304, -115, 0.5, sec = self.dend[199]) h.pt3dadd(682, -305, -115, 1.1, sec = self.dend[199]) h.pt3dadd(682.5, -307, -115, 0.9, sec = self.dend[199]) h.pt3dadd(684, -308, -117.5, 0.8, sec = self.dend[199]) h.pt3dadd(685, -309.5, -117.5, 1.7, sec = self.dend[199]) h.pt3dadd(685.5, -311.5, -115, 2.5, sec = self.dend[199]) h.pt3dadd(688, -314, -115, 3.6, sec = self.dend[199]) h.pt3dadd(689, -316.5, -115, 2.6, sec = self.dend[199]) h.pt3dadd(691, -318.5, -115, 0.9, sec = self.dend[199]) h.pt3dadd(692.5, -320, -120, 1.1, sec = self.dend[199]) h.pt3dadd(693.5, -322, -120, 1.1, sec = self.dend[199]) h.pt3dadd(694.5, -323.5, -120, 1.1, sec = self.dend[199]) h.pt3dadd(695, -324.5, -117.5, 2.4, sec = self.dend[199]) h.pt3dadd(696.5, -326, -117.5, 3.6, sec = self.dend[199]) h.pt3dadd(697.5, -328.5, -120, 1.5, sec = self.dend[199]) h.pt3dadd(698.5, -328.5, -120, 0.7, sec = self.dend[199]) h.pt3dadd(699.5, -329.5, -120, 0.6, sec = self.dend[199]) h.pt3dadd(701.5, -330.5, -120, 1.1, sec = self.dend[199]) h.pt3dadd(702.5, -332.5, -122.5, 1.2, sec = self.dend[199]) h.pt3dadd(703.5, -335, -122.5, 1.2, sec = self.dend[199]) h.pt3dadd(704.5, -335.5, -122.5, 0.9, sec = self.dend[199]) h.pt3dadd(706, -337.5, -122.5, 0.9, sec = self.dend[199]) h.pt3dadd(707.5, -339, -122.5, 0.9, sec = self.dend[199]) h.pt3dadd(709.5, -339, -122.5, 1.7, sec = self.dend[199]) h.pt3dadd(711, -340, -122.5, 2.5, sec = self.dend[199]) h.pt3dadd(712, -341, -122.5, 2.3, sec = self.dend[199]) h.pt3dadd(714, -341.5, -120, 1.6, sec = self.dend[199]) h.pt3dadd(715.5, -341.5, -122.5, 1.1, sec = self.dend[199]) h.pt3dadd(716.5, -342.5, -122.5, 0.9, sec = self.dend[199]) h.pt3dadd(718, -346, -122.5, 0.6, sec = self.dend[199]) h.pt3dadd(720, -346.5, -122.5, 0.6, sec = self.dend[199]) h.pt3dadd(721, -349.5, -122.5, 1.4, sec = self.dend[199]) h.pt3dadd(722.5, -352.5, -122.5, 1.5, sec = self.dend[199]) h.pt3dadd(724, -353.5, -124.5, 0.9, sec = self.dend[199]) h.pt3dadd(724.5, -355.5, -124.5, 0.6, sec = self.dend[199]) h.pt3dadd(724.5, -357, -124.5, 0.6, sec = self.dend[199]) h.pt3dadd(726, -359.5, -124.5, 0.6, sec = self.dend[199]) h.pt3dadd(725.5, -359.5, -120, 0.2, sec = self.dend[199]) h.pt3dadd(728, -360, -115, 1.7, sec = self.dend[199]) h.pt3dadd(730, -361.5, -117.5, 2.1, sec = self.dend[199]) h.pt3dadd(732, -363, -120, 0.6, sec = self.dend[199]) h.pt3dadd(732.5, -364.5, -122.5, 0.5, sec = self.dend[199]) h.pt3dadd(734.5, -367, -122.5, 0.5, sec = self.dend[199]) h.pt3dadd(737, -370, -120, 0.5, sec = self.dend[199]) h.pt3dclear(sec = self.dend[200]) h.pt3dadd(676, -294, -110.5, 4.1, sec = self.dend[200]) h.pt3dadd(681, -296, -110.5, 0.1, sec = self.dend[200]) h.pt3dadd(685, -297.5, -113, 0.1, sec = self.dend[200]) h.pt3dadd(686.5, -297.5, -113, 0.1, sec = self.dend[200]) h.pt3dadd(688, -299, -110.5, 1.6, sec = self.dend[200]) h.pt3dadd(690, -299, -110.5, 1.7, sec = self.dend[200]) h.pt3dadd(691.5, -299.5, -115, 1.4, sec = self.dend[200]) h.pt3dadd(693.5, -300.5, -115, 0.2, sec = self.dend[200]) h.pt3dadd(697, -302, -115, 0.2, sec = self.dend[200]) h.pt3dadd(698.5, -303.5, -115, 1.6, sec = self.dend[200]) h.pt3dadd(700.5, -303.5, -115, 2.4, sec = self.dend[200]) h.pt3dadd(701.5, -304.5, -113, 2.8, sec = self.dend[200]) h.pt3dadd(703, -305, -113, 2, sec = self.dend[200]) h.pt3dadd(705.5, -305, -113, 1.1, sec = self.dend[200]) h.pt3dadd(708, -305, -113, 0.9, sec = self.dend[200]) h.pt3dadd(709, -306, -113, 0.9, sec = self.dend[200]) h.pt3dadd(712, -307, -113, 0.8, sec = self.dend[200]) h.pt3dadd(713.5, -307, -113, 0.8, sec = self.dend[200]) h.pt3dadd(715, -307, -113, 1.4, sec = self.dend[200]) h.pt3dadd(716, -307, -113, 1.6, sec = self.dend[200]) h.pt3dadd(719, -307.5, -113, 2, sec = self.dend[200]) h.pt3dadd(721.5, -308, -113, 3.2, sec = self.dend[200]) h.pt3dadd(723, -308, -113, 1.8, sec = self.dend[200]) h.pt3dadd(724, -309, -113, 0.5, sec = self.dend[200]) h.pt3dadd(726.5, -309, -113, 0.5, sec = self.dend[200]) h.pt3dadd(730, -309, -113, 0.5, sec = self.dend[200]) h.pt3dadd(732.5, -310, -115, 2.1, sec = self.dend[200]) h.pt3dadd(734, -309, -115, 2.5, sec = self.dend[200]) h.pt3dadd(735.5, -309, -115, 3.6, sec = self.dend[200]) h.pt3dadd(737, -310.5, -115, 1.6, sec = self.dend[200]) h.pt3dadd(739, -309, -115, 0.7, sec = self.dend[200]) h.pt3dadd(742.5, -310, -115, 0.7, sec = self.dend[200]) h.pt3dadd(744.5, -310, -115, 1.4, sec = self.dend[200]) h.pt3dadd(745.5, -311, -115, 2.9, sec = self.dend[200]) h.pt3dadd(747.5, -312.5, -115, 1.6, sec = self.dend[200]) h.pt3dadd(750, -312.5, -115, 0.7, sec = self.dend[200]) h.pt3dadd(751, -314, -115, 0.7, sec = self.dend[200]) h.pt3dadd(753.5, -314, -115, 0.7, sec = self.dend[200]) h.pt3dadd(754.5, -315.5, -115, 1.7, sec = self.dend[200]) h.pt3dadd(756, -317, -115, 2.5, sec = self.dend[200]) h.pt3dadd(756.5, -318.5, -115, 1.5, sec = self.dend[200]) h.pt3dadd(757.5, -319, -115, 0.7, sec = self.dend[200]) h.pt3dadd(759, -320.5, -117.5, 0.7, sec = self.dend[200]) h.pt3dadd(761, -322.5, -120, 0.7, sec = self.dend[200]) h.pt3dadd(764, -323, -120, 0.7, sec = self.dend[200]) h.pt3dadd(766, -324.5, -117.5, 0.7, sec = self.dend[200]) h.pt3dadd(768.5, -324.5, -120, 1.6, sec = self.dend[200]) h.pt3dadd(770, -325.5, -120, 1.9, sec = self.dend[200]) h.pt3dadd(772, -325.5, -120, 0.7, sec = self.dend[200]) h.pt3dadd(775, -327.5, -120, 0.6, sec = self.dend[200]) h.pt3dadd(778.5, -328.5, -120, 0.6, sec = self.dend[200]) h.pt3dadd(779.5, -330, -120, 1.4, sec = self.dend[200]) h.pt3dadd(781, -330, -120, 2.2, sec = self.dend[200]) h.pt3dadd(782.5, -332, -120, 1.4, sec = self.dend[200]) h.pt3dadd(785.5, -335.5, -122.5, 0.4, sec = self.dend[200]) h.pt3dadd(787.5, -337, -124.5, 0.1, sec = self.dend[200]) h.pt3dadd(788.5, -337.5, -122.5, 1.6, sec = self.dend[200]) h.pt3dadd(790.5, -340.5, -120, 2.3, sec = self.dend[200]) h.pt3dadd(793.5, -341.5, -129.5, 1.6, sec = self.dend[200]) h.pt3dadd(795, -343, -124.5, 0.8, sec = self.dend[200]) h.pt3dadd(797.5, -345, -127, 0.8, sec = self.dend[200]) h.pt3dclear(sec = self.dend[201]) h.pt3dadd(652, -246.5, -110.5, 4.5, sec = self.dend[201]) h.pt3dadd(658, -250, -115, 0.1, sec = self.dend[201]) h.pt3dadd(658.5, -251.5, -115, 0.1, sec = self.dend[201]) h.pt3dadd(661, -253, -115, 0.1, sec = self.dend[201]) h.pt3dadd(663, -254.5, -115, 0.1, sec = self.dend[201]) h.pt3dadd(665, -254.5, -115, 0.1, sec = self.dend[201]) h.pt3dadd(667, -256.5, -115, 2.1, sec = self.dend[201]) h.pt3dadd(669.5, -257.5, -115, 0.1, sec = self.dend[201]) h.pt3dadd(673, -259, -115, 0.1, sec = self.dend[201]) h.pt3dadd(674.5, -259.5, -120, 2, sec = self.dend[201]) h.pt3dadd(677, -260, -117.5, 3.1, sec = self.dend[201]) h.pt3dadd(679, -262.5, -120, 1.6, sec = self.dend[201]) h.pt3dadd(681.5, -262.5, -117.5, 0.1, sec = self.dend[201]) h.pt3dadd(682.5, -265, -117.5, 0.1, sec = self.dend[201]) h.pt3dadd(683, -264.5, -122.5, 0.1, sec = self.dend[201]) h.pt3dadd(684.5, -264, -122.5, 1.9, sec = self.dend[201]) h.pt3dadd(686.5, -264, -120, 2.7, sec = self.dend[201]) h.pt3dadd(689, -264, -120, 1.4, sec = self.dend[201]) h.pt3dadd(690, -264, -120, 0.1, sec = self.dend[201]) h.pt3dadd(693, -266, -124.5, 0.1, sec = self.dend[201]) h.pt3dadd(694.5, -267, -122.5, 1.4, sec = self.dend[201]) h.pt3dadd(696.5, -267.5, -122.5, 2, sec = self.dend[201]) h.pt3dadd(698, -267.5, -122.5, 1.5, sec = self.dend[201]) h.pt3dadd(699, -267.5, -120, 0.1, sec = self.dend[201]) h.pt3dadd(700.5, -268, -124.5, 0.1, sec = self.dend[201]) h.pt3dadd(703, -269, -122.5, 2.2, sec = self.dend[201]) h.pt3dadd(706.5, -270, -129.5, 1.4, sec = self.dend[201]) h.pt3dadd(707, -270, -132, 0.1, sec = self.dend[201]) h.pt3dadd(707.5, -270.5, -129.5, 0.1, sec = self.dend[201]) h.pt3dadd(709.5, -272, -127, 0.1, sec = self.dend[201]) h.pt3dadd(712, -273, -127, 1.1, sec = self.dend[201]) h.pt3dadd(713.5, -274, -129.5, 1.1, sec = self.dend[201]) h.pt3dadd(714.5, -276, -132, 0.1, sec = self.dend[201]) h.pt3dadd(716, -276.5, -127, 0.1, sec = self.dend[201]) h.pt3dadd(720, -278, -127, 0.1, sec = self.dend[201]) h.pt3dadd(721.5, -278, -124.5, 1.9, sec = self.dend[201]) h.pt3dadd(724, -277.5, -124.5, 2.3, sec = self.dend[201]) h.pt3dadd(725, -277.5, -124.5, 2.3, sec = self.dend[201]) h.pt3dadd(726.5, -277.5, -124.5, 1.5, sec = self.dend[201]) h.pt3dadd(728.5, -276, -124.5, 1, sec = self.dend[201]) h.pt3dadd(729.5, -276.5, -124.5, 1.4, sec = self.dend[201]) h.pt3dadd(731.5, -276.5, -124.5, 3.3, sec = self.dend[201]) h.pt3dadd(733, -277, -124.5, 3.7, sec = self.dend[201]) h.pt3dadd(735.5, -277.5, -124.5, 2.4, sec = self.dend[201]) h.pt3dadd(737.5, -278, -122.5, 1.1, sec = self.dend[201]) h.pt3dadd(740, -277.5, -115, 1, sec = self.dend[201]) h.pt3dadd(743, -277.5, -115, 1, sec = self.dend[201]) h.pt3dadd(743.5, -278.5, -117.5, 1, sec = self.dend[201]) h.pt3dadd(745, -280, -115, 1.5, sec = self.dend[201]) h.pt3dadd(746.5, -281, -115, 1.1, sec = self.dend[201]) h.pt3dadd(747, -282, -115, 0.2, sec = self.dend[201]) h.pt3dadd(748, -282.5, -115, 0.2, sec = self.dend[201]) h.pt3dadd(749, -282.5, -115, 1.2, sec = self.dend[201]) h.pt3dadd(749.5, -284, -115, 1.6, sec = self.dend[201]) h.pt3dadd(751, -284, -117.5, 1.1, sec = self.dend[201]) h.pt3dadd(754, -284, -120, 0.1, sec = self.dend[201]) h.pt3dadd(755.5, -285.5, -120, 1.6, sec = self.dend[201]) h.pt3dadd(757, -287.5, -120, 1.6, sec = self.dend[201]) h.pt3dadd(757, -289, -122.5, 1.4, sec = self.dend[201]) h.pt3dadd(757, -290, -120, 0.2, sec = self.dend[201]) h.pt3dadd(757.5, -290.5, -120, 0.2, sec = self.dend[201]) h.pt3dadd(757.5, -292, -120, 1.8, sec = self.dend[201]) h.pt3dadd(758.5, -294, -120, 1.9, sec = self.dend[201]) h.pt3dadd(759, -295.5, -115, 1.3, sec = self.dend[201]) h.pt3dadd(760.5, -297, -115, 0.4, sec = self.dend[201]) h.pt3dadd(763, -298.5, -115, 0.4, sec = self.dend[201]) h.pt3dadd(764.5, -299.5, -120, 1.2, sec = self.dend[201]) h.pt3dadd(765.5, -301, -120, 0.7, sec = self.dend[201]) h.pt3dadd(766.5, -302, -120, 1.3, sec = self.dend[201]) h.pt3dadd(767.5, -302.5, -117.5, 2.5, sec = self.dend[201]) h.pt3dadd(769.5, -303, -117.5, 1.2, sec = self.dend[201]) h.pt3dadd(769.5, -304, -117.5, 0.1, sec = self.dend[201]) h.pt3dadd(770.5, -305.5, -117.5, 0.1, sec = self.dend[201]) h.pt3dadd(773.5, -306.5, -117.5, 0.1, sec = self.dend[201]) h.pt3dadd(775.5, -309, -120, 0.1, sec = self.dend[201]) h.pt3dadd(777.5, -309.5, -120, 0.1, sec = self.dend[201]) h.pt3dadd(778.5, -310.5, -120, 1.1, sec = self.dend[201]) h.pt3dadd(780, -312.5, -120, 1.5, sec = self.dend[201]) h.pt3dadd(781, -312.5, -120, 1.7, sec = self.dend[201]) h.pt3dadd(781, -314.5, -120, 0.9, sec = self.dend[201]) h.pt3dadd(783.5, -314.5, -122.5, 0.1, sec = self.dend[201]) h.pt3dadd(787, -315.5, -124.5, 0.1, sec = self.dend[201]) h.pt3dadd(790, -317, -124.5, 0.1, sec = self.dend[201]) h.pt3dadd(792, -318, -120, 1.2, sec = self.dend[201]) h.pt3dadd(795, -318.5, -124.5, 1.4, sec = self.dend[201]) h.pt3dadd(797.5, -318.5, -127, 1.2, sec = self.dend[201]) h.pt3dadd(801, -318.5, -129.5, 0.7, sec = self.dend[201]) h.pt3dadd(802, -318, -127, 0.6, sec = self.dend[201]) h.pt3dadd(803, -316, -124.5, 1.3, sec = self.dend[201]) h.pt3dadd(804.5, -316, -127, 0.7, sec = self.dend[201]) h.pt3dadd(807.5, -316, -120, 0.7, sec = self.dend[201]) h.pt3dadd(811, -316, -120, 0.7, sec = self.dend[201]) h.pt3dadd(813.5, -314, -122.5, 0.7, sec = self.dend[201]) h.pt3dadd(816, -314, -122.5, 0.7, sec = self.dend[201]) h.pt3dadd(818.5, -314, -122.5, 0.8, sec = self.dend[201]) h.pt3dadd(820, -314, -122.5, 1.6, sec = self.dend[201]) h.pt3dadd(820.5, -312.5, -122.5, 1.6, sec = self.dend[201]) h.pt3dadd(823, -312.5, -122.5, 1.1, sec = self.dend[201]) h.pt3dadd(826, -312.5, -122.5, 0.8, sec = self.dend[201]) h.pt3dadd(827.5, -310.5, -127, 0.1, sec = self.dend[201]) h.pt3dadd(832.5, -310.5, -120, 0.1, sec = self.dend[201]) h.pt3dadd(835, -307, -124.5, 0.1, sec = self.dend[201]) h.pt3dadd(837.5, -307, -124.5, 1.1, sec = self.dend[201]) h.pt3dclear(sec = self.dend[202]) h.pt3dadd(837.5, -307, -124.5, 1.1, sec = self.dend[202]) h.pt3dadd(839, -305.5, -124.5, 0.9, sec = self.dend[202]) h.pt3dadd(842, -303.5, -124.5, 0.9, sec = self.dend[202]) h.pt3dadd(845.5, -303.5, -124.5, 0.8, sec = self.dend[202]) h.pt3dadd(847.5, -303, -124.5, 0.8, sec = self.dend[202]) h.pt3dadd(850, -303, -124.5, 0.6, sec = self.dend[202]) h.pt3dadd(851.5, -300.5, -124.5, 0.9, sec = self.dend[202]) h.pt3dadd(852, -299, -124.5, 0.7, sec = self.dend[202]) h.pt3dadd(854, -297.5, -124.5, 0.7, sec = self.dend[202]) h.pt3dadd(855, -297, -124.5, 0.7, sec = self.dend[202]) h.pt3dadd(858.5, -296, -124.5, 1.3, sec = self.dend[202]) h.pt3dadd(859.5, -295, -122.5, 1.2, sec = self.dend[202]) h.pt3dadd(861.5, -293.5, -122.5, 0.2, sec = self.dend[202]) h.pt3dadd(863.5, -293.5, -122.5, 0.2, sec = self.dend[202]) h.pt3dadd(867, -293.5, -120, 1.6, sec = self.dend[202]) h.pt3dadd(869, -292.5, -120, 0.3, sec = self.dend[202]) h.pt3dadd(871.5, -293, -124.5, 0.3, sec = self.dend[202]) h.pt3dadd(875, -293, -124.5, 1.6, sec = self.dend[202]) h.pt3dadd(877.5, -293, -124.5, 0.2, sec = self.dend[202]) h.pt3dadd(881, -292.5, -124.5, 0.2, sec = self.dend[202]) h.pt3dadd(885, -295.5, -124.5, 0.3, sec = self.dend[202]) h.pt3dadd(888.5, -295.5, -124.5, 0.6, sec = self.dend[202]) h.pt3dadd(890, -295, -129.5, 1.6, sec = self.dend[202]) h.pt3dadd(893, -295, -129.5, 0.1, sec = self.dend[202]) h.pt3dadd(896, -295, -129.5, 0.1, sec = self.dend[202]) h.pt3dadd(898, -294.5, -124.5, 0.9, sec = self.dend[202]) h.pt3dadd(899, -294.5, -124.5, 0.3, sec = self.dend[202]) h.pt3dadd(898.5, -294.5, -124.5, 0.3, sec = self.dend[202]) h.pt3dadd(903.5, -294.5, -127, 1.6, sec = self.dend[202]) h.pt3dadd(904.5, -294.5, -122.5, 0.1, sec = self.dend[202]) h.pt3dadd(908.5, -294.5, -129.5, 0.1, sec = self.dend[202]) h.pt3dadd(912, -294.5, -132, 0.1, sec = self.dend[202]) h.pt3dadd(916, -293.5, -132, 0.1, sec = self.dend[202]) h.pt3dadd(920, -293.5, -127, 0.1, sec = self.dend[202]) h.pt3dadd(923.5, -291.5, -127, 0.1, sec = self.dend[202]) h.pt3dadd(927.5, -291.5, -129.5, 0.1, sec = self.dend[202]) h.pt3dclear(sec = self.dend[203]) h.pt3dadd(837.5, -307, -124.5, 1.1, sec = self.dend[203]) h.pt3dadd(839.5, -310, -117.5, 1.2, sec = self.dend[203]) h.pt3dadd(843, -310, -124.5, 1.4, sec = self.dend[203]) h.pt3dadd(847.5, -309.5, -120, 1.4, sec = self.dend[203]) h.pt3dadd(850, -308.5, -124.5, 1.1, sec = self.dend[203]) h.pt3dadd(853.5, -308.5, -115, 0.9, sec = self.dend[203]) h.pt3dadd(856.5, -306.5, -117.5, 0.9, sec = self.dend[203]) h.pt3dadd(858.5, -303, -113, 0.7, sec = self.dend[203]) h.pt3dadd(862, -301.5, -113, 0.7, sec = self.dend[203]) h.pt3dadd(864, -301.5, -110.5, 1.5, sec = self.dend[203]) h.pt3dadd(867.5, -300.5, -110.5, 1.5, sec = self.dend[203]) h.pt3dadd(869, -300.5, -108, 0.7, sec = self.dend[203]) h.pt3dadd(871.5, -298, -108, 0.7, sec = self.dend[203]) h.pt3dadd(873.5, -296, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(878, -296, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(881.5, -294, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(885.5, -293.5, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(889.5, -290.5, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(891.5, -289, -103.5, 0.7, sec = self.dend[203]) h.pt3dadd(898, -285.5, -103.5, 0.7, sec = self.dend[203]) h.pt3dclear(sec = self.dend[204]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[204]) h.pt3dadd(80, 56.5, -15, 13.7, sec = self.dend[204]) h.pt3dadd(82.5, 58.5, -10, 13, sec = self.dend[204]) h.pt3dadd(88.5, 60, -10, 12, sec = self.dend[204]) h.pt3dadd(92, 63.5, -9.5, 10.6, sec = self.dend[204]) h.pt3dadd(98.5, 67.5, -13, 10.1, sec = self.dend[204]) h.pt3dadd(102, 69.5, -13, 10.1, sec = self.dend[204]) h.pt3dadd(106, 70.5, -13, 11.3, sec = self.dend[204]) h.pt3dadd(109.5, 70, -13, 12, sec = self.dend[204]) h.pt3dadd(114, 71, -13, 11.7, sec = self.dend[204]) h.pt3dadd(120.5, 72, -11, 10.8, sec = self.dend[204]) h.pt3dadd(124.5, 75, -12, 10.9, sec = self.dend[204]) h.pt3dadd(129, 77.5, -12, 12.5, sec = self.dend[204]) h.pt3dadd(132, 79, -12, 12.4, sec = self.dend[204]) h.pt3dadd(135.5, 80, -13, 12.4, sec = self.dend[204]) h.pt3dadd(140, 81.5, -13, 11.3, sec = self.dend[204]) h.pt3dadd(144.5, 83, -15, 10.1, sec = self.dend[204]) h.pt3dadd(148, 83, -15, 10.1, sec = self.dend[204]) h.pt3dadd(152, 83, -15.5, 10.1, sec = self.dend[204]) h.pt3dadd(157, 85.5, -15.5, 11.6, sec = self.dend[204]) h.pt3dclear(sec = self.dend[205]) h.pt3dadd(157, 85.5, -15.5, 11.6, sec = self.dend[205]) h.pt3dadd(163, 81, -11, 4.2, sec = self.dend[205]) h.pt3dadd(169, 80.5, -13, 4.4, sec = self.dend[205]) h.pt3dadd(173.5, 80.5, -13, 4.2, sec = self.dend[205]) h.pt3dadd(179.5, 80.5, -15, 4.5, sec = self.dend[205]) h.pt3dadd(184.5, 80.5, -15, 5.2, sec = self.dend[205]) h.pt3dadd(188, 80.5, -14, 5.5, sec = self.dend[205]) h.pt3dadd(192, 81, -12, 6.2, sec = self.dend[205]) h.pt3dadd(197, 81, -13, 5.5, sec = self.dend[205]) h.pt3dadd(199.5, 81, -14, 5, sec = self.dend[205]) h.pt3dadd(201.5, 81, -15, 4.9, sec = self.dend[205]) h.pt3dadd(206, 81, -15, 4.7, sec = self.dend[205]) h.pt3dadd(209, 81, -15, 4.7, sec = self.dend[205]) h.pt3dadd(211, 81, -15, 4.1, sec = self.dend[205]) h.pt3dadd(214, 81, -15, 4.1, sec = self.dend[205]) h.pt3dadd(217.5, 81, -15, 4.6, sec = self.dend[205]) h.pt3dadd(221.5, 80, -15, 5.7, sec = self.dend[205]) h.pt3dadd(224, 79, -15, 5.3, sec = self.dend[205]) h.pt3dadd(228, 79, -15, 5.8, sec = self.dend[205]) h.pt3dadd(230.5, 78, -15, 6.2, sec = self.dend[205]) h.pt3dadd(236, 79.5, -15, 5.8, sec = self.dend[205]) h.pt3dadd(242, 80.5, -15.5, 6.2, sec = self.dend[205]) h.pt3dadd(247, 84, -12, 6.2, sec = self.dend[205]) h.pt3dadd(251.5, 85, -12, 6.3, sec = self.dend[205]) h.pt3dadd(254, 86, -12, 6.4, sec = self.dend[205]) h.pt3dadd(257, 86.5, -12, 5.7, sec = self.dend[205]) h.pt3dadd(261, 86.5, -13, 5, sec = self.dend[205]) h.pt3dadd(264.5, 85.5, -13, 5.3, sec = self.dend[205]) h.pt3dadd(267.5, 85.5, -14, 5.8, sec = self.dend[205]) h.pt3dclear(sec = self.dend[206]) h.pt3dadd(267.5, 85.5, -14, 5.8, sec = self.dend[206]) h.pt3dadd(270.5, 81, -6.5, 2.9, sec = self.dend[206]) h.pt3dadd(275, 81, -7.5, 3.1, sec = self.dend[206]) h.pt3dadd(280, 81.5, -7.5, 3.3, sec = self.dend[206]) h.pt3dadd(284, 81.5, -7.5, 3.7, sec = self.dend[206]) h.pt3dadd(288, 81.5, -7.5, 4, sec = self.dend[206]) h.pt3dadd(292.5, 81.5, -6.5, 4.1, sec = self.dend[206]) h.pt3dadd(297.5, 79.5, -6.5, 4.2, sec = self.dend[206]) h.pt3dadd(300.5, 79.5, -6.5, 4.9, sec = self.dend[206]) h.pt3dadd(305, 78.5, -8.5, 6.1, sec = self.dend[206]) h.pt3dclear(sec = self.dend[207]) h.pt3dadd(305, 78.5, -8.5, 6.1, sec = self.dend[207]) h.pt3dadd(306.5, 76.5, -8.5, 3.5, sec = self.dend[207]) h.pt3dadd(309.5, 74, -10, 2.7, sec = self.dend[207]) h.pt3dadd(313, 74, -10, 2.7, sec = self.dend[207]) h.pt3dadd(316, 71, -11, 2.5, sec = self.dend[207]) h.pt3dadd(317.5, 67.5, -11, 2.3, sec = self.dend[207]) h.pt3dadd(319, 65.5, -8.5, 2.3, sec = self.dend[207]) h.pt3dadd(319, 63.5, -9.5, 2.7, sec = self.dend[207]) h.pt3dadd(321, 61, -10, 1.9, sec = self.dend[207]) h.pt3dadd(323, 58, -10, 2.4, sec = self.dend[207]) h.pt3dadd(323.5, 54.5, -10, 2.5, sec = self.dend[207]) h.pt3dadd(324, 52, -10, 2.8, sec = self.dend[207]) h.pt3dadd(325, 48, -9.5, 2.9, sec = self.dend[207]) h.pt3dadd(326.5, 46, -12, 3.3, sec = self.dend[207]) h.pt3dadd(327.5, 42.5, -12, 3.3, sec = self.dend[207]) h.pt3dadd(328.5, 41, -12, 2.8, sec = self.dend[207]) h.pt3dadd(332.5, 37.5, -12, 2.7, sec = self.dend[207]) h.pt3dadd(335, 34.5, -13, 2.2, sec = self.dend[207]) h.pt3dadd(338.5, 30.5, -14, 2.4, sec = self.dend[207]) h.pt3dadd(339.5, 27.5, -15, 2.8, sec = self.dend[207]) h.pt3dadd(342.5, 24, -14, 2.3, sec = self.dend[207]) h.pt3dadd(345, 21.5, -14, 3.1, sec = self.dend[207]) h.pt3dadd(347, 18, -13, 2, sec = self.dend[207]) h.pt3dadd(349, 17, -10, 2.3, sec = self.dend[207]) h.pt3dadd(351.5, 13.5, -9, 2.3, sec = self.dend[207]) h.pt3dadd(353.5, 12, -10, 3.1, sec = self.dend[207]) h.pt3dadd(358, 11.5, -11, 3.3, sec = self.dend[207]) h.pt3dadd(361, 10.5, -11, 2.3, sec = self.dend[207]) h.pt3dadd(363.5, 9.5, -11, 1.7, sec = self.dend[207]) h.pt3dadd(364.5, 8.5, -12.5, 1.2, sec = self.dend[207]) h.pt3dadd(367.5, 8.5, -11, 1.2, sec = self.dend[207]) h.pt3dadd(368, 7.5, -11, 1.5, sec = self.dend[207]) h.pt3dadd(370.5, 5, -11, 2, sec = self.dend[207]) h.pt3dadd(372, 4.5, -11, 2.1, sec = self.dend[207]) h.pt3dadd(373.5, 1.5, -11, 2.4, sec = self.dend[207]) h.pt3dadd(374.5, 0.5, -11, 2.8, sec = self.dend[207]) h.pt3dadd(375.5, -1.5, -11, 2.5, sec = self.dend[207]) h.pt3dadd(378, -3, -11, 1.7, sec = self.dend[207]) h.pt3dadd(381.5, -3.5, -12.5, 1.6, sec = self.dend[207]) h.pt3dadd(384.5, -4.5, -12.5, 2.2, sec = self.dend[207]) h.pt3dadd(388, -4.5, -12.5, 2.2, sec = self.dend[207]) h.pt3dadd(389.5, -5.5, -12.5, 1.4, sec = self.dend[207]) h.pt3dadd(391, -6.5, -12.5, 1.2, sec = self.dend[207]) h.pt3dadd(393.5, -6.5, -13.5, 2.2, sec = self.dend[207]) h.pt3dadd(394.5, -6, -13.5, 1.4, sec = self.dend[207]) h.pt3dadd(397, -5, -13.5, 2, sec = self.dend[207]) h.pt3dadd(399.5, -5, -13.5, 1.7, sec = self.dend[207]) h.pt3dadd(401.5, -4, -12.5, 1.9, sec = self.dend[207]) h.pt3dadd(405, -4, -12.5, 1.4, sec = self.dend[207]) h.pt3dadd(406.5, -4.5, -13.5, 1.1, sec = self.dend[207]) h.pt3dadd(407.5, -4.5, -14.5, 1.1, sec = self.dend[207]) h.pt3dadd(410, -5, -14.5, 1.4, sec = self.dend[207]) h.pt3dadd(411.5, -5, -14.5, 1.6, sec = self.dend[207]) h.pt3dadd(413, -6, -14.5, 2.1, sec = self.dend[207]) h.pt3dadd(416.5, -8, -17, 3.6, sec = self.dend[207]) h.pt3dadd(418, -10, -17, 2.8, sec = self.dend[207]) h.pt3dadd(419.5, -10.5, -17, 2, sec = self.dend[207]) h.pt3dadd(420, -11.5, -17, 1.3, sec = self.dend[207]) h.pt3dadd(422, -12.5, -17, 1.4, sec = self.dend[207]) h.pt3dadd(423, -14, -18, 1.4, sec = self.dend[207]) h.pt3dadd(426, -16, -18, 1.3, sec = self.dend[207]) h.pt3dadd(427.5, -16, -19, 1.5, sec = self.dend[207]) h.pt3dadd(429, -17.5, -17, 2, sec = self.dend[207]) h.pt3dadd(430, -19, -18, 2.4, sec = self.dend[207]) h.pt3dadd(433, -21, -18, 2.6, sec = self.dend[207]) h.pt3dadd(435, -23, -19, 3.2, sec = self.dend[207]) h.pt3dadd(438, -23.5, -18, 3.1, sec = self.dend[207]) h.pt3dadd(442, -25.5, -18, 1.8, sec = self.dend[207]) h.pt3dadd(445, -26, -18.5, 1.8, sec = self.dend[207]) h.pt3dadd(446.5, -28, -18.5, 1.8, sec = self.dend[207]) h.pt3dadd(448.5, -28, -18.5, 1.5, sec = self.dend[207]) h.pt3dadd(450, -28, -18.5, 1.4, sec = self.dend[207]) h.pt3dadd(452, -28, -19.5, 1.2, sec = self.dend[207]) h.pt3dadd(456, -27, -19.5, 0.7, sec = self.dend[207]) h.pt3dadd(459, -28, -19.5, 0.7, sec = self.dend[207]) h.pt3dadd(460.5, -29, -18.5, 1.8, sec = self.dend[207]) h.pt3dadd(461.5, -30, -19.5, 3.2, sec = self.dend[207]) h.pt3dadd(463, -30, -19.5, 2.9, sec = self.dend[207]) h.pt3dadd(466.5, -33.5, -20, 2, sec = self.dend[207]) h.pt3dadd(469, -33.5, -20, 0.5, sec = self.dend[207]) h.pt3dadd(471.5, -35, -20.5, 0.5, sec = self.dend[207]) h.pt3dadd(473, -35, -20, 2.1, sec = self.dend[207]) h.pt3dadd(475.5, -37.5, -20, 2.6, sec = self.dend[207]) h.pt3dadd(478.5, -37.5, -20, 2.8, sec = self.dend[207]) h.pt3dadd(480.5, -38, -20, 3.8, sec = self.dend[207]) h.pt3dadd(483.5, -39.5, -20, 2.5, sec = self.dend[207]) h.pt3dadd(485, -40, -20, 1.6, sec = self.dend[207]) h.pt3dadd(486.5, -40, -20, 0.8, sec = self.dend[207]) h.pt3dadd(490, -41.5, -20, 0.7, sec = self.dend[207]) h.pt3dadd(493, -41.5, -20, 0.9, sec = self.dend[207]) h.pt3dadd(496, -43, -20, 0.9, sec = self.dend[207]) h.pt3dadd(497, -43, -20.5, 0.9, sec = self.dend[207]) h.pt3dadd(497, -44, -19.5, 0.6, sec = self.dend[207]) h.pt3dadd(499, -44, -20, 1.9, sec = self.dend[207]) h.pt3dadd(503.5, -45, -20, 1.1, sec = self.dend[207]) h.pt3dadd(504, -46, -19.5, 1.2, sec = self.dend[207]) h.pt3dadd(507.5, -46.5, -19.5, 1.2, sec = self.dend[207]) h.pt3dadd(510, -46.5, -20.5, 0.8, sec = self.dend[207]) h.pt3dadd(511, -47, -21.5, 1.3, sec = self.dend[207]) h.pt3dadd(512.5, -47.5, -20, 2.3, sec = self.dend[207]) h.pt3dadd(514, -49, -21.5, 3.1, sec = self.dend[207]) h.pt3dadd(516, -50, -20, 1.6, sec = self.dend[207]) h.pt3dadd(518, -49, -21.5, 1.8, sec = self.dend[207]) h.pt3dadd(520, -49, -22, 1.5, sec = self.dend[207]) h.pt3dadd(523, -49, -22.5, 1.2, sec = self.dend[207]) h.pt3dadd(525.5, -49, -22.5, 1, sec = self.dend[207]) h.pt3dadd(528, -49, -22.5, 1.3, sec = self.dend[207]) h.pt3dadd(529, -49, -22.5, 2, sec = self.dend[207]) h.pt3dadd(531.5, -48.5, -22.5, 2.2, sec = self.dend[207]) h.pt3dadd(533.5, -48, -22.5, 1.6, sec = self.dend[207]) h.pt3dadd(535.5, -47, -22.5, 0.4, sec = self.dend[207]) h.pt3dadd(539.5, -44, -22.5, 0.4, sec = self.dend[207]) h.pt3dadd(541.5, -44, -22.5, 1.4, sec = self.dend[207]) h.pt3dadd(542, -42.5, -22.5, 2.1, sec = self.dend[207]) h.pt3dadd(543.5, -41.5, -22.5, 2.5, sec = self.dend[207]) h.pt3dadd(546, -41, -22.5, 2, sec = self.dend[207]) h.pt3dadd(546.5, -39, -22.5, 0.9, sec = self.dend[207]) h.pt3dadd(548, -38.5, -23.5, 0.5, sec = self.dend[207]) h.pt3dadd(550.5, -35.5, -23.5, 0.7, sec = self.dend[207]) h.pt3dadd(553.5, -33, -23.5, 0.7, sec = self.dend[207]) h.pt3dadd(555.5, -32, -23.5, 1.2, sec = self.dend[207]) h.pt3dadd(558.5, -31.5, -23.5, 1.3, sec = self.dend[207]) h.pt3dadd(560, -29, -24, 1.2, sec = self.dend[207]) h.pt3dadd(561, -29, -24, 1.2, sec = self.dend[207]) h.pt3dadd(562, -27.5, -24, 0.7, sec = self.dend[207]) h.pt3dadd(564.5, -26, -24, 0.7, sec = self.dend[207]) h.pt3dadd(567, -25, -23.5, 0.7, sec = self.dend[207]) h.pt3dadd(569, -25.5, -23.5, 1.8, sec = self.dend[207]) h.pt3dadd(571.5, -25, -23.5, 2.4, sec = self.dend[207]) h.pt3dadd(575.5, -24.5, -24, 1.6, sec = self.dend[207]) h.pt3dadd(578.5, -24, -24, 1.1, sec = self.dend[207]) h.pt3dadd(582, -22.5, -24, 1.1, sec = self.dend[207]) h.pt3dadd(585, -21.5, -24, 1.1, sec = self.dend[207]) h.pt3dadd(586.5, -20, -24, 1.8, sec = self.dend[207]) h.pt3dadd(590, -19.5, -23.5, 2.5, sec = self.dend[207]) h.pt3dadd(594, -19.5, -23.5, 1.6, sec = self.dend[207]) h.pt3dadd(595.5, -19, -24.5, 0.8, sec = self.dend[207]) h.pt3dadd(598, -18, -23.5, 0.8, sec = self.dend[207]) h.pt3dadd(601.5, -18, -23.5, 1.1, sec = self.dend[207]) h.pt3dadd(605, -18, -23.5, 1.6, sec = self.dend[207]) h.pt3dadd(607.5, -18, -23.5, 1.4, sec = self.dend[207]) h.pt3dadd(609, -18.5, -23.5, 1.2, sec = self.dend[207]) h.pt3dadd(611, -19.5, -24, 1, sec = self.dend[207]) h.pt3dadd(612.5, -18.5, -24, 0.7, sec = self.dend[207]) h.pt3dadd(615, -17, -23.5, 0.7, sec = self.dend[207]) h.pt3dadd(621, -14.5, -23.5, 0.7, sec = self.dend[207]) h.pt3dadd(624, -14, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(626.5, -14, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(627.5, -14, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(629.5, -13.5, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(630, -12.5, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(630.5, -11, -23.5, 0.6, sec = self.dend[207]) h.pt3dadd(631, -12, -23.5, 0.9, sec = self.dend[207]) h.pt3dadd(633, -12, -23.5, 0.9, sec = self.dend[207]) h.pt3dadd(634.5, -11, -30, 1.3, sec = self.dend[207]) h.pt3dadd(635.5, -11, -30, 1.3, sec = self.dend[207]) h.pt3dadd(635.5, -11, -23.5, 1.9, sec = self.dend[207]) h.pt3dadd(636.5, -11, -30, 2.8, sec = self.dend[207]) h.pt3dadd(637.5, -11, -23.5, 3.6, sec = self.dend[207]) h.pt3dadd(638.5, -11, -23.5, 3, sec = self.dend[207]) h.pt3dadd(639, -10, -23.5, 2.3, sec = self.dend[207]) h.pt3dadd(640, -10, -23.5, 1.6, sec = self.dend[207]) h.pt3dadd(641, -10, -30, 1.2, sec = self.dend[207]) h.pt3dadd(641.5, -10, -30, 0.9, sec = self.dend[207]) h.pt3dadd(643, -10, -30, 0.9, sec = self.dend[207]) h.pt3dadd(644, -10, -30, 0.9, sec = self.dend[207]) h.pt3dadd(645.5, -9.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(647, -8.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(648, -9, -30, 1.1, sec = self.dend[207]) h.pt3dadd(648.5, -10, -30, 1.3, sec = self.dend[207]) h.pt3dadd(649.5, -10, -30, 1.5, sec = self.dend[207]) h.pt3dadd(651.5, -8.5, -30, 2, sec = self.dend[207]) h.pt3dadd(653, -8.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(653.5, -8.5, -30, 1.1, sec = self.dend[207]) h.pt3dadd(655, -8.5, -30, 1, sec = self.dend[207]) h.pt3dadd(656, -8.5, -30, 1, sec = self.dend[207]) h.pt3dadd(658, -8, -30, 1.7, sec = self.dend[207]) h.pt3dadd(658.5, -8, -30, 2.4, sec = self.dend[207]) h.pt3dadd(660.5, -7, -36, 2.7, sec = self.dend[207]) h.pt3dadd(661.5, -7, -36, 2.3, sec = self.dend[207]) h.pt3dadd(664, -7, -36, 1.4, sec = self.dend[207]) h.pt3dadd(666.5, -7, -36, 0.9, sec = self.dend[207]) h.pt3dadd(668.5, -7, -36, 0.9, sec = self.dend[207]) h.pt3dadd(669, -7, -36, 1.2, sec = self.dend[207]) h.pt3dadd(670, -7, -36, 1.3, sec = self.dend[207]) h.pt3dadd(671.5, -7, -36, 1.8, sec = self.dend[207]) h.pt3dadd(674, -5.5, -36, 1.1, sec = self.dend[207]) h.pt3dadd(674.5, -4.5, -36, 1, sec = self.dend[207]) h.pt3dadd(676, -4.5, -36, 1.7, sec = self.dend[207]) h.pt3dadd(678, -4.5, -36, 2.6, sec = self.dend[207]) h.pt3dadd(679.5, -4.5, -36, 1.7, sec = self.dend[207]) h.pt3dadd(682, -4.5, -36, 1.2, sec = self.dend[207]) h.pt3dadd(683.5, -4.5, -36, 1.2, sec = self.dend[207]) h.pt3dadd(684, -5, -36, 0.8, sec = self.dend[207]) h.pt3dadd(685.5, -5, -36, 0.7, sec = self.dend[207]) h.pt3dadd(686.5, -5.5, -36, 1.1, sec = self.dend[207]) h.pt3dadd(688.5, -6, -36, 1.4, sec = self.dend[207]) h.pt3dadd(689, -6, -36, 1.4, sec = self.dend[207]) h.pt3dadd(689.5, -6.5, -42.5, 1.3, sec = self.dend[207]) h.pt3dadd(691, -7, -42.5, 0.8, sec = self.dend[207]) h.pt3dadd(693, -7, -36, 1, sec = self.dend[207]) h.pt3dadd(693.5, -7, -36, 1.4, sec = self.dend[207]) h.pt3dadd(695, -7.5, -36, 1.8, sec = self.dend[207]) h.pt3dadd(696.5, -7.5, -36, 2.5, sec = self.dend[207]) h.pt3dadd(698.5, -7, -36, 2.4, sec = self.dend[207]) h.pt3dadd(701.5, -7, -36, 1, sec = self.dend[207]) h.pt3dadd(703, -7, -36, 0.7, sec = self.dend[207]) h.pt3dadd(703.5, -8, -36, 1.5, sec = self.dend[207]) h.pt3dadd(705.5, -8.5, -36, 1.6, sec = self.dend[207]) h.pt3dadd(707.5, -10, -36, 1.2, sec = self.dend[207]) h.pt3dadd(710, -11, -36, 1, sec = self.dend[207]) h.pt3dadd(710.5, -12, -36, 1, sec = self.dend[207]) h.pt3dadd(711.5, -12, -36, 1.5, sec = self.dend[207]) h.pt3dadd(714, -13, -36, 2.1, sec = self.dend[207]) h.pt3dadd(714.5, -14, -36, 2.5, sec = self.dend[207]) h.pt3dadd(716, -14, -36, 1.6, sec = self.dend[207]) h.pt3dadd(717, -15, -36, 1.1, sec = self.dend[207]) h.pt3dadd(718, -15.5, -36, 0.5, sec = self.dend[207]) h.pt3dadd(719.5, -15.5, -36, 0.5, sec = self.dend[207]) h.pt3dadd(721, -15.5, -36, 0.4, sec = self.dend[207]) h.pt3dadd(723, -15.5, -36, 1.1, sec = self.dend[207]) h.pt3dadd(724, -16, -36, 1.7, sec = self.dend[207]) h.pt3dadd(726, -17.5, -36, 2.1, sec = self.dend[207]) h.pt3dadd(728, -17.5, -36, 2.4, sec = self.dend[207]) h.pt3dadd(730, -18, -36, 1.9, sec = self.dend[207]) h.pt3dadd(731, -18, -36, 1.5, sec = self.dend[207]) h.pt3dadd(733, -18, -36, 1.1, sec = self.dend[207]) h.pt3dadd(735, -18, -36, 1.1, sec = self.dend[207]) h.pt3dadd(737, -18, -36, 1.1, sec = self.dend[207]) h.pt3dadd(739, -18, -36, 1.1, sec = self.dend[207]) h.pt3dadd(740.5, -18.5, -42.5, 1.4, sec = self.dend[207]) h.pt3dadd(741.5, -18, -42.5, 1.7, sec = self.dend[207]) h.pt3dadd(743, -18, -42.5, 2.3, sec = self.dend[207]) h.pt3dadd(744.5, -19.5, -42.5, 1.4, sec = self.dend[207]) h.pt3dadd(748, -19.5, -42.5, 1.1, sec = self.dend[207]) h.pt3dadd(749.5, -19.5, -42.5, 0.9, sec = self.dend[207]) h.pt3dadd(751, -19.5, -42.5, 1.1, sec = self.dend[207]) h.pt3dadd(753.5, -19.5, -42.5, 1.2, sec = self.dend[207]) h.pt3dadd(755, -18.5, -42.5, 1.7, sec = self.dend[207]) h.pt3dadd(756, -18.5, -42.5, 2.6, sec = self.dend[207]) h.pt3dadd(757.5, -18, -42.5, 3.2, sec = self.dend[207]) h.pt3dadd(758.5, -18, -42.5, 2.4, sec = self.dend[207]) h.pt3dadd(761, -18.5, -36, 1.6, sec = self.dend[207]) h.pt3dadd(762, -18.5, -36, 1.2, sec = self.dend[207]) h.pt3dadd(763.5, -19, -36, 1.2, sec = self.dend[207]) h.pt3dadd(766, -19, -36, 0.9, sec = self.dend[207]) h.pt3dadd(767.5, -18.5, -36, 0.6, sec = self.dend[207]) h.pt3dadd(769, -18.5, -36, 1.6, sec = self.dend[207]) h.pt3dadd(770.5, -18.5, -36, 2.1, sec = self.dend[207]) h.pt3dadd(771.5, -18.5, -36, 2.8, sec = self.dend[207]) h.pt3dadd(773, -18.5, -36, 1.8, sec = self.dend[207]) h.pt3dadd(774.5, -18.5, -36, 1.1, sec = self.dend[207]) h.pt3dadd(775, -18, -36, 1, sec = self.dend[207]) h.pt3dadd(776.5, -18, -36, 1, sec = self.dend[207]) h.pt3dadd(777.5, -17.5, -30, 1.5, sec = self.dend[207]) h.pt3dadd(779.5, -16.5, -30, 2.3, sec = self.dend[207]) h.pt3dadd(782, -16.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(783, -16.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(783, -15.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(784.5, -15.5, -30, 0.5, sec = self.dend[207]) h.pt3dadd(786, -15.5, -30, 1.4, sec = self.dend[207]) h.pt3dadd(787.5, -15.5, -36, 2, sec = self.dend[207]) h.pt3dadd(790, -15.5, -36, 0.9, sec = self.dend[207]) h.pt3dadd(792, -15.5, -36, 1, sec = self.dend[207]) h.pt3dadd(795, -15.5, -36, 1.1, sec = self.dend[207]) h.pt3dadd(797, -15.5, -36, 1.3, sec = self.dend[207]) h.pt3dadd(799.5, -15.5, -36, 2.1, sec = self.dend[207]) h.pt3dadd(801, -16, -36, 2.3, sec = self.dend[207]) h.pt3dadd(802.5, -16, -36, 2.1, sec = self.dend[207]) h.pt3dadd(806, -15, -36, 1.3, sec = self.dend[207]) h.pt3dadd(807.5, -14.5, -36, 1.3, sec = self.dend[207]) h.pt3dadd(809, -13, -36, 0.9, sec = self.dend[207]) h.pt3dadd(810.5, -13, -36, 1.4, sec = self.dend[207]) h.pt3dadd(812.5, -11.5, -30, 2, sec = self.dend[207]) h.pt3dadd(814.5, -11, -36, 3.2, sec = self.dend[207]) h.pt3dadd(816, -11, -36, 2.2, sec = self.dend[207]) h.pt3dadd(819, -10.5, -36, 1.5, sec = self.dend[207]) h.pt3dadd(821, -9.5, -36, 0.7, sec = self.dend[207]) h.pt3dadd(823, -8.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(824.5, -9, -36, 1.3, sec = self.dend[207]) h.pt3dadd(825, -10, -36, 3.3, sec = self.dend[207]) h.pt3dadd(827, -11, -30, 1.3, sec = self.dend[207]) h.pt3dadd(828, -12, -30, 1.3, sec = self.dend[207]) h.pt3dadd(829.5, -12, -30, 2.2, sec = self.dend[207]) h.pt3dadd(831.5, -13.5, -30, 3.5, sec = self.dend[207]) h.pt3dadd(832, -14.5, -30, 2.1, sec = self.dend[207]) h.pt3dadd(833, -15, -30, 1.3, sec = self.dend[207]) h.pt3dadd(833.5, -16.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(833.5, -18, -30, 0.5, sec = self.dend[207]) h.pt3dadd(833.5, -19.5, -30, 0.5, sec = self.dend[207]) h.pt3dadd(833.5, -21, -30, 1.9, sec = self.dend[207]) h.pt3dadd(833.5, -23.5, -30, 0.6, sec = self.dend[207]) h.pt3dadd(833, -26, -30, 0.6, sec = self.dend[207]) h.pt3dadd(832.5, -26, -30, 0.6, sec = self.dend[207]) h.pt3dadd(832, -27.5, -30, 0.6, sec = self.dend[207]) h.pt3dadd(833.5, -27.5, -30, 1.6, sec = self.dend[207]) h.pt3dadd(833.5, -28.5, -30, 2.7, sec = self.dend[207]) h.pt3dadd(834.5, -29.5, -30, 1, sec = self.dend[207]) h.pt3dadd(835.5, -30, -30, 0.4, sec = self.dend[207]) h.pt3dadd(837.5, -30, -30, 1.6, sec = self.dend[207]) h.pt3dadd(838.5, -30, -30, 2.4, sec = self.dend[207]) h.pt3dadd(839.5, -31.5, -30, 1.6, sec = self.dend[207]) h.pt3dadd(841, -33.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(841.5, -33.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(843.5, -34.5, -30, 1.1, sec = self.dend[207]) h.pt3dadd(845, -34.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(848, -35.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(849.5, -35.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(851.5, -35.5, -30, 1.1, sec = self.dend[207]) h.pt3dadd(854, -36.5, -30, 1.6, sec = self.dend[207]) h.pt3dadd(855, -38, -30, 1, sec = self.dend[207]) h.pt3dadd(856.5, -40, -30, 0.8, sec = self.dend[207]) h.pt3dadd(857, -41.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(858, -42, -30, 0.7, sec = self.dend[207]) h.pt3dadd(858.5, -43, -30, 0.7, sec = self.dend[207]) h.pt3dadd(858.5, -44, -23.5, 1.2, sec = self.dend[207]) h.pt3dadd(859.5, -46, -30, 2.2, sec = self.dend[207]) h.pt3dadd(860, -47.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(860.5, -47.5, -30, 0.6, sec = self.dend[207]) h.pt3dadd(864.5, -49.5, -30, 0.6, sec = self.dend[207]) h.pt3dadd(867, -49.5, -30, 0.8, sec = self.dend[207]) h.pt3dadd(869.5, -50, -30, 1.4, sec = self.dend[207]) h.pt3dadd(871.5, -50, -30, 1.7, sec = self.dend[207]) h.pt3dadd(873.5, -50, -30, 2.4, sec = self.dend[207]) h.pt3dadd(874.5, -50, -30, 3.3, sec = self.dend[207]) h.pt3dadd(878, -49.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(879, -49.5, -30, 1, sec = self.dend[207]) h.pt3dadd(881.5, -49.5, -30, 2.2, sec = self.dend[207]) h.pt3dadd(883, -50, -30, 0.9, sec = self.dend[207]) h.pt3dadd(884, -51.5, -30, 0.6, sec = self.dend[207]) h.pt3dadd(885, -51.5, -30, 0.5, sec = self.dend[207]) h.pt3dadd(887.5, -51.5, -30, 0.5, sec = self.dend[207]) h.pt3dadd(889, -51.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(890.5, -51.5, -30, 2.3, sec = self.dend[207]) h.pt3dadd(892.5, -51.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(894, -51.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(895.5, -51.5, -30, 0.8, sec = self.dend[207]) h.pt3dadd(898, -52, -30, 0.8, sec = self.dend[207]) h.pt3dadd(900, -52, -30, 0.8, sec = self.dend[207]) h.pt3dadd(902.5, -52.5, -30, 1.3, sec = self.dend[207]) h.pt3dadd(904.5, -53.5, -23.5, 1.9, sec = self.dend[207]) h.pt3dadd(906.5, -55.5, -30, 1.1, sec = self.dend[207]) h.pt3dadd(908.5, -54.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(911.5, -54.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(915, -54.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(918, -53.5, -23.5, 0.9, sec = self.dend[207]) h.pt3dadd(919.5, -53.5, -23.5, 2.4, sec = self.dend[207]) h.pt3dadd(921, -53.5, -23.5, 0.8, sec = self.dend[207]) h.pt3dadd(923.5, -53.5, -23.5, 0.1, sec = self.dend[207]) h.pt3dadd(925, -53.5, -23.5, 0.9, sec = self.dend[207]) h.pt3dadd(925.5, -53.5, -23.5, 1.6, sec = self.dend[207]) h.pt3dadd(927, -53.5, -23.5, 2.4, sec = self.dend[207]) h.pt3dadd(929, -53.5, -23.5, 1.1, sec = self.dend[207]) h.pt3dadd(929.5, -53.5, -23.5, 0.4, sec = self.dend[207]) h.pt3dadd(932, -53.5, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(933.5, -53.5, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(935, -55.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(937, -57, -30, 0.4, sec = self.dend[207]) h.pt3dadd(938, -57, -30, 0.8, sec = self.dend[207]) h.pt3dadd(940.5, -57, -30, 0.7, sec = self.dend[207]) h.pt3dadd(942, -57.5, -30, 1.5, sec = self.dend[207]) h.pt3dadd(944, -57.5, -30, 2.7, sec = self.dend[207]) h.pt3dadd(945.5, -57.5, -30, 1, sec = self.dend[207]) h.pt3dadd(946, -57.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(948, -58.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(950, -60.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(950.5, -59.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(953, -59.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(954.5, -59.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(957, -59.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(958, -60, -30, 0.1, sec = self.dend[207]) h.pt3dadd(960, -60, -30, 0.1, sec = self.dend[207]) h.pt3dadd(963, -60, -30, 0.1, sec = self.dend[207]) h.pt3dadd(964.5, -58.5, -30, 0.1, sec = self.dend[207]) h.pt3dadd(966, -57.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(967, -57, -36, 0.7, sec = self.dend[207]) h.pt3dadd(968, -56, -30, 0.7, sec = self.dend[207]) h.pt3dadd(970, -56, -30, 0.2, sec = self.dend[207]) h.pt3dadd(972.5, -56, -36, 0.2, sec = self.dend[207]) h.pt3dadd(972.5, -55.5, -30, 0.8, sec = self.dend[207]) h.pt3dadd(973.5, -54, -36, 1.3, sec = self.dend[207]) h.pt3dadd(976.5, -54, -36, 0.8, sec = self.dend[207]) h.pt3dadd(977.5, -54, -36, 0.2, sec = self.dend[207]) h.pt3dadd(979.5, -53, -30, 0.2, sec = self.dend[207]) h.pt3dadd(981.5, -52, -36, 0.8, sec = self.dend[207]) h.pt3dadd(983.5, -51, -30, 1.8, sec = self.dend[207]) h.pt3dadd(985.5, -51, -36, 1.5, sec = self.dend[207]) h.pt3dadd(986.5, -51, -36, 0.9, sec = self.dend[207]) h.pt3dadd(987.5, -51, -36, 0.6, sec = self.dend[207]) h.pt3dadd(989, -51.5, -36, 0.6, sec = self.dend[207]) h.pt3dadd(992.5, -51.5, -36, 0.6, sec = self.dend[207]) h.pt3dadd(996, -52, -36, 0.1, sec = self.dend[207]) h.pt3dadd(998, -52, -36, 0.1, sec = self.dend[207]) h.pt3dadd(999.5, -52, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1000.5, -51.5, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1002, -50.5, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1005, -50.5, -36, 0.9, sec = self.dend[207]) h.pt3dadd(1006.5, -50.5, -36, 1.2, sec = self.dend[207]) h.pt3dadd(1007.5, -50, -36, 0.7, sec = self.dend[207]) h.pt3dadd(1009.5, -48.5, -42.5, 1, sec = self.dend[207]) h.pt3dadd(1011, -48.5, -42.5, 1.2, sec = self.dend[207]) h.pt3dadd(1013.5, -48.5, -42.5, 1.2, sec = self.dend[207]) h.pt3dadd(1015.5, -49, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1018.5, -49, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1020, -47.5, -42.5, 1.2, sec = self.dend[207]) h.pt3dadd(1021.5, -46, -42.5, 2, sec = self.dend[207]) h.pt3dadd(1024.5, -46, -42.5, 0.4, sec = self.dend[207]) h.pt3dadd(1026.5, -47, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1029.5, -47.5, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1030, -48.5, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1031.5, -46.5, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1033, -49, -48.5, 0.3, sec = self.dend[207]) h.pt3dadd(1035, -51, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1037.5, -51, -42.5, 0.8, sec = self.dend[207]) h.pt3dadd(1039.5, -51, -42.5, 0.8, sec = self.dend[207]) h.pt3dadd(1040, -51, -42.5, 0.1, sec = self.dend[207]) h.pt3dadd(1042, -52.5, -42.5, 0.1, sec = self.dend[207]) h.pt3dadd(1043.5, -53.5, -42.5, 1.1, sec = self.dend[207]) h.pt3dadd(1045, -53.5, -42.5, 1.4, sec = self.dend[207]) h.pt3dadd(1046, -53.5, -42.5, 0.7, sec = self.dend[207]) h.pt3dadd(1046, -55.5, -42.5, 0.7, sec = self.dend[207]) h.pt3dadd(1048, -55.5, -42.5, 0.3, sec = self.dend[207]) h.pt3dadd(1048, -54.5, -36, 0.3, sec = self.dend[207]) h.pt3dadd(1047.5, -52, -30, 1.9, sec = self.dend[207]) h.pt3dadd(1048.5, -52, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1049.5, -51, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1051, -50, -36, 0.6, sec = self.dend[207]) h.pt3dadd(1052, -48.5, -30, 1.4, sec = self.dend[207]) h.pt3dadd(1053.5, -50, -36, 0.9, sec = self.dend[207]) h.pt3dadd(1055, -50.5, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1056, -50.5, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1056, -49, -36, 0.1, sec = self.dend[207]) h.pt3dadd(1055.5, -48.5, -30, 0.4, sec = self.dend[207]) h.pt3dadd(1055.5, -47.5, -30, 0.9, sec = self.dend[207]) h.pt3dadd(1056, -47, -30, 2, sec = self.dend[207]) h.pt3dadd(1056.5, -47.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(1058, -47.5, -30, 0.7, sec = self.dend[207]) h.pt3dadd(1058.5, -48.5, -30, 1, sec = self.dend[207]) h.pt3dadd(1060.5, -48.5, -30, 1.5, sec = self.dend[207]) h.pt3dadd(1062.5, -49, -30, 2.2, sec = self.dend[207]) h.pt3dadd(1064.5, -48.5, -30, 0.8, sec = self.dend[207]) h.pt3dadd(1066, -50, -30, 0.1, sec = self.dend[207]) h.pt3dadd(1067.5, -50, -23.5, 0.3, sec = self.dend[207]) h.pt3dadd(1070, -50, -23.5, 0.3, sec = self.dend[207]) h.pt3dadd(1071, -50.5, -30, 0.3, sec = self.dend[207]) h.pt3dadd(1073.5, -49.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1077, -49, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1080, -47, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1082, -44, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1084.5, -43.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1088.5, -42.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1090.5, -42.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1092, -42.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1094.5, -41, -30, 1.1, sec = self.dend[207]) h.pt3dadd(1095.5, -41, -30, 1.5, sec = self.dend[207]) h.pt3dadd(1096.5, -41.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(1098, -41.5, -30, 0.1, sec = self.dend[207]) h.pt3dadd(1101.5, -41.5, -30, 0.1, sec = self.dend[207]) h.pt3dadd(1102.5, -41.5, -30, 1.2, sec = self.dend[207]) h.pt3dadd(1104.5, -41.5, -30, 0.2, sec = self.dend[207]) h.pt3dadd(1105.5, -42.5, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(1107.5, -42.5, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(1110, -42.5, -23.5, 1, sec = self.dend[207]) h.pt3dadd(1112, -43, -23.5, 0.4, sec = self.dend[207]) h.pt3dadd(1112.5, -45, -23.5, 0.4, sec = self.dend[207]) h.pt3dadd(1113.5, -46, -23.5, 0.4, sec = self.dend[207]) h.pt3dadd(1115, -46, -23.5, 2.1, sec = self.dend[207]) h.pt3dadd(1116.5, -46.5, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(1118, -46, -23.5, 0.2, sec = self.dend[207]) h.pt3dadd(1119.5, -48, -23.5, 0.1, sec = self.dend[207]) h.pt3dclear(sec = self.dend[208]) h.pt3dadd(305, 78.5, -8.5, 6.1, sec = self.dend[208]) h.pt3dadd(310, 80, -9.5, 2.2, sec = self.dend[208]) h.pt3dadd(313.5, 80, -9.5, 2.3, sec = self.dend[208]) h.pt3dadd(315, 80, -5.5, 2.7, sec = self.dend[208]) h.pt3dadd(316.5, 78, -3, 2.7, sec = self.dend[208]) h.pt3dadd(318, 73.5, -4, 2.7, sec = self.dend[208]) h.pt3dadd(318, 77.5, -5, 1.9, sec = self.dend[208]) h.pt3dadd(320.5, 77.5, -5, 2.9, sec = self.dend[208]) h.pt3dadd(321.5, 77.5, -5, 2.9, sec = self.dend[208]) h.pt3dadd(323.5, 77.5, -5.5, 1.8, sec = self.dend[208]) h.pt3dadd(325.5, 77.5, -5.5, 1.3, sec = self.dend[208]) h.pt3dadd(326, 75.5, -5.5, 1.3, sec = self.dend[208]) h.pt3dadd(327.5, 76, -5.5, 1.7, sec = self.dend[208]) h.pt3dadd(330, 76, -6.5, 1.8, sec = self.dend[208]) h.pt3dadd(330.5, 74.5, -6.5, 1.5, sec = self.dend[208]) h.pt3dadd(335, 74.5, -2, 1.5, sec = self.dend[208]) h.pt3dadd(339.5, 69, 0.5, 1.4, sec = self.dend[208]) h.pt3dadd(341.5, 69, 0.5, 1.7, sec = self.dend[208]) h.pt3dadd(344, 69, 0.5, 1.5, sec = self.dend[208]) h.pt3dadd(345.5, 68.5, 0.5, 1.4, sec = self.dend[208]) h.pt3dadd(348.5, 69.5, 0.5, 0.9, sec = self.dend[208]) h.pt3dadd(350, 69.5, 3.5, 1.1, sec = self.dend[208]) h.pt3dadd(352.5, 69.5, 3.5, 1.2, sec = self.dend[208]) h.pt3dadd(353.5, 69.5, 3.5, 2.3, sec = self.dend[208]) h.pt3dadd(356, 69.5, 3.5, 2.9, sec = self.dend[208]) h.pt3dadd(357, 69, 0.5, 3.1, sec = self.dend[208]) h.pt3dadd(360, 68, -2, 2.2, sec = self.dend[208]) h.pt3dadd(361, 68, 6, 2.2, sec = self.dend[208]) h.pt3dadd(363.5, 68, 9, 1.1, sec = self.dend[208]) h.pt3dadd(364.5, 67.5, 9, 0.8, sec = self.dend[208]) h.pt3dadd(366.5, 67.5, 9, 1.6, sec = self.dend[208]) h.pt3dadd(368.5, 67.5, 9, 2.4, sec = self.dend[208]) h.pt3dadd(370.5, 68, 9, 2.7, sec = self.dend[208]) h.pt3dadd(373, 68, 9, 2.7, sec = self.dend[208]) h.pt3dadd(374.5, 67, 9, 2.3, sec = self.dend[208]) h.pt3dadd(377, 64.5, 9, 2.4, sec = self.dend[208]) h.pt3dadd(379, 63, 9, 3.2, sec = self.dend[208]) h.pt3dadd(381.5, 62.5, 17.5, 2, sec = self.dend[208]) h.pt3dadd(384, 62.5, 17.5, 1.5, sec = self.dend[208]) h.pt3dadd(387, 62.5, 11.5, 1.8, sec = self.dend[208]) h.pt3dadd(390.5, 62.5, 11.5, 2, sec = self.dend[208]) h.pt3dadd(392.5, 61.5, 20, 2, sec = self.dend[208]) h.pt3dadd(394.5, 59, 25.5, 2.1, sec = self.dend[208]) h.pt3dadd(397, 58.5, 25.5, 1.6, sec = self.dend[208]) h.pt3dadd(399.5, 57, 25.5, 1.8, sec = self.dend[208]) h.pt3dadd(402, 56, 25.5, 2.1, sec = self.dend[208]) h.pt3dadd(404.5, 55, 20, 2.1, sec = self.dend[208]) h.pt3dadd(406.5, 54, 20, 0.9, sec = self.dend[208]) h.pt3dadd(409.5, 54, 18.5, 2.2, sec = self.dend[208]) h.pt3dadd(410.5, 51.5, 20, 0.6, sec = self.dend[208]) h.pt3dadd(413.5, 51.5, 18.5, 0.6, sec = self.dend[208]) h.pt3dadd(415, 51.5, 18.5, 1.5, sec = self.dend[208]) h.pt3dadd(417, 50.5, 18.5, 2.5, sec = self.dend[208]) h.pt3dadd(419, 50, 18.5, 1.8, sec = self.dend[208]) h.pt3dadd(420.5, 50, 18.5, 0.9, sec = self.dend[208]) h.pt3dadd(422, 50, 18.5, 0.9, sec = self.dend[208]) h.pt3dadd(423.5, 50, 17.5, 1.6, sec = self.dend[208]) h.pt3dadd(425, 50, 17.5, 2.5, sec = self.dend[208]) h.pt3dadd(426, 50, 17.5, 1.4, sec = self.dend[208]) h.pt3dadd(429.5, 49.5, 17.5, 1, sec = self.dend[208]) h.pt3dadd(431, 49.5, 17.5, 2.1, sec = self.dend[208]) h.pt3dadd(433, 49.5, 17.5, 3.8, sec = self.dend[208]) h.pt3dadd(434, 49.5, 17.5, 1.5, sec = self.dend[208]) h.pt3dadd(435, 50, 21.5, 1.2, sec = self.dend[208]) h.pt3dadd(436, 50, 21.5, 1.2, sec = self.dend[208]) h.pt3dadd(437.5, 50, 21.5, 1.2, sec = self.dend[208]) h.pt3dadd(438.5, 49.5, 21.5, 2, sec = self.dend[208]) h.pt3dadd(439.5, 49, 21.5, 2.8, sec = self.dend[208]) h.pt3dadd(440.5, 46.5, 21.5, 2.8, sec = self.dend[208]) h.pt3dadd(442, 46.5, 20, 2.5, sec = self.dend[208]) h.pt3dadd(443.5, 45, 24.5, 1.5, sec = self.dend[208]) h.pt3dadd(445.5, 43, 23, 1.1, sec = self.dend[208]) h.pt3dadd(446.5, 43, 23, 1.2, sec = self.dend[208]) h.pt3dadd(449, 42, 23, 1.6, sec = self.dend[208]) h.pt3dadd(451, 41.5, 23, 1.8, sec = self.dend[208]) h.pt3dadd(454, 40.5, 23, 2.8, sec = self.dend[208]) h.pt3dadd(457, 40, 23, 3.3, sec = self.dend[208]) h.pt3dadd(458, 38, 26, 2.1, sec = self.dend[208]) h.pt3dadd(459.5, 36.5, 23, 1.6, sec = self.dend[208]) h.pt3dadd(459.5, 36, 23, 0.9, sec = self.dend[208]) h.pt3dadd(462.5, 33.5, 23, 1.6, sec = self.dend[208]) h.pt3dadd(462.5, 32.5, 23, 1.6, sec = self.dend[208]) h.pt3dadd(463.5, 31, 23, 1.6, sec = self.dend[208]) h.pt3dadd(466, 29.5, 23, 1.6, sec = self.dend[208]) h.pt3dadd(466, 27.5, 23, 2.4, sec = self.dend[208]) h.pt3dadd(467.5, 25.5, 21.5, 1.9, sec = self.dend[208]) h.pt3dadd(468, 24, 21.5, 1.1, sec = self.dend[208]) h.pt3dadd(470.5, 24, 21.5, 1.1, sec = self.dend[208]) h.pt3dadd(472, 24, 21.5, 2.4, sec = self.dend[208]) h.pt3dadd(473, 23.5, 20, 2.5, sec = self.dend[208]) h.pt3dadd(474.5, 22, 20, 2.5, sec = self.dend[208]) h.pt3dadd(476, 20, 20, 2.5, sec = self.dend[208]) h.pt3dadd(476, 19, 20, 2.4, sec = self.dend[208]) h.pt3dadd(478, 17.5, 21.5, 0.9, sec = self.dend[208]) h.pt3dadd(481, 16.5, 23, 0.9, sec = self.dend[208]) h.pt3dadd(482.5, 15, 23, 0.9, sec = self.dend[208]) h.pt3dadd(484, 14.5, 21.5, 1.6, sec = self.dend[208]) h.pt3dadd(485, 12.5, 21.5, 2.5, sec = self.dend[208]) h.pt3dadd(487, 10, 20, 1.7, sec = self.dend[208]) h.pt3dadd(489.5, 8.5, 20, 1.4, sec = self.dend[208]) h.pt3dadd(492, 6.5, 18.5, 0.7, sec = self.dend[208]) h.pt3dadd(494.5, 3.5, 21.5, 0.9, sec = self.dend[208]) h.pt3dadd(498, 3.5, 20, 0.7, sec = self.dend[208]) h.pt3dadd(500.5, 2.5, 18.5, 0.8, sec = self.dend[208]) h.pt3dadd(502.5, 2, 18.5, 0.9, sec = self.dend[208]) h.pt3dadd(504, 0, 30, 0.7, sec = self.dend[208]) h.pt3dadd(507, 0, 30, 0.5, sec = self.dend[208]) h.pt3dadd(510.5, -0.5, 30, 0.5, sec = self.dend[208]) h.pt3dadd(510.5, -2, 30, 0.6, sec = self.dend[208]) h.pt3dadd(516, -2, 28.5, 0.9, sec = self.dend[208]) h.pt3dadd(518.5, -0.5, 30, 0.9, sec = self.dend[208]) h.pt3dadd(520, -2, 30, 0.8, sec = self.dend[208]) h.pt3dadd(524.5, -4.5, 30, 0.7, sec = self.dend[208]) h.pt3dadd(524.5, -5.5, 28.5, 0.7, sec = self.dend[208]) h.pt3dadd(527, -5.5, 28.5, 1.6, sec = self.dend[208]) h.pt3dadd(530, -8, 28.5, 0.6, sec = self.dend[208]) h.pt3dadd(532, -9, 28.5, 0.6, sec = self.dend[208]) h.pt3dadd(535, -11, 28.5, 1.4, sec = self.dend[208]) h.pt3dadd(536.5, -11, 27.5, 0.6, sec = self.dend[208]) h.pt3dadd(541, -11, 27.5, 0.6, sec = self.dend[208]) h.pt3dadd(545, -12, 27.5, 1.7, sec = self.dend[208]) h.pt3dadd(547.5, -12.5, 24.5, 0.7, sec = self.dend[208]) h.pt3dadd(549.5, -15.5, 26, 0.7, sec = self.dend[208]) h.pt3dadd(554, -15.5, 24.5, 0.7, sec = self.dend[208]) h.pt3dadd(556, -15.5, 24.5, 0.7, sec = self.dend[208]) h.pt3dadd(558, -15.5, 24.5, 2, sec = self.dend[208]) h.pt3dadd(559.5, -15, 24.5, 2.7, sec = self.dend[208]) h.pt3dadd(561, -13, 26, 1.9, sec = self.dend[208]) h.pt3dadd(562, -12.5, 26, 1, sec = self.dend[208]) h.pt3dadd(562.5, -12, 26, 0.8, sec = self.dend[208]) h.pt3dadd(563, -10, 28.5, 0.8, sec = self.dend[208]) h.pt3dadd(564.5, -7, 30, 0.8, sec = self.dend[208]) h.pt3dadd(566.5, -4, 31.5, 1.1, sec = self.dend[208]) h.pt3dadd(568.5, -4, 31.5, 1.1, sec = self.dend[208]) h.pt3dadd(571, -3, 31.5, 1.8, sec = self.dend[208]) h.pt3dadd(572.5, -1, 31.5, 2.8, sec = self.dend[208]) h.pt3dadd(574, 1, 31.5, 4.6, sec = self.dend[208]) h.pt3dadd(577, 2, 31.5, 1.3, sec = self.dend[208]) h.pt3dadd(578, 4.5, 31.5, 0.8, sec = self.dend[208]) h.pt3dadd(580.5, 6.5, 31.5, 1.1, sec = self.dend[208]) h.pt3dadd(582, 7, 31.5, 2.1, sec = self.dend[208]) h.pt3dadd(582.5, 9.5, 31.5, 2.7, sec = self.dend[208]) h.pt3dadd(584.5, 11, 31.5, 1.3, sec = self.dend[208]) h.pt3dadd(586.5, 11.5, 28.5, 0.9, sec = self.dend[208]) h.pt3dadd(590, 13.5, 30, 0.9, sec = self.dend[208]) h.pt3dadd(590.5, 14, 30, 1.7, sec = self.dend[208]) h.pt3dadd(592.5, 14.5, 30, 2.7, sec = self.dend[208]) h.pt3dadd(593.5, 16.5, 30, 1.4, sec = self.dend[208]) h.pt3dadd(594.5, 17.5, 28.5, 0.8, sec = self.dend[208]) h.pt3dadd(598, 19.5, 28.5, 0.8, sec = self.dend[208]) h.pt3dadd(598.5, 19.5, 28.5, 1.7, sec = self.dend[208]) h.pt3dadd(601, 21, 28.5, 0.9, sec = self.dend[208]) h.pt3dadd(602, 22.5, 28.5, 0.9, sec = self.dend[208]) h.pt3dadd(603.5, 23, 28.5, 0.9, sec = self.dend[208]) h.pt3dadd(606, 25, 30, 1.9, sec = self.dend[208]) h.pt3dadd(607, 25.5, 30, 2.6, sec = self.dend[208]) h.pt3dadd(609, 27, 30, 1.5, sec = self.dend[208]) h.pt3dadd(610.5, 27, 30, 1.4, sec = self.dend[208]) h.pt3dadd(613, 28, 30, 1.4, sec = self.dend[208]) h.pt3dadd(614, 30.5, 31.5, 2.3, sec = self.dend[208]) h.pt3dadd(616, 33, 31.5, 1.5, sec = self.dend[208]) h.pt3dadd(617.5, 34.5, 31.5, 1, sec = self.dend[208]) h.pt3dadd(620, 35, 31.5, 0.8, sec = self.dend[208]) h.pt3dadd(622, 36, 31.5, 0.8, sec = self.dend[208]) h.pt3dadd(624, 36.5, 31.5, 2.2, sec = self.dend[208]) h.pt3dadd(626, 37.5, 31.5, 4.3, sec = self.dend[208]) h.pt3dadd(628, 40.5, 31.5, 1.3, sec = self.dend[208]) h.pt3dadd(630, 40.5, 30, 0.3, sec = self.dend[208]) h.pt3dadd(635.5, 40.5, 30, 0.3, sec = self.dend[208]) h.pt3dadd(638.5, 40.5, 30, 0.3, sec = self.dend[208]) h.pt3dadd(643, 44, 30, 0.3, sec = self.dend[208]) h.pt3dadd(645.5, 44, 30, 0.3, sec = self.dend[208]) h.pt3dadd(647.5, 44.5, 31.5, 0.7, sec = self.dend[208]) h.pt3dadd(649, 44.5, 31.5, 0.7, sec = self.dend[208]) h.pt3dadd(651, 45, 31.5, 0.7, sec = self.dend[208]) h.pt3dadd(653, 45.5, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(653, 47.5, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(655.5, 47.5, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(658.5, 49.5, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(662, 50, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(664, 50.5, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(666.5, 53, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(668.5, 53, 31.5, 0.9, sec = self.dend[208]) h.pt3dadd(670.5, 54, 30, 0.1, sec = self.dend[208]) h.pt3dadd(674, 54, 30, 0.1, sec = self.dend[208]) h.pt3dadd(679, 55.5, 28.5, 0.1, sec = self.dend[208]) h.pt3dadd(681.5, 56, 31.5, 1.6, sec = self.dend[208]) h.pt3dadd(684.5, 56, 31.5, 0.2, sec = self.dend[208]) h.pt3dadd(687.5, 58, 31.5, 0.2, sec = self.dend[208]) h.pt3dadd(689.5, 58, 31.5, 0.2, sec = self.dend[208]) h.pt3dadd(690.5, 58, 31.5, 1.3, sec = self.dend[208]) h.pt3dadd(694, 58, 31.5, 0.2, sec = self.dend[208]) h.pt3dadd(696.5, 59, 31.5, 0.2, sec = self.dend[208]) h.pt3dadd(697, 61, 36, 2.8, sec = self.dend[208]) h.pt3dadd(700, 63.5, 33, 0.9, sec = self.dend[208]) h.pt3dadd(701, 64, 33, 0.9, sec = self.dend[208]) h.pt3dadd(703, 65.5, 34.5, 0.9, sec = self.dend[208]) h.pt3dadd(703, 66, 37.5, 3.2, sec = self.dend[208]) h.pt3dadd(702.5, 70, 37.5, 1.4, sec = self.dend[208]) h.pt3dadd(702, 72, 37.5, 1, sec = self.dend[208]) h.pt3dadd(699, 72, 37.5, 1.4, sec = self.dend[208]) h.pt3dadd(697, 72, 38.5, 1.4, sec = self.dend[208]) h.pt3dadd(694.5, 72.5, 43, 0.9, sec = self.dend[208]) h.pt3dadd(693, 72.5, 44.5, 1.4, sec = self.dend[208]) h.pt3dadd(691.5, 72.5, 44.5, 2.1, sec = self.dend[208]) h.pt3dadd(688.5, 73, 47.5, 1.1, sec = self.dend[208]) h.pt3dadd(687.5, 73, 47.5, 1.1, sec = self.dend[208]) h.pt3dadd(684.5, 76.5, 44, 0.8, sec = self.dend[208]) h.pt3dadd(681, 77, 44, 0.8, sec = self.dend[208]) h.pt3dadd(678.5, 79.5, 44, 0.8, sec = self.dend[208]) h.pt3dadd(678.5, 80.5, 44, 0.8, sec = self.dend[208]) h.pt3dadd(677.5, 82, 51, 1.1, sec = self.dend[208]) h.pt3dadd(675.5, 82, 51, 1.2, sec = self.dend[208]) h.pt3dadd(673, 82, 53, 0.6, sec = self.dend[208]) h.pt3dadd(672, 83, 53, 0.6, sec = self.dend[208]) h.pt3dadd(670, 83, 54.5, 0.6, sec = self.dend[208]) h.pt3dadd(668.5, 83, 56.5, 1.4, sec = self.dend[208]) h.pt3dadd(667.5, 83, 56.5, 0.9, sec = self.dend[208]) h.pt3dadd(667, 85, 58, 0.6, sec = self.dend[208]) h.pt3dadd(666, 86, 58, 0.6, sec = self.dend[208]) h.pt3dadd(665, 88, 54.5, 1, sec = self.dend[208]) h.pt3dadd(663, 88, 56.5, 1.2, sec = self.dend[208]) h.pt3dadd(662, 90, 56.5, 0.7, sec = self.dend[208]) h.pt3dadd(662, 91, 56.5, 0.7, sec = self.dend[208]) h.pt3dadd(661, 92.5, 56.5, 0.7, sec = self.dend[208]) h.pt3dadd(661.5, 94, 56.5, 0.7, sec = self.dend[208]) h.pt3dadd(662, 95, 56.5, 0.7, sec = self.dend[208]) h.pt3dadd(660.5, 96.5, 58, 2, sec = self.dend[208]) h.pt3dadd(658.5, 96.5, 58, 1.2, sec = self.dend[208]) h.pt3dadd(656.5, 98, 59.5, 0.8, sec = self.dend[208]) h.pt3dadd(656.5, 99, 61, 1.4, sec = self.dend[208]) h.pt3dadd(657.5, 99.5, 65.5, 1.2, sec = self.dend[208]) h.pt3dadd(658.5, 101, 65.5, 1.7, sec = self.dend[208]) h.pt3dadd(660, 102.5, 65.5, 1.7, sec = self.dend[208]) h.pt3dadd(661, 103.5, 65.5, 2, sec = self.dend[208]) h.pt3dadd(663.5, 106, 67, 0.1, sec = self.dend[208]) h.pt3dadd(662.5, 107.5, 67, 0.1, sec = self.dend[208]) h.pt3dadd(661, 107.5, 67, 0.1, sec = self.dend[208]) h.pt3dadd(660, 104.5, 68.5, 0.1, sec = self.dend[208]) h.pt3dadd(658, 105.5, 68.5, 0.1, sec = self.dend[208]) h.pt3dadd(656.5, 106, 68.5, 0.1, sec = self.dend[208]) h.pt3dadd(655.5, 106, 70, 1.5, sec = self.dend[208]) h.pt3dadd(653.5, 105.5, 71.5, 2.5, sec = self.dend[208]) h.pt3dadd(652.5, 106, 71.5, 1.3, sec = self.dend[208]) h.pt3dadd(651, 107, 71.5, 0.1, sec = self.dend[208]) h.pt3dadd(649.5, 107, 76, 0.1, sec = self.dend[208]) h.pt3dadd(647, 106, 76, 0.1, sec = self.dend[208]) h.pt3dadd(645, 108, 74.5, 0.1, sec = self.dend[208]) h.pt3dadd(645, 109, 74.5, 0.1, sec = self.dend[208]) h.pt3dadd(643.5, 109.5, 73, 1.7, sec = self.dend[208]) h.pt3dadd(642, 110.5, 74.5, 0.9, sec = self.dend[208]) h.pt3dadd(637, 112, 79, 0.7, sec = self.dend[208]) h.pt3dadd(634.5, 114, 79, 0.7, sec = self.dend[208]) h.pt3dclear(sec = self.dend[209]) h.pt3dadd(267.5, 85.5, -14, 5.8, sec = self.dend[209]) h.pt3dadd(268.5, 90.5, -9.5, 4.1, sec = self.dend[209]) h.pt3dadd(270, 94, -9.5, 4.2, sec = self.dend[209]) h.pt3dadd(273.5, 97.5, -9.5, 3.7, sec = self.dend[209]) h.pt3dadd(276, 98.5, -10, 3.3, sec = self.dend[209]) h.pt3dadd(278.5, 100.5, -9.5, 4.3, sec = self.dend[209]) h.pt3dadd(280, 102.5, -9.5, 3.6, sec = self.dend[209]) h.pt3dadd(282, 104, -9.5, 3.6, sec = self.dend[209]) h.pt3dadd(284.5, 105, -9.5, 3.1, sec = self.dend[209]) h.pt3dadd(289, 105, -7.5, 3.1, sec = self.dend[209]) h.pt3dadd(291.5, 105, -7.5, 4.3, sec = self.dend[209]) h.pt3dadd(293.5, 106, -7.5, 5.3, sec = self.dend[209]) h.pt3dadd(296.5, 106, -8.5, 4.4, sec = self.dend[209]) h.pt3dadd(302, 106.5, -8.5, 4.9, sec = self.dend[209]) h.pt3dadd(306, 108, -6.5, 4.3, sec = self.dend[209]) h.pt3dadd(310, 109, -5, 4.6, sec = self.dend[209]) h.pt3dadd(313, 111, -5, 4.7, sec = self.dend[209]) h.pt3dadd(316.5, 111, -5, 5.6, sec = self.dend[209]) h.pt3dadd(320, 113, -4, 5.6, sec = self.dend[209]) h.pt3dadd(323.5, 113.5, -4, 4.6, sec = self.dend[209]) h.pt3dadd(328, 114, -4, 4.6, sec = self.dend[209]) h.pt3dadd(331.5, 117, -4, 4.6, sec = self.dend[209]) h.pt3dadd(336.5, 118, -7, 1.9, sec = self.dend[209]) h.pt3dadd(340, 119, -7, 2.5, sec = self.dend[209]) h.pt3dadd(342.5, 120.5, -4, 2.5, sec = self.dend[209]) h.pt3dadd(347, 122.5, 4, 2.5, sec = self.dend[209]) h.pt3dadd(350, 122.5, 4, 2.5, sec = self.dend[209]) h.pt3dadd(353.5, 123, -1.5, 2.2, sec = self.dend[209]) h.pt3dadd(356, 124.5, -1.5, 2.2, sec = self.dend[209]) h.pt3dadd(359, 124.5, -1.5, 2.2, sec = self.dend[209]) h.pt3dadd(361, 124.5, 1.5, 2.8, sec = self.dend[209]) h.pt3dadd(364.5, 126, 1.5, 2.8, sec = self.dend[209]) h.pt3dadd(367, 128.5, 1.5, 4.3, sec = self.dend[209]) h.pt3dadd(371, 129.5, 1.5, 4.3, sec = self.dend[209]) h.pt3dadd(375.5, 131, 1.5, 3.8, sec = self.dend[209]) h.pt3dadd(377.5, 131.5, 1.5, 3.1, sec = self.dend[209]) h.pt3dadd(379, 132.5, 4, 4.4, sec = self.dend[209]) h.pt3dadd(383, 132.5, 7, 3.2, sec = self.dend[209]) h.pt3dadd(387, 132.5, 7, 2.1, sec = self.dend[209]) h.pt3dadd(391, 132.5, 10, 1.9, sec = self.dend[209]) h.pt3dadd(394, 132.5, 10, 2.7, sec = self.dend[209]) h.pt3dadd(396.5, 133, 4, 3.8, sec = self.dend[209]) h.pt3dadd(400.5, 133, 4, 3.8, sec = self.dend[209]) h.pt3dadd(402.5, 133, 4, 3.8, sec = self.dend[209]) h.pt3dadd(406.5, 134.5, 4, 3.8, sec = self.dend[209]) h.pt3dclear(sec = self.dend[210]) h.pt3dadd(406.5, 134.5, 4, 3.8, sec = self.dend[210]) h.pt3dadd(409, 132.5, 4, 2.4, sec = self.dend[210]) h.pt3dadd(414.5, 131, 4, 2.4, sec = self.dend[210]) h.pt3dadd(420, 131, 1.5, 2.4, sec = self.dend[210]) h.pt3dadd(423.5, 129.5, 1.5, 2.4, sec = self.dend[210]) h.pt3dadd(425.5, 129.5, -1.5, 2.4, sec = self.dend[210]) h.pt3dadd(429.5, 128, -4, 2.7, sec = self.dend[210]) h.pt3dadd(431.5, 128, -4, 1.4, sec = self.dend[210]) h.pt3dadd(433, 128, -4, 1.3, sec = self.dend[210]) h.pt3dadd(434.5, 126, -7, 1.8, sec = self.dend[210]) h.pt3dadd(436, 125, -7, 2.1, sec = self.dend[210]) h.pt3dadd(438.5, 125, -9.5, 1, sec = self.dend[210]) h.pt3dadd(441, 123.5, -9.5, 0.9, sec = self.dend[210]) h.pt3dadd(442.5, 122, -9.5, 0.9, sec = self.dend[210]) h.pt3dadd(445, 120.5, -15, 0.9, sec = self.dend[210]) h.pt3dadd(450.5, 118, -15.5, 4, sec = self.dend[210]) h.pt3dadd(455, 116, -15.5, 4, sec = self.dend[210]) h.pt3dadd(457.5, 115, -15.5, 3.6, sec = self.dend[210]) h.pt3dadd(460.5, 115, -16.5, 3.8, sec = self.dend[210]) h.pt3dadd(465.5, 115.5, -16.5, 2.9, sec = self.dend[210]) h.pt3dadd(468, 115.5, -15.5, 2.9, sec = self.dend[210]) h.pt3dadd(471, 115.5, -15.5, 3.3, sec = self.dend[210]) h.pt3dadd(474, 113.5, -15.5, 3.7, sec = self.dend[210]) h.pt3dadd(476.5, 113, -16.5, 2.4, sec = self.dend[210]) h.pt3dadd(479.5, 113, -16.5, 2.1, sec = self.dend[210]) h.pt3dadd(483, 113, -15.5, 2.1, sec = self.dend[210]) h.pt3dadd(487, 113, -16.5, 3.3, sec = self.dend[210]) h.pt3dadd(489.5, 115, -16.5, 3.7, sec = self.dend[210]) h.pt3dadd(492.5, 115, -16.5, 3.7, sec = self.dend[210]) h.pt3dadd(495.5, 116, -16.5, 3.6, sec = self.dend[210]) h.pt3dadd(499.5, 115, -17.5, 3.9, sec = self.dend[210]) h.pt3dadd(504, 114, -18.5, 4.1, sec = self.dend[210]) h.pt3dadd(507.5, 113.5, -15.5, 2.8, sec = self.dend[210]) h.pt3dadd(511.5, 113.5, -14, 2.8, sec = self.dend[210]) h.pt3dadd(514.5, 113.5, -12, 2.9, sec = self.dend[210]) h.pt3dadd(517.5, 113, -11, 3.7, sec = self.dend[210]) h.pt3dadd(521.5, 113, -11, 4.4, sec = self.dend[210]) h.pt3dadd(525, 113, -12, 3.8, sec = self.dend[210]) h.pt3dadd(530, 114, -9, 2.7, sec = self.dend[210]) h.pt3dadd(532.5, 114, -10, 2.7, sec = self.dend[210]) h.pt3dadd(535, 113.5, -10, 3.4, sec = self.dend[210]) h.pt3dadd(539.5, 114, -10, 1.8, sec = self.dend[210]) h.pt3dadd(542, 114, -10, 2.6, sec = self.dend[210]) h.pt3dadd(544, 113.5, -10, 3.4, sec = self.dend[210]) h.pt3dadd(548, 112, -10, 4, sec = self.dend[210]) h.pt3dadd(551.5, 110, -10, 2.9, sec = self.dend[210]) h.pt3dadd(553, 108.5, -10, 2.7, sec = self.dend[210]) h.pt3dadd(557, 108.5, -10, 2.2, sec = self.dend[210]) h.pt3dadd(560, 108.5, -10, 2.2, sec = self.dend[210]) h.pt3dadd(562.5, 108.5, -10, 1.6, sec = self.dend[210]) h.pt3dadd(567, 109.5, -10, 1.6, sec = self.dend[210]) h.pt3dadd(569, 109, -10, 2.5, sec = self.dend[210]) h.pt3dadd(571.5, 108.5, -10, 3.1, sec = self.dend[210]) h.pt3dadd(574.5, 109, -10, 3.7, sec = self.dend[210]) h.pt3dadd(577, 110, -10, 3.1, sec = self.dend[210]) h.pt3dadd(579.5, 110, -10, 2.4, sec = self.dend[210]) h.pt3dadd(582, 110, -10, 2.2, sec = self.dend[210]) h.pt3dadd(585, 110, -10, 3.1, sec = self.dend[210]) h.pt3dadd(587.5, 110, -10, 4, sec = self.dend[210]) h.pt3dadd(591, 110.5, -10, 3, sec = self.dend[210]) h.pt3dadd(593.5, 111, -11, 2.3, sec = self.dend[210]) h.pt3dadd(596.5, 111, -11, 2.5, sec = self.dend[210]) h.pt3dadd(600, 111.5, -11, 3.3, sec = self.dend[210]) h.pt3dadd(605.5, 113, -11, 3.4, sec = self.dend[210]) h.pt3dadd(608, 115, -10, 3.1, sec = self.dend[210]) h.pt3dadd(613.5, 114, -5, 3.6, sec = self.dend[210]) h.pt3dadd(617, 114, -7, 3.1, sec = self.dend[210]) h.pt3dadd(621.5, 114, -12, 3.5, sec = self.dend[210]) h.pt3dadd(626, 115, -17.5, 3.4, sec = self.dend[210]) h.pt3dadd(630, 118.5, -17.5, 3.4, sec = self.dend[210]) h.pt3dadd(630.5, 120, -17.5, 2.9, sec = self.dend[210]) h.pt3dadd(633, 122, -17.5, 2.6, sec = self.dend[210]) h.pt3dadd(635, 125, -17.5, 2.6, sec = self.dend[210]) h.pt3dadd(636.5, 126, -17.5, 1.9, sec = self.dend[210]) h.pt3dadd(639.5, 126, -17.5, 1.9, sec = self.dend[210]) h.pt3dadd(644, 126, -17.5, 2, sec = self.dend[210]) h.pt3dadd(646.5, 125, -17.5, 2.2, sec = self.dend[210]) h.pt3dadd(650, 126, -17.5, 1.9, sec = self.dend[210]) h.pt3dadd(652.5, 129, -17.5, 2.3, sec = self.dend[210]) h.pt3dadd(654, 129, -17.5, 2.7, sec = self.dend[210]) h.pt3dadd(658, 129, -17.5, 2.7, sec = self.dend[210]) h.pt3dadd(661, 131.5, -17.5, 2.4, sec = self.dend[210]) h.pt3dadd(663.5, 133, -18.5, 2.6, sec = self.dend[210]) h.pt3dadd(665.5, 135, -19.5, 3.1, sec = self.dend[210]) h.pt3dadd(667.5, 135.5, -20, 3.7, sec = self.dend[210]) h.pt3dadd(672, 135.5, -20, 3.3, sec = self.dend[210]) h.pt3dadd(674.5, 136, -20, 3.2, sec = self.dend[210]) h.pt3dadd(680, 137, -21, 3.1, sec = self.dend[210]) h.pt3dadd(683.5, 138, -20, 2.6, sec = self.dend[210]) h.pt3dadd(687, 138.5, -20, 1.6, sec = self.dend[210]) h.pt3dadd(689, 139, -20, 1.6, sec = self.dend[210]) h.pt3dadd(691.5, 139, -23.5, 1.7, sec = self.dend[210]) h.pt3dadd(694, 140, -21, 2.2, sec = self.dend[210]) h.pt3dadd(696, 140.5, -21, 2.5, sec = self.dend[210]) h.pt3dadd(698.5, 140.5, -21, 2.6, sec = self.dend[210]) h.pt3dadd(701, 140.5, -21, 2.6, sec = self.dend[210]) h.pt3dadd(702.5, 141.5, -23.5, 1.8, sec = self.dend[210]) h.pt3dadd(704.5, 142, -24.5, 2.4, sec = self.dend[210]) h.pt3dadd(706.5, 142, -23.5, 2.8, sec = self.dend[210]) h.pt3dadd(709.5, 142, -23.5, 2.4, sec = self.dend[210]) h.pt3dadd(711.5, 143, -23.5, 2.6, sec = self.dend[210]) h.pt3dadd(714, 143.5, -23.5, 2.3, sec = self.dend[210]) h.pt3dadd(717, 143.5, -23.5, 2.1, sec = self.dend[210]) h.pt3dadd(720, 144.5, -23.5, 1.6, sec = self.dend[210]) h.pt3dadd(721.5, 144.5, -23.5, 1.2, sec = self.dend[210]) h.pt3dadd(722.5, 146, -22.5, 1.7, sec = self.dend[210]) h.pt3dadd(724, 147, -24.5, 2.5, sec = self.dend[210]) h.pt3dadd(725.5, 148, -24.5, 2, sec = self.dend[210]) h.pt3dadd(726.5, 150, -24.5, 1, sec = self.dend[210]) h.pt3dadd(729, 150, -24.5, 1, sec = self.dend[210]) h.pt3dadd(732, 150, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(735, 150, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(738, 150, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(739.5, 150, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(741, 149, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(743, 149, -24.5, 2.3, sec = self.dend[210]) h.pt3dadd(746, 149, -24.5, 2.4, sec = self.dend[210]) h.pt3dadd(748, 149, -24.5, 2.9, sec = self.dend[210]) h.pt3dadd(750, 149.5, -24.5, 3.7, sec = self.dend[210]) h.pt3dadd(752, 150, -24.5, 4.3, sec = self.dend[210]) h.pt3dadd(754.5, 150.5, -24.5, 4.3, sec = self.dend[210]) h.pt3dadd(757.5, 150.5, -24.5, 3.1, sec = self.dend[210]) h.pt3dadd(759, 150.5, -24.5, 2.5, sec = self.dend[210]) h.pt3dadd(760.5, 150.5, -24.5, 1.9, sec = self.dend[210]) h.pt3dadd(762.5, 150.5, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(764, 150.5, -24.5, 1.4, sec = self.dend[210]) h.pt3dadd(766, 150.5, -24.5, 1.6, sec = self.dend[210]) h.pt3dadd(769, 150.5, -25.5, 4, sec = self.dend[210]) h.pt3dclear(sec = self.dend[211]) h.pt3dadd(769, 150.5, -25.5, 4, sec = self.dend[211]) h.pt3dadd(771, 150.5, -27, 1.3, sec = self.dend[211]) h.pt3dadd(772, 150.5, -27, 1.5, sec = self.dend[211]) h.pt3dadd(774.5, 152.5, -27, 1.1, sec = self.dend[211]) h.pt3dadd(775.5, 153, -29, 0.8, sec = self.dend[211]) h.pt3dadd(777.5, 154, -28, 0.7, sec = self.dend[211]) h.pt3dadd(781.5, 155, -29, 0.7, sec = self.dend[211]) h.pt3dadd(783.5, 155, -30.5, 0.9, sec = self.dend[211]) h.pt3dadd(785.5, 155, -30.5, 1.2, sec = self.dend[211]) h.pt3dadd(788, 153, -29, 1.5, sec = self.dend[211]) h.pt3dadd(788.5, 155, -30, 1.1, sec = self.dend[211]) h.pt3dadd(789, 157, -30, 1.2, sec = self.dend[211]) h.pt3dadd(789, 158, -31, 2.4, sec = self.dend[211]) h.pt3dadd(790, 158.5, -30.5, 0.8, sec = self.dend[211]) h.pt3dadd(791.5, 158.5, -31, 0.8, sec = self.dend[211]) h.pt3dadd(792, 158.5, -31, 0.9, sec = self.dend[211]) h.pt3dadd(793, 158.5, -31, 1.5, sec = self.dend[211]) h.pt3dadd(794.5, 158.5, -30.5, 2.7, sec = self.dend[211]) h.pt3dadd(797, 158.5, -32, 0.3, sec = self.dend[211]) h.pt3dadd(799, 158, -32, 0.7, sec = self.dend[211]) h.pt3dadd(801, 158, -32.5, 0.7, sec = self.dend[211]) h.pt3dadd(801.5, 159.5, -32.5, 1, sec = self.dend[211]) h.pt3dadd(803, 160, -32, 0.8, sec = self.dend[211]) h.pt3dadd(803.5, 160.5, -32.5, 0.8, sec = self.dend[211]) h.pt3dadd(805, 160.5, -33, 1.1, sec = self.dend[211]) h.pt3dadd(806, 161, -34, 1.4, sec = self.dend[211]) h.pt3dadd(807.5, 162, -32.5, 0.8, sec = self.dend[211]) h.pt3dadd(809, 162.5, -33, 0.8, sec = self.dend[211]) h.pt3dadd(810.5, 162.5, -34, 0.7, sec = self.dend[211]) h.pt3dadd(813, 163, -34.5, 0.7, sec = self.dend[211]) h.pt3dadd(814, 163, -34.5, 0.9, sec = self.dend[211]) h.pt3dadd(816, 163, -34.5, 0.9, sec = self.dend[211]) h.pt3dadd(816.5, 164.5, -34.5, 1.5, sec = self.dend[211]) h.pt3dadd(817.5, 165, -34, 0.9, sec = self.dend[211]) h.pt3dadd(818, 165.5, -34, 1.9, sec = self.dend[211]) h.pt3dadd(820.5, 167, -34, 1.5, sec = self.dend[211]) h.pt3dadd(821, 168, -34, 0.6, sec = self.dend[211]) h.pt3dadd(824, 168, -34, 0.9, sec = self.dend[211]) h.pt3dadd(825, 168, -35.5, 0.9, sec = self.dend[211]) h.pt3dadd(826, 170, -34, 1.4, sec = self.dend[211]) h.pt3dadd(827.5, 171, -34.5, 0.9, sec = self.dend[211]) h.pt3dadd(829, 172, -34, 0.7, sec = self.dend[211]) h.pt3dadd(832.5, 173.5, -40, 0.6, sec = self.dend[211]) h.pt3dadd(833.5, 175, -40, 1.1, sec = self.dend[211]) h.pt3dadd(834.5, 177, -40, 1.1, sec = self.dend[211]) h.pt3dadd(835.5, 178.5, -40, 0.7, sec = self.dend[211]) h.pt3dadd(837, 180, -40, 0.9, sec = self.dend[211]) h.pt3dadd(839, 180.5, -40, 1.1, sec = self.dend[211]) h.pt3dadd(840.5, 180.5, -40, 1.3, sec = self.dend[211]) h.pt3dadd(841, 180.5, -40, 1.6, sec = self.dend[211]) h.pt3dadd(843, 180.5, -40, 0.9, sec = self.dend[211]) h.pt3dadd(844, 180, -40, 1.3, sec = self.dend[211]) h.pt3dadd(845, 181, -40, 1, sec = self.dend[211]) h.pt3dadd(846.5, 181, -40, 1, sec = self.dend[211]) h.pt3dadd(847, 180.5, -40, 1.1, sec = self.dend[211]) h.pt3dadd(848.5, 180, -40, 1.2, sec = self.dend[211]) h.pt3dadd(851, 180, -40, 1.3, sec = self.dend[211]) h.pt3dadd(851.5, 180, -46.5, 1.7, sec = self.dend[211]) h.pt3dadd(854, 180.5, -40, 2, sec = self.dend[211]) h.pt3dadd(854.5, 181.5, -40, 2.1, sec = self.dend[211]) h.pt3dadd(855.5, 182.5, -40, 1.8, sec = self.dend[211]) h.pt3dadd(857, 183.5, -40, 0.8, sec = self.dend[211]) h.pt3dadd(858, 184, -40, 0.7, sec = self.dend[211]) h.pt3dadd(858.5, 185.5, -40, 1.9, sec = self.dend[211]) h.pt3dadd(860, 186, -46.5, 2.5, sec = self.dend[211]) h.pt3dadd(862, 187.5, -46.5, 3.8, sec = self.dend[211]) h.pt3dadd(862.5, 188, -46.5, 2.6, sec = self.dend[211]) h.pt3dadd(864.5, 188.5, -46.5, 1.9, sec = self.dend[211]) h.pt3dadd(865, 189, -46.5, 0.9, sec = self.dend[211]) h.pt3dadd(866, 190, -46.5, 1, sec = self.dend[211]) h.pt3dadd(868, 191, -46.5, 1.8, sec = self.dend[211]) h.pt3dadd(870, 192.5, -46.5, 1.4, sec = self.dend[211]) h.pt3dadd(871.5, 193.5, -46.5, 1.4, sec = self.dend[211]) h.pt3dadd(874, 195, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(875.5, 195, -46.5, 1.1, sec = self.dend[211]) h.pt3dadd(877.5, 195.5, -46.5, 1.3, sec = self.dend[211]) h.pt3dadd(879.5, 196.5, -46.5, 1.3, sec = self.dend[211]) h.pt3dadd(880.5, 197.5, -46.5, 1.7, sec = self.dend[211]) h.pt3dadd(882.5, 199.5, -46.5, 1.5, sec = self.dend[211]) h.pt3dadd(883, 200, -46.5, 1.3, sec = self.dend[211]) h.pt3dadd(884, 202, -46.5, 1.1, sec = self.dend[211]) h.pt3dadd(885.5, 204, -46.5, 0.8, sec = self.dend[211]) h.pt3dadd(887.5, 205, -46.5, 1.1, sec = self.dend[211]) h.pt3dadd(889, 206, -46.5, 1, sec = self.dend[211]) h.pt3dadd(890, 207.5, -52.5, 1.1, sec = self.dend[211]) h.pt3dadd(891.5, 209, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(893, 211.5, -46.5, 1.1, sec = self.dend[211]) h.pt3dadd(894.5, 213, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(896, 214, -46.5, 1.4, sec = self.dend[211]) h.pt3dadd(896, 214.5, -46.5, 1.7, sec = self.dend[211]) h.pt3dadd(897, 216, -46.5, 1.8, sec = self.dend[211]) h.pt3dadd(898, 218, -46.5, 2.2, sec = self.dend[211]) h.pt3dadd(899.5, 218.5, -46.5, 3, sec = self.dend[211]) h.pt3dadd(901, 219, -46.5, 2.7, sec = self.dend[211]) h.pt3dadd(902.5, 219, -46.5, 2, sec = self.dend[211]) h.pt3dadd(903.5, 219.5, -46.5, 1.4, sec = self.dend[211]) h.pt3dadd(905.5, 220, -46.5, 1, sec = self.dend[211]) h.pt3dadd(907.5, 221, -46.5, 1, sec = self.dend[211]) h.pt3dadd(909.5, 221, -46.5, 1.4, sec = self.dend[211]) h.pt3dadd(911.5, 222, -46.5, 1.8, sec = self.dend[211]) h.pt3dadd(914.5, 223, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(915.5, 223.5, -46.5, 0.5, sec = self.dend[211]) h.pt3dadd(918.5, 224.5, -46.5, 0.7, sec = self.dend[211]) h.pt3dadd(921.5, 224.5, -46.5, 1, sec = self.dend[211]) h.pt3dadd(923.5, 225.5, -52.5, 1, sec = self.dend[211]) h.pt3dadd(925, 225.5, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(926, 225.5, -46.5, 2, sec = self.dend[211]) h.pt3dadd(928.5, 225.5, -46.5, 1.2, sec = self.dend[211]) h.pt3dadd(929.5, 225.5, -46.5, 0.8, sec = self.dend[211]) h.pt3dadd(932, 225.5, -52.5, 1.1, sec = self.dend[211]) h.pt3dadd(934, 227, -52.5, 1.1, sec = self.dend[211]) h.pt3dadd(935, 228, -52.5, 1.2, sec = self.dend[211]) h.pt3dadd(937, 227, -52.5, 1.2, sec = self.dend[211]) h.pt3dadd(937.5, 227, -59, 1.6, sec = self.dend[211]) h.pt3dadd(940, 227, -59, 2.3, sec = self.dend[211]) h.pt3dadd(941, 228.5, -59, 1.2, sec = self.dend[211]) h.pt3dadd(942.5, 229.5, -59, 1.1, sec = self.dend[211]) h.pt3dadd(944.5, 231, -59, 0.9, sec = self.dend[211]) h.pt3dadd(945.5, 231, -59, 1.5, sec = self.dend[211]) h.pt3dadd(948, 233, -59, 1.8, sec = self.dend[211]) h.pt3dadd(948.5, 235, -59, 1.5, sec = self.dend[211]) h.pt3dadd(949.5, 237.5, -59, 1.1, sec = self.dend[211]) h.pt3dadd(951, 240.5, -59, 1.1, sec = self.dend[211]) h.pt3dadd(953, 242, -59, 1.2, sec = self.dend[211]) h.pt3dadd(955.5, 243.5, -59, 0.9, sec = self.dend[211]) h.pt3dadd(955.5, 245, -59, 0.9, sec = self.dend[211]) h.pt3dadd(958.5, 245.5, -59, 1.6, sec = self.dend[211]) h.pt3dadd(961, 248, -59, 0.8, sec = self.dend[211]) h.pt3dadd(964, 249, -59, 0.8, sec = self.dend[211]) h.pt3dadd(964.5, 251, -59, 0.8, sec = self.dend[211]) h.pt3dadd(965.5, 251, -59, 0.8, sec = self.dend[211]) h.pt3dadd(967, 252, -65, 0.8, sec = self.dend[211]) h.pt3dadd(969.5, 252, -65, 1.8, sec = self.dend[211]) h.pt3dadd(971.5, 252.5, -59, 1.9, sec = self.dend[211]) h.pt3dadd(973.5, 253, -59, 1.4, sec = self.dend[211]) h.pt3dadd(975.5, 253, -59, 1.2, sec = self.dend[211]) h.pt3dadd(977, 255, -59, 1, sec = self.dend[211]) h.pt3dadd(978, 255.5, -65, 1, sec = self.dend[211]) h.pt3dadd(979, 257, -65, 1, sec = self.dend[211]) h.pt3dadd(979.5, 258.5, -65, 1, sec = self.dend[211]) h.pt3dadd(981.5, 260, -65, 1, sec = self.dend[211]) h.pt3dadd(985, 262.5, -65, 0.8, sec = self.dend[211]) h.pt3dclear(sec = self.dend[212]) h.pt3dadd(769, 150.5, -25.5, 4, sec = self.dend[212]) h.pt3dadd(769.5, 148, -29, 1.2, sec = self.dend[212]) h.pt3dadd(771, 146, -29, 0.3, sec = self.dend[212]) h.pt3dadd(773, 146, -29, 0.3, sec = self.dend[212]) h.pt3dadd(773.5, 145, -29, 0.3, sec = self.dend[212]) h.pt3dadd(774.5, 144, -27, 1, sec = self.dend[212]) h.pt3dadd(776.5, 144, -29, 0.7, sec = self.dend[212]) h.pt3dadd(777.5, 144, -29, 0.6, sec = self.dend[212]) h.pt3dadd(775.5, 145.5, -27, 0.6, sec = self.dend[212]) h.pt3dadd(779, 144, -27, 0.6, sec = self.dend[212]) h.pt3dadd(782.5, 144, -27, 0.6, sec = self.dend[212]) h.pt3dadd(784, 144, -27, 0.6, sec = self.dend[212]) h.pt3dadd(785.5, 144, -28, 0.7, sec = self.dend[212]) h.pt3dadd(786, 144, -29, 0.8, sec = self.dend[212]) h.pt3dadd(788.5, 144.5, -27, 1.4, sec = self.dend[212]) h.pt3dadd(789, 145, -29, 0.1, sec = self.dend[212]) h.pt3dadd(791.5, 148.5, -27, 0.1, sec = self.dend[212]) h.pt3dadd(793.5, 148.5, -24.5, 1.6, sec = self.dend[212]) h.pt3dadd(796.5, 150.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(802.5, 155, -23.5, 0.3, sec = self.dend[212]) h.pt3dadd(804, 158.5, -24, 0.3, sec = self.dend[212]) h.pt3dadd(806.5, 158.5, -24, 0.3, sec = self.dend[212]) h.pt3dadd(809, 160.5, -24, 0.3, sec = self.dend[212]) h.pt3dadd(811.5, 160.5, -24, 0.3, sec = self.dend[212]) h.pt3dadd(813, 160.5, -24, 0.3, sec = self.dend[212]) h.pt3dadd(814, 160.5, -24.5, 0.3, sec = self.dend[212]) h.pt3dadd(815.5, 161.5, -25.5, 0.3, sec = self.dend[212]) h.pt3dadd(815.5, 161.5, -24, 1.2, sec = self.dend[212]) h.pt3dadd(817.5, 161.5, -23.5, 1.7, sec = self.dend[212]) h.pt3dadd(820, 161.5, -23.5, 0.6, sec = self.dend[212]) h.pt3dadd(822, 161.5, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(824, 162, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(826.5, 162.5, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(830.5, 165, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(833, 163.5, -23.5, 0.2, sec = self.dend[212]) h.pt3dadd(834.5, 163.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(836, 164.5, -23.5, 2.2, sec = self.dend[212]) h.pt3dadd(838.5, 168, -23.5, 0.6, sec = self.dend[212]) h.pt3dadd(841, 168, -24.5, 0.6, sec = self.dend[212]) h.pt3dadd(841.5, 168, -24, 2.2, sec = self.dend[212]) h.pt3dadd(843, 170, -24.5, 1.9, sec = self.dend[212]) h.pt3dadd(847, 170, -24.5, 0.7, sec = self.dend[212]) h.pt3dadd(850, 170, -24.5, 0.5, sec = self.dend[212]) h.pt3dadd(853, 170, -24.5, 0.5, sec = self.dend[212]) h.pt3dadd(853, 169, -24.5, 0.5, sec = self.dend[212]) h.pt3dadd(855, 169, -24, 1.6, sec = self.dend[212]) h.pt3dadd(856.5, 169, -24, 2.7, sec = self.dend[212]) h.pt3dadd(858.5, 169, -24, 3.3, sec = self.dend[212]) h.pt3dadd(859.5, 170.5, -22.5, 1.5, sec = self.dend[212]) h.pt3dadd(862.5, 174, -23.5, 0.8, sec = self.dend[212]) h.pt3dadd(864, 174, -23.5, 0.6, sec = self.dend[212]) h.pt3dadd(866.5, 175, -24.5, 0.9, sec = self.dend[212]) h.pt3dadd(868.5, 176.5, -24.5, 1.2, sec = self.dend[212]) h.pt3dadd(869.5, 178.5, -24.5, 1.2, sec = self.dend[212]) h.pt3dadd(873, 180.5, -24.5, 1.2, sec = self.dend[212]) h.pt3dadd(875, 182.5, -25.5, 1.5, sec = self.dend[212]) h.pt3dadd(879, 184.5, -24, 1.5, sec = self.dend[212]) h.pt3dadd(882.5, 185.5, -24, 1.5, sec = self.dend[212]) h.pt3dadd(885, 187, -24.5, 1.5, sec = self.dend[212]) h.pt3dadd(887.5, 188.5, -24.5, 1.6, sec = self.dend[212]) h.pt3dadd(888.5, 188.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(891, 190, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(895, 190, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(897.5, 190, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(900, 191.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(900, 190, -26, 0.1, sec = self.dend[212]) h.pt3dadd(903.5, 190, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(905.5, 192, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(908.5, 194, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(911, 194, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(914, 191.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(915, 191.5, -24.5, 1.4, sec = self.dend[212]) h.pt3dadd(918, 191.5, -24.5, 0.8, sec = self.dend[212]) h.pt3dadd(920.5, 191, -24.5, 0.3, sec = self.dend[212]) h.pt3dadd(923.5, 190, -25.5, 0.3, sec = self.dend[212]) h.pt3dadd(928.5, 189.5, -24.5, 0.3, sec = self.dend[212]) h.pt3dadd(931.5, 188, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(934.5, 188.5, -26, 0.2, sec = self.dend[212]) h.pt3dadd(937, 191, -26, 0.2, sec = self.dend[212]) h.pt3dadd(938.5, 191, -26, 1.1, sec = self.dend[212]) h.pt3dadd(940, 191, -26, 1.4, sec = self.dend[212]) h.pt3dadd(940.5, 192.5, -24, 0.1, sec = self.dend[212]) h.pt3dadd(943.5, 192, -24, 1.8, sec = self.dend[212]) h.pt3dadd(947.5, 192, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(951.5, 194, -26, 0.1, sec = self.dend[212]) h.pt3dadd(953.5, 194, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(957, 193.5, -25.5, 1, sec = self.dend[212]) h.pt3dadd(958.5, 193.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(961, 193.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(963.5, 194.5, -25.5, 1.6, sec = self.dend[212]) h.pt3dadd(966.5, 194, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(969, 193.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(970.5, 192.5, -25.5, 1.5, sec = self.dend[212]) h.pt3dadd(974, 192.5, -25.5, 0.6, sec = self.dend[212]) h.pt3dadd(976, 192.5, -26.5, 0.6, sec = self.dend[212]) h.pt3dadd(979.5, 195, -25.5, 2.7, sec = self.dend[212]) h.pt3dadd(981, 195, -27.5, 0.1, sec = self.dend[212]) h.pt3dadd(983.5, 195, -26.5, 0.1, sec = self.dend[212]) h.pt3dadd(986.5, 195, -26.5, 0.1, sec = self.dend[212]) h.pt3dadd(990.5, 194.5, -26.5, 3, sec = self.dend[212]) h.pt3dadd(993, 195, -26.5, 1.3, sec = self.dend[212]) h.pt3dadd(996.5, 195, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1001, 195, -27.5, 0.2, sec = self.dend[212]) h.pt3dadd(1004.5, 195, -25.5, 0.2, sec = self.dend[212]) h.pt3dadd(1006, 195, -24.5, 0.2, sec = self.dend[212]) h.pt3dadd(1009.5, 196, -25.5, 0.2, sec = self.dend[212]) h.pt3dadd(1013.5, 196.5, -26, 0.2, sec = self.dend[212]) h.pt3dadd(1015.5, 198.5, -26, 0.2, sec = self.dend[212]) h.pt3dadd(1019, 198, -26, 0.2, sec = self.dend[212]) h.pt3dadd(1022.5, 198, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1025.5, 198.5, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1030.5, 198.5, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1034.5, 198.5, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1036.5, 198.5, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1040.5, 198.5, -26.5, 0.2, sec = self.dend[212]) h.pt3dadd(1047, 197, -26.5, 0.1, sec = self.dend[212]) h.pt3dadd(1049.5, 196, -26.5, 0.1, sec = self.dend[212]) h.pt3dadd(1052, 196, -27.5, 0.1, sec = self.dend[212]) h.pt3dadd(1053.5, 195.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1055.5, 194, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1057.5, 194, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1060, 192.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1063, 191.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1064, 192.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1067, 192.5, -24.5, 0.5, sec = self.dend[212]) h.pt3dadd(1068.5, 193, -25.5, 1.7, sec = self.dend[212]) h.pt3dadd(1071.5, 194, -26, 0.6, sec = self.dend[212]) h.pt3dadd(1072, 195.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1077, 195.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1079, 195.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1082.5, 195.5, -26.5, 0.1, sec = self.dend[212]) h.pt3dadd(1083, 195.5, -24, 0.1, sec = self.dend[212]) h.pt3dadd(1085.5, 195.5, -24, 0.9, sec = self.dend[212]) h.pt3dadd(1087.5, 195.5, -25.5, 1.2, sec = self.dend[212]) h.pt3dadd(1092, 195.5, -25.5, 0.3, sec = self.dend[212]) h.pt3dadd(1092.5, 195.5, -23.5, 0.1, sec = self.dend[212]) h.pt3dadd(1094, 195.5, -24, 0.1, sec = self.dend[212]) h.pt3dadd(1096.5, 195.5, -22.5, 0.5, sec = self.dend[212]) h.pt3dadd(1098.5, 195.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1102, 195, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1107.5, 192.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1111, 192, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1112, 191, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1117, 189.5, -25.5, 0.1, sec = self.dend[212]) h.pt3dadd(1119.5, 189.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1121.5, 189.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1123, 189.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1125.5, 189, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1126.5, 186, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1128.5, 184.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1128.5, 182.5, -26, 0.1, sec = self.dend[212]) h.pt3dadd(1131.5, 182.5, -24.5, 0.1, sec = self.dend[212]) h.pt3dadd(1135.5, 183, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1137.5, 181.5, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1139.5, 181.5, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1140, 180, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1142, 180, -30.5, 1.1, sec = self.dend[212]) h.pt3dadd(1143.5, 179, -30.5, 1.2, sec = self.dend[212]) h.pt3dadd(1145.5, 179, -30.5, 1.8, sec = self.dend[212]) h.pt3dadd(1147.5, 177.5, -24.5, 1.2, sec = self.dend[212]) h.pt3dadd(1148.5, 177, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1151, 175, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1152, 173, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1153, 172, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1154.5, 172, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1157, 172, -30.5, 0.1, sec = self.dend[212]) h.pt3dadd(1158, 172, -30.5, 2, sec = self.dend[212]) h.pt3dadd(1158, 170.5, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1158.5, 168.5, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1160.5, 168, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1160.5, 166, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1159, 165, -37, 1.7, sec = self.dend[212]) h.pt3dadd(1158.5, 164.5, -37, 1.7, sec = self.dend[212]) h.pt3dadd(1159, 162.5, -37, 1.3, sec = self.dend[212]) h.pt3dadd(1159.5, 161.5, -37, 0.4, sec = self.dend[212]) h.pt3dadd(1159, 160, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1159, 157, -37, 0.1, sec = self.dend[212]) h.pt3dadd(1161, 155.5, -43, 0.1, sec = self.dend[212]) h.pt3dadd(1162.5, 155, -37, 0.7, sec = self.dend[212]) h.pt3dadd(1164, 155, -43, 0.7, sec = self.dend[212]) h.pt3dadd(1165, 152.5, -43, 0.7, sec = self.dend[212]) h.pt3dadd(1166, 152.5, -49.5, 0.1, sec = self.dend[212]) h.pt3dadd(1167, 153.5, -55.5, 0.1, sec = self.dend[212]) h.pt3dadd(1167.5, 151.5, -49.5, 0.1, sec = self.dend[212]) h.pt3dadd(1169.5, 153, -49.5, 0.1, sec = self.dend[212]) h.pt3dclear(sec = self.dend[213]) h.pt3dadd(406.5, 134.5, 4, 3.8, sec = self.dend[213]) h.pt3dadd(408.5, 136, 4, 2.1, sec = self.dend[213]) h.pt3dadd(411.5, 137.5, 4, 2.1, sec = self.dend[213]) h.pt3dadd(415, 139.5, 4, 2.1, sec = self.dend[213]) h.pt3dadd(417, 142, 4, 2.3, sec = self.dend[213]) h.pt3dadd(418.5, 144.5, 4, 2.3, sec = self.dend[213]) h.pt3dadd(421, 147, 4, 2.3, sec = self.dend[213]) h.pt3dadd(422, 149, 10, 1.4, sec = self.dend[213]) h.pt3dadd(423.5, 150.5, 10, 1.4, sec = self.dend[213]) h.pt3dadd(423.5, 152, 10, 1.7, sec = self.dend[213]) h.pt3dadd(424.5, 153.5, 10, 2.2, sec = self.dend[213]) h.pt3dadd(425, 156, 12.5, 2.4, sec = self.dend[213]) h.pt3dadd(426.5, 159, 12.5, 2.4, sec = self.dend[213]) h.pt3dadd(428.5, 160.5, 12.5, 2.1, sec = self.dend[213]) h.pt3dadd(430, 162.5, 12.5, 2.1, sec = self.dend[213]) h.pt3dadd(431, 163.5, 12.5, 1.7, sec = self.dend[213]) h.pt3dadd(433, 163.5, 12.5, 1.9, sec = self.dend[213]) h.pt3dadd(433.5, 165, 12.5, 1.9, sec = self.dend[213]) h.pt3dadd(436, 166.5, 21, 2.7, sec = self.dend[213]) h.pt3dadd(439, 166.5, 19.5, 2.2, sec = self.dend[213]) h.pt3dadd(438.5, 169.5, 21, 2, sec = self.dend[213]) h.pt3dadd(438, 170.5, 22.5, 1.5, sec = self.dend[213]) h.pt3dadd(439, 172, 22.5, 1, sec = self.dend[213]) h.pt3dadd(441, 172, 22.5, 1, sec = self.dend[213]) h.pt3dadd(442, 175, 22.5, 2.3, sec = self.dend[213]) h.pt3dadd(442.5, 177, 22.5, 2.7, sec = self.dend[213]) h.pt3dadd(443, 179, 22.5, 2.7, sec = self.dend[213]) h.pt3dadd(444.5, 181, 24, 1.6, sec = self.dend[213]) h.pt3dadd(445, 181, 24, 1.2, sec = self.dend[213]) h.pt3dadd(448, 181, 24, 1.2, sec = self.dend[213]) h.pt3dadd(448, 183.5, 24, 1.6, sec = self.dend[213]) h.pt3dadd(448, 184.5, 24, 2.2, sec = self.dend[213]) h.pt3dadd(447, 185, 24, 2.5, sec = self.dend[213]) h.pt3dadd(448.5, 185.5, 24, 2.6, sec = self.dend[213]) h.pt3dadd(449, 187.5, 22.5, 2.6, sec = self.dend[213]) h.pt3dadd(450.5, 189.5, 26.5, 2.3, sec = self.dend[213]) h.pt3dadd(452, 191, 26.5, 1.8, sec = self.dend[213]) h.pt3dadd(453, 191.5, 26.5, 1.6, sec = self.dend[213]) h.pt3dadd(454.5, 193.5, 26.5, 1.4, sec = self.dend[213]) h.pt3dadd(456.5, 194, 26.5, 1.4, sec = self.dend[213]) h.pt3dadd(458, 195, 26.5, 1.4, sec = self.dend[213]) h.pt3dadd(460, 195, 26.5, 1.4, sec = self.dend[213]) h.pt3dadd(461.5, 195, 26.5, 1.1, sec = self.dend[213]) h.pt3dadd(463.5, 195, 29.5, 1.1, sec = self.dend[213]) h.pt3dadd(464.5, 197.5, 29.5, 2, sec = self.dend[213]) h.pt3dadd(466, 198.5, 29.5, 2.3, sec = self.dend[213]) h.pt3dadd(466, 200, 28, 2.3, sec = self.dend[213]) h.pt3dadd(469.5, 198, 28, 2.2, sec = self.dend[213]) h.pt3dadd(471, 199.5, 34, 2, sec = self.dend[213]) h.pt3dadd(472.5, 201, 32.5, 2, sec = self.dend[213]) h.pt3dadd(474.5, 201.5, 35.5, 1.2, sec = self.dend[213]) h.pt3dadd(474.5, 204, 39.5, 1.5, sec = self.dend[213]) h.pt3dadd(476.5, 206.5, 42.5, 2.1, sec = self.dend[213]) h.pt3dadd(479.5, 206.5, 42.5, 2.1, sec = self.dend[213]) h.pt3dadd(483, 206.5, 42.5, 1.6, sec = self.dend[213]) h.pt3dadd(483.5, 207, 36.5, 1.9, sec = self.dend[213]) h.pt3dadd(485.5, 207, 36.5, 1.9, sec = self.dend[213]) h.pt3dadd(487, 207, 36.5, 3.4, sec = self.dend[213]) h.pt3dadd(488, 209, 36.5, 2.1, sec = self.dend[213]) h.pt3dadd(489.5, 209, 36.5, 1.7, sec = self.dend[213]) h.pt3dadd(491, 209.5, 36.5, 1.7, sec = self.dend[213]) h.pt3dadd(492, 210.5, 36.5, 2.4, sec = self.dend[213]) h.pt3dadd(493, 211, 36.5, 2.9, sec = self.dend[213]) h.pt3dadd(494, 213.5, 36.5, 1.7, sec = self.dend[213]) h.pt3dadd(496, 216.5, 38, 1.7, sec = self.dend[213]) h.pt3dadd(497.5, 218, 38, 1.7, sec = self.dend[213]) h.pt3dadd(500.5, 219.5, 38, 1.5, sec = self.dend[213]) h.pt3dadd(501.5, 220, 36.5, 1.5, sec = self.dend[213]) h.pt3dadd(506.5, 221.5, 36.5, 1.5, sec = self.dend[213]) h.pt3dadd(509.5, 224.5, 42.5, 1.2, sec = self.dend[213]) h.pt3dadd(511, 225, 55, 1.2, sec = self.dend[213]) h.pt3dadd(511.5, 226, 57, 2.3, sec = self.dend[213]) h.pt3dadd(512.5, 227.5, 58.5, 3.1, sec = self.dend[213]) h.pt3dadd(514.5, 229, 62, 1.9, sec = self.dend[213]) h.pt3dadd(515.5, 230.5, 62, 0.5, sec = self.dend[213]) h.pt3dadd(517, 231, 62, 0.5, sec = self.dend[213]) h.pt3dadd(517.5, 232.5, 58.5, 1.3, sec = self.dend[213]) h.pt3dadd(517.5, 234.5, 64, 2.4, sec = self.dend[213]) h.pt3dadd(518.5, 236.5, 64, 0.1, sec = self.dend[213]) h.pt3dadd(520.5, 235.5, 64, 0.1, sec = self.dend[213]) h.pt3dadd(521.5, 235.5, 60.5, 1.9, sec = self.dend[213]) h.pt3dadd(523, 235.5, 62, 3.1, sec = self.dend[213]) h.pt3dadd(525.5, 236.5, 62, 1.8, sec = self.dend[213]) h.pt3dadd(526, 236.5, 64, 0.1, sec = self.dend[213]) h.pt3dadd(528, 236.5, 64, 1.3, sec = self.dend[213]) h.pt3dadd(529.5, 238, 64, 1.4, sec = self.dend[213]) h.pt3dadd(529.5, 239, 64, 1.5, sec = self.dend[213]) h.pt3dadd(531, 240.5, 64, 1.5, sec = self.dend[213]) h.pt3dadd(534, 242.5, 64, 1.5, sec = self.dend[213]) h.pt3dadd(534.5, 244, 66, 0.9, sec = self.dend[213]) h.pt3dadd(536, 244, 66, 0.9, sec = self.dend[213]) h.pt3dadd(537.5, 245, 60.5, 2.5, sec = self.dend[213]) h.pt3dadd(537.5, 245, 66, 3.1, sec = self.dend[213]) h.pt3dadd(540, 247.5, 64, 0.4, sec = self.dend[213]) h.pt3dadd(540, 248.5, 58.5, 0.1, sec = self.dend[213]) h.pt3dadd(540, 250.5, 57, 1.6, sec = self.dend[213]) h.pt3dadd(541, 251.5, 57, 1.8, sec = self.dend[213]) h.pt3dadd(540.5, 253.5, 57, 1.9, sec = self.dend[213]) h.pt3dadd(541, 255, 58.5, 1.1, sec = self.dend[213]) h.pt3dadd(541.5, 256, 58.5, 1.3, sec = self.dend[213]) h.pt3dadd(542.5, 256, 60, 1.7, sec = self.dend[213]) h.pt3dadd(544, 257.5, 61.5, 1.8, sec = self.dend[213]) h.pt3dadd(544, 259, 61.5, 2.4, sec = self.dend[213]) h.pt3dadd(543.5, 262.5, 64.5, 1.6, sec = self.dend[213]) h.pt3dadd(543.5, 263, 64.5, 0.8, sec = self.dend[213]) h.pt3dadd(544.5, 263.5, 64.5, 0.9, sec = self.dend[213]) h.pt3dadd(545, 264, 64.5, 0.9, sec = self.dend[213]) h.pt3dadd(545.5, 265, 64.5, 1.6, sec = self.dend[213]) h.pt3dadd(546.5, 265, 66, 2.6, sec = self.dend[213]) h.pt3dadd(546.5, 267.5, 66, 3.8, sec = self.dend[213]) h.pt3dclear(sec = self.dend[214]) h.pt3dadd(546.5, 267.5, 66, 3.8, sec = self.dend[214]) h.pt3dadd(545.5, 269, 67.5, 0.1, sec = self.dend[214]) h.pt3dadd(545, 270.5, 66, 0.1, sec = self.dend[214]) h.pt3dadd(545, 272.5, 66, 0.1, sec = self.dend[214]) h.pt3dadd(542.5, 272.5, 66, 0.1, sec = self.dend[214]) h.pt3dadd(540.5, 273, 66, 0.1, sec = self.dend[214]) h.pt3dadd(540, 274, 64.5, 1.8, sec = self.dend[214]) h.pt3dadd(538.5, 276, 64.5, 1.8, sec = self.dend[214]) h.pt3dadd(537, 277, 64.5, 2, sec = self.dend[214]) h.pt3dadd(537.5, 278.5, 67.5, 1.7, sec = self.dend[214]) h.pt3dadd(539, 280.5, 67.5, 2.1, sec = self.dend[214]) h.pt3dadd(538.5, 284.5, 69, 1.7, sec = self.dend[214]) h.pt3dclear(sec = self.dend[215]) h.pt3dadd(546.5, 267.5, 66, 3.8, sec = self.dend[215]) h.pt3dadd(552, 270.5, 66, 0.4, sec = self.dend[215]) h.pt3dadd(554, 271.5, 66, 0.4, sec = self.dend[215]) h.pt3dadd(555.5, 271, 66, 0.2, sec = self.dend[215]) h.pt3dadd(557, 273, 66, 0.2, sec = self.dend[215]) h.pt3dadd(557, 274.5, 66, 0.2, sec = self.dend[215]) h.pt3dadd(558.5, 277.5, 66, 0.2, sec = self.dend[215]) h.pt3dadd(560.5, 278, 66, 1.6, sec = self.dend[215]) h.pt3dadd(561.5, 279.5, 66, 1.2, sec = self.dend[215]) h.pt3dadd(565, 281.5, 69, 0.5, sec = self.dend[215]) h.pt3dadd(563.5, 283, 69, 0.1, sec = self.dend[215]) h.pt3dadd(565.5, 284, 69, 0.1, sec = self.dend[215]) h.pt3dadd(566.5, 284.5, 69, 1.8, sec = self.dend[215]) h.pt3dadd(567.5, 286, 70.5, 0.2, sec = self.dend[215]) h.pt3dadd(568.5, 289, 70.5, 0.2, sec = self.dend[215]) h.pt3dadd(570.5, 290.5, 70.5, 0.2, sec = self.dend[215]) h.pt3dadd(569.5, 291.5, 70.5, 1, sec = self.dend[215]) h.pt3dadd(570, 294, 72, 2.8, sec = self.dend[215]) h.pt3dadd(571, 296.5, 72, 1, sec = self.dend[215]) h.pt3dadd(571.5, 296.5, 72, 0.2, sec = self.dend[215]) h.pt3dadd(573.5, 297.5, 72, 0.1, sec = self.dend[215]) h.pt3dadd(574, 298.5, 72, 0.6, sec = self.dend[215]) h.pt3dadd(575.5, 300.5, 72, 0.9, sec = self.dend[215]) h.pt3dadd(575.5, 302, 73.5, 0.1, sec = self.dend[215]) h.pt3dadd(574.5, 303, 73.5, 0.1, sec = self.dend[215]) h.pt3dadd(576.5, 303.5, 73.5, 0.1, sec = self.dend[215]) h.pt3dadd(575.5, 305.5, 76.5, 1.7, sec = self.dend[215]) h.pt3dadd(575.5, 306.5, 78, 3, sec = self.dend[215]) h.pt3dadd(575.5, 308, 78, 0.5, sec = self.dend[215]) h.pt3dadd(576.5, 309.5, 79.5, 0.1, sec = self.dend[215]) h.pt3dadd(579.5, 311, 79.5, 0.1, sec = self.dend[215]) h.pt3dadd(580, 312.5, 78, 0.3, sec = self.dend[215]) h.pt3dadd(582, 313.5, 73.5, 0.6, sec = self.dend[215]) h.pt3dadd(583.5, 313.5, 76.5, 1.9, sec = self.dend[215]) h.pt3dadd(587.5, 313.5, 76.5, 0.5, sec = self.dend[215]) h.pt3dadd(589, 316, 82.5, 0.1, sec = self.dend[215]) h.pt3dadd(591.5, 316.5, 82.5, 0.9, sec = self.dend[215]) h.pt3dadd(593.5, 319.5, 84.5, 0.9, sec = self.dend[215]) h.pt3dadd(596.5, 321, 84.5, 0.9, sec = self.dend[215]) h.pt3dadd(599.5, 322.5, 84.5, 2, sec = self.dend[215]) h.pt3dclear(sec = self.dend[216]) h.pt3dadd(599.5, 322.5, 84.5, 2, sec = self.dend[216]) h.pt3dadd(601.5, 322.5, 84.5, 0.9, sec = self.dend[216]) h.pt3dadd(604.5, 322.5, 84.5, 0.8, sec = self.dend[216]) h.pt3dadd(605, 325.5, 80.5, 1.8, sec = self.dend[216]) h.pt3dadd(607, 325.5, 84.5, 2.8, sec = self.dend[216]) h.pt3dadd(609, 325.5, 84.5, 1.7, sec = self.dend[216]) h.pt3dadd(611, 327, 82.5, 0.9, sec = self.dend[216]) h.pt3dadd(613.5, 327, 80.5, 0.6, sec = self.dend[216]) h.pt3dadd(615.5, 327, 82.5, 0.6, sec = self.dend[216]) h.pt3dadd(617.5, 328, 82.5, 2.1, sec = self.dend[216]) h.pt3dadd(619.5, 329.5, 80.5, 0.5, sec = self.dend[216]) h.pt3dadd(623, 329.5, 80.5, 0.5, sec = self.dend[216]) h.pt3dadd(626, 331.5, 80.5, 1.8, sec = self.dend[216]) h.pt3dadd(628, 332.5, 80.5, 0.8, sec = self.dend[216]) h.pt3dadd(629.5, 333, 80.5, 0.8, sec = self.dend[216]) h.pt3dadd(631.5, 333.5, 80.5, 2.4, sec = self.dend[216]) h.pt3dadd(631.5, 332.5, 80.5, 2, sec = self.dend[216]) h.pt3dadd(631.5, 331, 80.5, 1.1, sec = self.dend[216]) h.pt3dadd(632, 329, 78.5, 0.8, sec = self.dend[216]) h.pt3dadd(637, 326.5, 80.5, 1.2, sec = self.dend[216]) h.pt3dclear(sec = self.dend[217]) h.pt3dadd(599.5, 322.5, 84.5, 2, sec = self.dend[217]) h.pt3dadd(598, 327.5, 84.5, 0.6, sec = self.dend[217]) h.pt3dadd(596, 329, 86.5, 0.7, sec = self.dend[217]) h.pt3dadd(594.5, 331.5, 86.5, 0.7, sec = self.dend[217]) h.pt3dadd(593, 333.5, 86.5, 0.7, sec = self.dend[217]) h.pt3dadd(592, 334.5, 88.5, 1.2, sec = self.dend[217]) h.pt3dadd(590, 336, 88.5, 1.6, sec = self.dend[217]) h.pt3dadd(590, 338.5, 88.5, 1.1, sec = self.dend[217]) h.pt3dadd(589, 340, 90.5, 0.6, sec = self.dend[217]) h.pt3dadd(587, 343.5, 90.5, 0.6, sec = self.dend[217]) h.pt3dadd(585.5, 345.5, 92.5, 0.6, sec = self.dend[217]) h.pt3dadd(584, 346.5, 90.5, 1.2, sec = self.dend[217]) h.pt3dadd(583, 348, 90.5, 1.2, sec = self.dend[217]) h.pt3dadd(581, 350, 90.5, 0.7, sec = self.dend[217]) h.pt3dadd(578, 352, 90.5, 0.7, sec = self.dend[217]) h.pt3dadd(575, 353, 88.5, 0.7, sec = self.dend[217]) h.pt3dclear(sec = self.dend[218]) h.pt3dadd(157, 85.5, -15.5, 11.6, sec = self.dend[218]) h.pt3dadd(164, 94.5, -13, 5.7, sec = self.dend[218]) h.pt3dadd(167, 98.5, -13, 6.2, sec = self.dend[218]) h.pt3dadd(170.5, 98.5, -13, 6.2, sec = self.dend[218]) h.pt3dadd(174, 103.5, -13, 6.8, sec = self.dend[218]) h.pt3dadd(177.5, 107, -14, 7.1, sec = self.dend[218]) h.pt3dadd(179, 110, -14, 6.7, sec = self.dend[218]) h.pt3dadd(183.5, 112, -15, 6.3, sec = self.dend[218]) h.pt3dadd(188, 117, -15, 6.6, sec = self.dend[218]) h.pt3dadd(190, 120.5, -15, 6.7, sec = self.dend[218]) h.pt3dadd(193, 123.5, -15, 6.3, sec = self.dend[218]) h.pt3dadd(195, 127, -15, 6.3, sec = self.dend[218]) h.pt3dadd(198, 130.5, -15, 7, sec = self.dend[218]) h.pt3dadd(200, 132.5, -15, 7.3, sec = self.dend[218]) h.pt3dadd(202.5, 135.5, -15, 6.7, sec = self.dend[218]) h.pt3dadd(204.5, 137.5, -15.5, 7, sec = self.dend[218]) h.pt3dadd(207, 140.5, -15.5, 7.2, sec = self.dend[218]) h.pt3dadd(210.5, 141.5, -15.5, 7.5, sec = self.dend[218]) h.pt3dadd(212.5, 144.5, -8.5, 7.8, sec = self.dend[218]) h.pt3dadd(215.5, 147.5, -6.5, 6.8, sec = self.dend[218]) h.pt3dadd(218, 151, -8.5, 6, sec = self.dend[218]) h.pt3dadd(222, 152, -8.5, 7.3, sec = self.dend[218]) h.pt3dadd(225, 156, -8.5, 7.9, sec = self.dend[218]) h.pt3dadd(228.5, 157.5, -9.5, 6.9, sec = self.dend[218]) h.pt3dadd(231.5, 160.5, -9.5, 5.7, sec = self.dend[218]) h.pt3dadd(233.5, 162.5, -9.5, 5.7, sec = self.dend[218]) h.pt3dadd(235.5, 164.5, -4, 6.5, sec = self.dend[218]) h.pt3dadd(241, 166.5, -5, 6.9, sec = self.dend[218]) h.pt3dadd(244.5, 169.5, -5, 7.6, sec = self.dend[218]) h.pt3dadd(247.5, 172, -5, 7.6, sec = self.dend[218]) h.pt3dadd(250.5, 175, -1, 8.1, sec = self.dend[218]) h.pt3dclear(sec = self.dend[219]) h.pt3dadd(250.5, 175, -1, 8.1, sec = self.dend[219]) h.pt3dadd(250.5, 181.5, -7.5, 2.9, sec = self.dend[219]) h.pt3dadd(251.5, 184.5, -5.5, 2.3, sec = self.dend[219]) h.pt3dadd(252, 187.5, 0, 2.3, sec = self.dend[219]) h.pt3dadd(252.5, 192, -4, 1.6, sec = self.dend[219]) h.pt3dadd(249, 196.5, -20.5, 2.9, sec = self.dend[219]) h.pt3dadd(249, 201.5, -20.5, 2.9, sec = self.dend[219]) h.pt3dadd(248, 205, -20.5, 3.1, sec = self.dend[219]) h.pt3dadd(246.5, 210, -15, 2.9, sec = self.dend[219]) h.pt3dadd(246.5, 214, -15, 2.6, sec = self.dend[219]) h.pt3dadd(246.5, 218, -1, 2.7, sec = self.dend[219]) h.pt3dadd(249, 220, -1, 2.5, sec = self.dend[219]) h.pt3dadd(250.5, 223, 2, 1.5, sec = self.dend[219]) h.pt3dadd(252, 224, 2, 1.6, sec = self.dend[219]) h.pt3dadd(253, 227, 4.5, 2.8, sec = self.dend[219]) h.pt3dadd(254, 230, 4.5, 2.8, sec = self.dend[219]) h.pt3dadd(254, 233.5, 7.5, 2.7, sec = self.dend[219]) h.pt3dadd(255, 238, -1, 2.4, sec = self.dend[219]) h.pt3dadd(255, 241.5, -1, 2.2, sec = self.dend[219]) h.pt3dadd(257, 243, 4.5, 2.9, sec = self.dend[219]) h.pt3dadd(257, 244.5, 4.5, 3, sec = self.dend[219]) h.pt3dadd(258.5, 248, 4.5, 1.8, sec = self.dend[219]) h.pt3dadd(259, 251.5, 7.5, 2.6, sec = self.dend[219]) h.pt3dadd(261.5, 253.5, 10, 2.6, sec = self.dend[219]) h.pt3dadd(263, 256, 10, 3.3, sec = self.dend[219]) h.pt3dadd(263.5, 257.5, 10, 3.6, sec = self.dend[219]) h.pt3dadd(264.5, 259.5, 13, 2.5, sec = self.dend[219]) h.pt3dadd(266, 261.5, 7.5, 2, sec = self.dend[219]) h.pt3dadd(267, 263, 10, 1.7, sec = self.dend[219]) h.pt3dadd(268, 265.5, 10, 1.5, sec = self.dend[219]) h.pt3dadd(269.5, 267.5, 13, 1.4, sec = self.dend[219]) h.pt3dadd(270, 270, 7.5, 1.9, sec = self.dend[219]) h.pt3dadd(271.5, 272, 13, 2.5, sec = self.dend[219]) h.pt3dadd(272.5, 275, 13, 2.6, sec = self.dend[219]) h.pt3dadd(272.5, 277.5, 13, 2, sec = self.dend[219]) h.pt3dadd(272.5, 280, 13, 1.6, sec = self.dend[219]) h.pt3dadd(273.5, 282.5, 10, 2.6, sec = self.dend[219]) h.pt3dadd(275.5, 285.5, 13, 2.9, sec = self.dend[219]) h.pt3dadd(278.5, 288.5, 13, 2.9, sec = self.dend[219]) h.pt3dadd(280, 291, 13, 2.9, sec = self.dend[219]) h.pt3dadd(280.5, 294.5, 7.5, 2.3, sec = self.dend[219]) h.pt3dadd(282.5, 296, 10, 2, sec = self.dend[219]) h.pt3dadd(284, 297.5, 10, 2, sec = self.dend[219]) h.pt3dadd(284, 299.5, 10, 2, sec = self.dend[219]) h.pt3dadd(284, 301, 10, 2, sec = self.dend[219]) h.pt3dadd(285.5, 303.5, 10, 2.3, sec = self.dend[219]) h.pt3dadd(286.5, 305, 10, 2.1, sec = self.dend[219]) h.pt3dadd(288.5, 307.5, 10, 2.2, sec = self.dend[219]) h.pt3dadd(288, 310, 10, 2.4, sec = self.dend[219]) h.pt3dadd(288, 311.5, 10, 2.4, sec = self.dend[219]) h.pt3dadd(289, 314.5, 10, 2.7, sec = self.dend[219]) h.pt3dadd(290.5, 317, 10, 1.3, sec = self.dend[219]) h.pt3dadd(292.5, 318, 10, 1.3, sec = self.dend[219]) h.pt3dadd(292.5, 319.5, 10, 2.1, sec = self.dend[219]) h.pt3dadd(294, 322, 10, 2.8, sec = self.dend[219]) h.pt3dadd(295.5, 324, -1, 3.7, sec = self.dend[219]) h.pt3dadd(299.5, 327, 4.5, 3.7, sec = self.dend[219]) h.pt3dadd(303, 330, 2, 3.8, sec = self.dend[219]) h.pt3dadd(304, 331.5, 2, 4.3, sec = self.dend[219]) h.pt3dadd(305, 335.5, 2, 3.6, sec = self.dend[219]) h.pt3dclear(sec = self.dend[220]) h.pt3dadd(305, 335.5, 2, 3.6, sec = self.dend[220]) h.pt3dadd(314, 344.5, 2, 0.8, sec = self.dend[220]) h.pt3dadd(316.5, 344.5, 2, 0.8, sec = self.dend[220]) h.pt3dadd(318, 346, 2, 0.8, sec = self.dend[220]) h.pt3dadd(322, 349.5, 2, 0.8, sec = self.dend[220]) h.pt3dadd(324.5, 351, -9.5, 0.8, sec = self.dend[220]) h.pt3dadd(327, 354, -12, 0.8, sec = self.dend[220]) h.pt3dadd(329.5, 356, -6.5, 0.9, sec = self.dend[220]) h.pt3dadd(332, 359, -6.5, 0.9, sec = self.dend[220]) h.pt3dadd(335.5, 362, 4.5, 0.9, sec = self.dend[220]) h.pt3dadd(337, 363.5, 6, 1.3, sec = self.dend[220]) h.pt3dadd(337.5, 367, 6, 1.8, sec = self.dend[220]) h.pt3dadd(338, 369.5, 9, 2, sec = self.dend[220]) h.pt3dadd(338.5, 372, 9, 2.6, sec = self.dend[220]) h.pt3dadd(338, 376, 9, 2.6, sec = self.dend[220]) h.pt3dadd(336.5, 377.5, 9, 2.6, sec = self.dend[220]) h.pt3dadd(336, 379, 8, 1.1, sec = self.dend[220]) h.pt3dadd(336, 381.5, 8, 1.1, sec = self.dend[220]) h.pt3dadd(336, 383.5, 8, 1.8, sec = self.dend[220]) h.pt3dadd(335, 387, 3.5, 2.4, sec = self.dend[220]) h.pt3dadd(335, 389.5, 3.5, 2.4, sec = self.dend[220]) h.pt3dadd(334, 398, 3.5, 1.7, sec = self.dend[220]) h.pt3dadd(334.5, 400, 4.5, 1.7, sec = self.dend[220]) h.pt3dadd(334.5, 403, 0.5, 1.7, sec = self.dend[220]) h.pt3dadd(334.5, 405, -9, 1.8, sec = self.dend[220]) h.pt3dadd(334.5, 409, -9, 1.9, sec = self.dend[220]) h.pt3dadd(334.5, 411, -9, 2, sec = self.dend[220]) h.pt3dadd(336, 411.5, -9, 2.7, sec = self.dend[220]) h.pt3dadd(335.5, 414.5, -9, 1.6, sec = self.dend[220]) h.pt3dadd(336, 415.5, -9, 1.5, sec = self.dend[220]) h.pt3dadd(338, 415.5, -9, 1.5, sec = self.dend[220]) h.pt3dadd(340, 417, -9, 3.1, sec = self.dend[220]) h.pt3dadd(341.5, 418.5, -9, 1.7, sec = self.dend[220]) h.pt3dadd(341.5, 421, -9, 1.8, sec = self.dend[220]) h.pt3dadd(342.5, 424, -9, 1.7, sec = self.dend[220]) h.pt3dadd(342.5, 426, -9, 2.4, sec = self.dend[220]) h.pt3dadd(343, 427.5, -9, 2.7, sec = self.dend[220]) h.pt3dadd(343, 429.5, -9, 2.7, sec = self.dend[220]) h.pt3dadd(343, 430.5, -9, 1.6, sec = self.dend[220]) h.pt3dadd(342.5, 432, -9, 1.3, sec = self.dend[220]) h.pt3dadd(342.5, 435.5, -9, 1.3, sec = self.dend[220]) h.pt3dadd(342.5, 437.5, -10, 0.9, sec = self.dend[220]) h.pt3dadd(341.5, 441, -12.5, 1.2, sec = self.dend[220]) h.pt3dadd(342, 442.5, -15, 1.4, sec = self.dend[220]) h.pt3dadd(344, 443, -14.5, 2.3, sec = self.dend[220]) h.pt3dadd(344.5, 444.5, -13.5, 2.3, sec = self.dend[220]) h.pt3dadd(344.5, 448.5, -13.5, 2.3, sec = self.dend[220]) h.pt3dadd(344.5, 451, -13.5, 2.3, sec = self.dend[220]) h.pt3dadd(346, 453, -13.5, 2.3, sec = self.dend[220]) h.pt3dadd(347, 453.5, -13.5, 1.8, sec = self.dend[220]) h.pt3dadd(348.5, 455.5, -13.5, 1.3, sec = self.dend[220]) h.pt3dadd(351, 456.5, -13.5, 1.3, sec = self.dend[220]) h.pt3dadd(351, 458.5, -13.5, 1.3, sec = self.dend[220]) h.pt3dadd(352, 460.5, -13.5, 0.9, sec = self.dend[220]) h.pt3dadd(353, 462, -13.5, 0.9, sec = self.dend[220]) h.pt3dadd(354, 462, -13.5, 1.4, sec = self.dend[220]) h.pt3dadd(355, 465, -13.5, 1, sec = self.dend[220]) h.pt3dadd(354, 466, -14.5, 1.1, sec = self.dend[220]) h.pt3dadd(357, 466, -14.5, 1.1, sec = self.dend[220]) h.pt3dadd(357.5, 466, -14.5, 1.1, sec = self.dend[220]) h.pt3dadd(357.5, 467, -15, 1.4, sec = self.dend[220]) h.pt3dadd(357, 469.5, -15, 1.4, sec = self.dend[220]) h.pt3dadd(357, 471.5, -18, 1.4, sec = self.dend[220]) h.pt3dadd(357, 468.5, -20, 1.1, sec = self.dend[220]) h.pt3dadd(357.5, 466.5, -20, 1.1, sec = self.dend[220]) h.pt3dadd(358, 464, -20, 1.1, sec = self.dend[220]) h.pt3dadd(358, 463, -20, 1.7, sec = self.dend[220]) h.pt3dadd(357, 460, -22.5, 1.9, sec = self.dend[220]) h.pt3dadd(357, 458, -22.5, 1.3, sec = self.dend[220]) h.pt3dadd(356, 455, -26, 1, sec = self.dend[220]) h.pt3dadd(353.5, 455, -26, 1, sec = self.dend[220]) h.pt3dadd(352.5, 454.5, -24.5, 1, sec = self.dend[220]) h.pt3dadd(351.5, 454.5, -24.5, 2.6, sec = self.dend[220]) h.pt3dadd(351.5, 452, -26, 2.2, sec = self.dend[220]) h.pt3dadd(350.5, 451, -26, 1.7, sec = self.dend[220]) h.pt3dadd(351, 448.5, -27, 1.5, sec = self.dend[220]) h.pt3dadd(349, 446.5, -27, 1.5, sec = self.dend[220]) h.pt3dadd(347.5, 445.5, -30.5, 1.3, sec = self.dend[220]) h.pt3dadd(348.5, 442.5, -30.5, 1.3, sec = self.dend[220]) h.pt3dclear(sec = self.dend[221]) h.pt3dadd(305, 335.5, 2, 3.6, sec = self.dend[221]) h.pt3dadd(309.5, 340.5, -1, 2.1, sec = self.dend[221]) h.pt3dadd(311, 342, -1, 2.3, sec = self.dend[221]) h.pt3dadd(312.5, 345, -6.5, 2.6, sec = self.dend[221]) h.pt3dadd(312.5, 347.5, 4.5, 2.7, sec = self.dend[221]) h.pt3dadd(314, 352.5, 9, 0.9, sec = self.dend[221]) h.pt3dadd(315, 355, 9, 0.9, sec = self.dend[221]) h.pt3dadd(317.5, 356.5, 7.5, 0.9, sec = self.dend[221]) h.pt3dadd(318, 357.5, 9, 1.2, sec = self.dend[221]) h.pt3dadd(318, 358.5, 9, 1.2, sec = self.dend[221]) h.pt3dadd(319.5, 361, 9, 1.2, sec = self.dend[221]) h.pt3dadd(319.5, 362.5, 9, 0.6, sec = self.dend[221]) h.pt3dadd(321, 362.5, 9, 0.6, sec = self.dend[221]) h.pt3dadd(322, 364, 9, 0.6, sec = self.dend[221]) h.pt3dadd(323.5, 364, 9, 1.6, sec = self.dend[221]) h.pt3dadd(323.5, 367.5, 9, 1.6, sec = self.dend[221]) h.pt3dadd(324, 368, 9, 1.6, sec = self.dend[221]) h.pt3dadd(324.5, 370, 9, 0.9, sec = self.dend[221]) h.pt3dadd(325.5, 371.5, 9, 0.9, sec = self.dend[221]) h.pt3dadd(325.5, 373, 9, 1.2, sec = self.dend[221]) h.pt3dadd(327.5, 373.5, 9, 0.9, sec = self.dend[221]) h.pt3dadd(328.5, 374.5, 10.5, 0.7, sec = self.dend[221]) h.pt3dadd(329, 376.5, 10.5, 0.7, sec = self.dend[221]) h.pt3dadd(330, 376.5, 10.5, 0.9, sec = self.dend[221]) h.pt3dadd(331.5, 377.5, 10.5, 0.9, sec = self.dend[221]) h.pt3dadd(333, 379, 10.5, 1.4, sec = self.dend[221]) h.pt3dadd(334.5, 381, 10.5, 1.5, sec = self.dend[221]) h.pt3dadd(335.5, 383, 10.5, 1.5, sec = self.dend[221]) h.pt3dadd(337, 385.5, 12, 1.6, sec = self.dend[221]) h.pt3dadd(339.5, 388.5, 12, 2, sec = self.dend[221]) h.pt3dadd(342, 390, 13.5, 2, sec = self.dend[221]) h.pt3dadd(342, 392, 13.5, 1.4, sec = self.dend[221]) h.pt3dadd(342, 394.5, 13.5, 1.4, sec = self.dend[221]) h.pt3dadd(343.5, 397, 13.5, 1.7, sec = self.dend[221]) h.pt3dadd(344, 398.5, 14.5, 2.8, sec = self.dend[221]) h.pt3dadd(344, 401, 14.5, 2.8, sec = self.dend[221]) h.pt3dadd(343, 403.5, 14.5, 1.6, sec = self.dend[221]) h.pt3dadd(342.5, 407, 14.5, 1.1, sec = self.dend[221]) h.pt3dadd(342.5, 409, 14.5, 1.1, sec = self.dend[221]) h.pt3dadd(342.5, 411.5, 14.5, 1.3, sec = self.dend[221]) h.pt3dadd(343, 414, 14.5, 1.5, sec = self.dend[221]) h.pt3dadd(344, 415.5, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(345, 418, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(345, 419.5, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(345.5, 421, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(346.5, 423.5, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(346.5, 426, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(346.5, 426.5, 14.5, 1.9, sec = self.dend[221]) h.pt3dadd(347, 428.5, 14.5, 2, sec = self.dend[221]) h.pt3dadd(348, 431.5, 14.5, 2, sec = self.dend[221]) h.pt3dadd(349, 434, 14.5, 2, sec = self.dend[221]) h.pt3dadd(349, 436, 14.5, 2, sec = self.dend[221]) h.pt3dadd(349, 438.5, 14.5, 1.5, sec = self.dend[221]) h.pt3dadd(349, 440, 16, 1.5, sec = self.dend[221]) h.pt3dadd(350, 442.5, 14.5, 1.5, sec = self.dend[221]) h.pt3dadd(350, 445, 14.5, 1.6, sec = self.dend[221]) h.pt3dadd(350.5, 448, 16, 1.6, sec = self.dend[221]) h.pt3dadd(351.5, 448.5, 16, 1.6, sec = self.dend[221]) h.pt3dadd(353, 450.5, 16, 1.3, sec = self.dend[221]) h.pt3dadd(354, 453.5, 16, 0.7, sec = self.dend[221]) h.pt3dadd(354, 455.5, 16, 0.7, sec = self.dend[221]) h.pt3dadd(357, 458, 16, 0.7, sec = self.dend[221]) h.pt3dadd(357.5, 458, 16, 0.7, sec = self.dend[221]) h.pt3dadd(358, 459.5, 19, 1.3, sec = self.dend[221]) h.pt3dadd(359, 460, 19, 1.4, sec = self.dend[221]) h.pt3dadd(359, 462.5, 20.5, 1.7, sec = self.dend[221]) h.pt3dadd(360, 463, 20.5, 1.3, sec = self.dend[221]) h.pt3dadd(360.5, 465, 20.5, 1, sec = self.dend[221]) h.pt3dadd(360.5, 467, 20.5, 1.3, sec = self.dend[221]) h.pt3dadd(361, 469.5, 20.5, 1.5, sec = self.dend[221]) h.pt3dadd(361.5, 471.5, 20.5, 1.5, sec = self.dend[221]) h.pt3dadd(361.5, 473, 22, 1.5, sec = self.dend[221]) h.pt3dadd(361.5, 474.5, 22, 1.5, sec = self.dend[221]) h.pt3dadd(363.5, 478, 22, 1.5, sec = self.dend[221]) h.pt3dadd(363.5, 479, 22, 1.5, sec = self.dend[221]) h.pt3dadd(363.5, 480.5, 22, 0.9, sec = self.dend[221]) h.pt3dadd(366, 483, 22, 0.9, sec = self.dend[221]) h.pt3dadd(366, 484.5, 23.5, 1, sec = self.dend[221]) h.pt3dadd(368, 485.5, 23.5, 1.1, sec = self.dend[221]) h.pt3dadd(370, 490.5, 22, 1.5, sec = self.dend[221]) h.pt3dadd(371, 492, 22, 2, sec = self.dend[221]) h.pt3dadd(372, 494.5, 23.5, 2.6, sec = self.dend[221]) h.pt3dadd(375, 498, 23.5, 2.7, sec = self.dend[221]) h.pt3dadd(375, 499.5, 23.5, 2.7, sec = self.dend[221]) h.pt3dadd(376.5, 502, 24.5, 2, sec = self.dend[221]) h.pt3dadd(377.5, 503, 24.5, 1.7, sec = self.dend[221]) h.pt3dadd(377.5, 505, 24.5, 1.5, sec = self.dend[221]) h.pt3dadd(378, 507, 24.5, 1.2, sec = self.dend[221]) h.pt3dadd(379.5, 508.5, 24.5, 1.2, sec = self.dend[221]) h.pt3dadd(381.5, 510.5, 24.5, 1.3, sec = self.dend[221]) h.pt3dadd(383.5, 512.5, 24.5, 1.3, sec = self.dend[221]) h.pt3dadd(385, 512.5, 24.5, 1, sec = self.dend[221]) h.pt3dadd(386.5, 512.5, 23.5, 1, sec = self.dend[221]) h.pt3dadd(389, 514.5, 23.5, 1, sec = self.dend[221]) h.pt3dadd(391.5, 516, 23.5, 1, sec = self.dend[221]) h.pt3dadd(393, 518, 23.5, 1.3, sec = self.dend[221]) h.pt3dadd(393, 521, 24.5, 1.2, sec = self.dend[221]) h.pt3dadd(395, 523, 24.5, 1.2, sec = self.dend[221]) h.pt3dadd(395, 527.5, 24.5, 0.8, sec = self.dend[221]) h.pt3dadd(397, 528.5, 24.5, 1.1, sec = self.dend[221]) h.pt3dadd(397.5, 530.5, 24.5, 1.2, sec = self.dend[221]) h.pt3dadd(397.5, 533, 24.5, 0.9, sec = self.dend[221]) h.pt3dadd(399, 534, 24.5, 0.7, sec = self.dend[221]) h.pt3dadd(400, 536, 24.5, 0.7, sec = self.dend[221]) h.pt3dadd(400.5, 537, 26.5, 1.2, sec = self.dend[221]) h.pt3dadd(401.5, 537.5, 24.5, 1.7, sec = self.dend[221]) h.pt3dadd(402, 540.5, 24.5, 1.3, sec = self.dend[221]) h.pt3dadd(401.5, 542.5, 22.5, 1.1, sec = self.dend[221]) h.pt3dadd(400, 545.5, 24.5, 0.6, sec = self.dend[221]) h.pt3dadd(399.5, 548.5, 26.5, 0.9, sec = self.dend[221]) h.pt3dadd(399.5, 550.5, 26.5, 0.9, sec = self.dend[221]) h.pt3dadd(400, 551.5, 26.5, 1.1, sec = self.dend[221]) h.pt3dadd(400, 552.5, 26.5, 0.9, sec = self.dend[221]) h.pt3dadd(399.5, 554, 28, 0.8, sec = self.dend[221]) h.pt3dadd(399.5, 555, 28, 1.4, sec = self.dend[221]) h.pt3dadd(399, 555.5, 28, 1.8, sec = self.dend[221]) h.pt3dadd(398.5, 557.5, 28, 0.6, sec = self.dend[221]) h.pt3dadd(398.5, 558, 28, 0.6, sec = self.dend[221]) h.pt3dadd(398, 559.5, 26.5, 1, sec = self.dend[221]) h.pt3dadd(398, 560.5, 28, 1.6, sec = self.dend[221]) h.pt3dadd(397.5, 562.5, 28, 0.8, sec = self.dend[221]) h.pt3dadd(398, 562.5, 28, 0.6, sec = self.dend[221]) h.pt3dadd(399, 564.5, 28, 0.6, sec = self.dend[221]) h.pt3dadd(401, 566, 28, 0.6, sec = self.dend[221]) h.pt3dadd(401, 568, 28, 0.6, sec = self.dend[221]) h.pt3dadd(399.5, 569, 28, 1.8, sec = self.dend[221]) h.pt3dadd(399.5, 570.5, 28, 1.9, sec = self.dend[221]) h.pt3dadd(399, 572.5, 30, 1.4, sec = self.dend[221]) h.pt3dadd(398.5, 574, 31.5, 0.3, sec = self.dend[221]) h.pt3dadd(399.5, 575, 33.5, 0.3, sec = self.dend[221]) h.pt3dadd(401, 577, 33.5, 0.3, sec = self.dend[221]) h.pt3dadd(402.5, 579, 33.5, 0.4, sec = self.dend[221]) h.pt3dadd(402.5, 581.5, 33.5, 0.4, sec = self.dend[221]) h.pt3dadd(402.5, 583.5, 33.5, 0.4, sec = self.dend[221]) h.pt3dadd(403, 585.5, 30, 1.2, sec = self.dend[221]) h.pt3dadd(403, 586.5, 30, 1.4, sec = self.dend[221]) h.pt3dadd(405, 588, 30, 1.2, sec = self.dend[221]) h.pt3dadd(405.5, 590.5, 31.5, 2, sec = self.dend[221]) h.pt3dadd(407, 592, 33.5, 2.8, sec = self.dend[221]) h.pt3dadd(408, 593, 35, 1, sec = self.dend[221]) h.pt3dadd(408.5, 595, 37, 0.2, sec = self.dend[221]) h.pt3dadd(410.5, 596.5, 37, 0.2, sec = self.dend[221]) h.pt3dadd(411, 599, 39, 0.1, sec = self.dend[221]) h.pt3dadd(411, 601, 39, 0.1, sec = self.dend[221]) h.pt3dadd(412, 602.5, 31.5, 0.1, sec = self.dend[221]) h.pt3dadd(414, 604, 31.5, 0.1, sec = self.dend[221]) h.pt3dadd(414.5, 604.5, 31.5, 0.1, sec = self.dend[221]) h.pt3dadd(415, 606, 33.5, 1.1, sec = self.dend[221]) h.pt3dadd(416, 607, 35, 2, sec = self.dend[221]) h.pt3dadd(417, 609.5, 33.5, 0.3, sec = self.dend[221]) h.pt3dadd(417, 611, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(418.5, 613, 35, 0.1, sec = self.dend[221]) h.pt3dadd(419, 614.5, 35, 0.1, sec = self.dend[221]) h.pt3dadd(419, 617.5, 35, 0.1, sec = self.dend[221]) h.pt3dadd(419.5, 621.5, 35, 0.4, sec = self.dend[221]) h.pt3dadd(419.5, 624, 35, 0.7, sec = self.dend[221]) h.pt3dadd(420, 626.5, 35, 1.3, sec = self.dend[221]) h.pt3dadd(420, 627, 35, 1.7, sec = self.dend[221]) h.pt3dadd(420, 629, 35, 0.1, sec = self.dend[221]) h.pt3dadd(421, 630, 42.5, 0.1, sec = self.dend[221]) h.pt3dadd(423, 631, 42.5, 0.1, sec = self.dend[221]) h.pt3dadd(423, 633, 42.5, 0.1, sec = self.dend[221]) h.pt3dadd(423, 635, 42.5, 0.9, sec = self.dend[221]) h.pt3dadd(422.5, 635.5, 35, 1.2, sec = self.dend[221]) h.pt3dadd(421, 637.5, 39, 1.8, sec = self.dend[221]) h.pt3dadd(423.5, 640, 39, 0.1, sec = self.dend[221]) h.pt3dadd(426.5, 642.5, 39, 0.1, sec = self.dend[221]) h.pt3dadd(429.5, 647.5, 37, 0.1, sec = self.dend[221]) h.pt3dadd(430, 651, 35, 0.1, sec = self.dend[221]) h.pt3dadd(431, 656.5, 35, 0.1, sec = self.dend[221]) h.pt3dadd(431, 660, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(431, 663.5, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(430.5, 667, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(433.5, 668.5, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(436, 673.5, 33.5, 0.1, sec = self.dend[221]) h.pt3dadd(439, 675.5, 31.5, 0.1, sec = self.dend[221]) h.pt3dadd(443, 678, 35, 0.2, sec = self.dend[221]) h.pt3dadd(443.5, 678, 35, 0.2, sec = self.dend[221]) h.pt3dadd(444.5, 679, 42.5, 1.9, sec = self.dend[221]) h.pt3dadd(448, 680.5, 37, 0.3, sec = self.dend[221]) h.pt3dclear(sec = self.dend[222]) h.pt3dadd(250.5, 175, -1, 8.1, sec = self.dend[222]) h.pt3dadd(256.5, 177.5, -2, 5.6, sec = self.dend[222]) h.pt3dadd(262.5, 178, -3, 5.6, sec = self.dend[222]) h.pt3dadd(266, 180, -3, 5.6, sec = self.dend[222]) h.pt3dadd(268.5, 181.5, -4, 5.6, sec = self.dend[222]) h.pt3dadd(272, 183, -3, 5.7, sec = self.dend[222]) h.pt3dadd(279.5, 185.5, 2.5, 3.4, sec = self.dend[222]) h.pt3dadd(284.5, 187.5, 2.5, 3.4, sec = self.dend[222]) h.pt3dadd(288, 190.5, 2.5, 3.4, sec = self.dend[222]) h.pt3dadd(293, 191.5, 2.5, 3.4, sec = self.dend[222]) h.pt3dadd(298, 194, 2.5, 3.4, sec = self.dend[222]) h.pt3dadd(300.5, 194, 5.5, 4.3, sec = self.dend[222]) h.pt3dadd(305, 197.5, 5.5, 4.9, sec = self.dend[222]) h.pt3dadd(309, 198.5, 5.5, 5, sec = self.dend[222]) h.pt3dclear(sec = self.dend[223]) h.pt3dadd(309, 198.5, 5.5, 5, sec = self.dend[223]) h.pt3dadd(309, 202, 2.5, 1.6, sec = self.dend[223]) h.pt3dadd(310.5, 203.5, 2.5, 1.6, sec = self.dend[223]) h.pt3dadd(313, 204.5, 2.5, 1.4, sec = self.dend[223]) h.pt3dadd(314, 205.5, 2.5, 1.4, sec = self.dend[223]) h.pt3dadd(317.5, 206, 2.5, 1.4, sec = self.dend[223]) h.pt3dadd(317.5, 207.5, 2.5, 1.4, sec = self.dend[223]) h.pt3dadd(317.5, 209.5, 2.5, 1.4, sec = self.dend[223]) h.pt3dadd(319, 211, 2.5, 1.7, sec = self.dend[223]) h.pt3dadd(321, 213, 2.5, 1.8, sec = self.dend[223]) h.pt3dadd(321.5, 214.5, 2.5, 1.9, sec = self.dend[223]) h.pt3dadd(320.5, 214.5, 5.5, 2.5, sec = self.dend[223]) h.pt3dadd(318.5, 216, 8, 2.3, sec = self.dend[223]) h.pt3dadd(316, 217, 8, 1.6, sec = self.dend[223]) h.pt3dadd(314, 218.5, 8, 1.7, sec = self.dend[223]) h.pt3dadd(313, 220, 11, 1.7, sec = self.dend[223]) h.pt3dadd(313, 222.5, 33, 1.4, sec = self.dend[223]) h.pt3dclear(sec = self.dend[224]) h.pt3dadd(309, 198.5, 5.5, 5, sec = self.dend[224]) h.pt3dadd(313.5, 202.5, 5.5, 6.2, sec = self.dend[224]) h.pt3dadd(319, 204, 5.5, 6.1, sec = self.dend[224]) h.pt3dadd(324, 204.5, 5.5, 4.3, sec = self.dend[224]) h.pt3dadd(327.5, 205, 8, 4, sec = self.dend[224]) h.pt3dadd(330.5, 205, 5.5, 3.3, sec = self.dend[224]) h.pt3dadd(335, 206.5, 5.5, 3.3, sec = self.dend[224]) h.pt3dadd(339.5, 206.5, 5.5, 3.8, sec = self.dend[224]) h.pt3dadd(344, 207.5, 5.5, 3.8, sec = self.dend[224]) h.pt3dadd(348.5, 207.5, 5.5, 3.8, sec = self.dend[224]) h.pt3dadd(352.5, 208.5, 5.5, 4.7, sec = self.dend[224]) h.pt3dadd(356.5, 208.5, 5.5, 4.7, sec = self.dend[224]) h.pt3dadd(359.5, 210, 5.5, 5.2, sec = self.dend[224]) h.pt3dadd(364, 210, 2.5, 5.2, sec = self.dend[224]) h.pt3dadd(367, 209, 2.5, 4.9, sec = self.dend[224]) h.pt3dadd(369.5, 208, 2.5, 4.8, sec = self.dend[224]) h.pt3dadd(373.5, 208, 2.5, 4.8, sec = self.dend[224]) h.pt3dadd(379, 208, 2.5, 4.8, sec = self.dend[224]) h.pt3dadd(383.5, 208, 2.5, 4.1, sec = self.dend[224]) h.pt3dadd(386, 208, 2.5, 4.1, sec = self.dend[224]) h.pt3dadd(389.5, 208, 0, 4.1, sec = self.dend[224]) h.pt3dadd(394, 208, 0, 4, sec = self.dend[224]) h.pt3dadd(400, 208, 0, 4, sec = self.dend[224]) h.pt3dadd(403, 207, 2.5, 4.6, sec = self.dend[224]) h.pt3dadd(406, 206, -3, 4.4, sec = self.dend[224]) h.pt3dadd(409, 206, -3, 4.3, sec = self.dend[224]) h.pt3dadd(412.5, 204, -3, 4, sec = self.dend[224]) h.pt3dadd(415.5, 204.5, -3, 4.1, sec = self.dend[224]) h.pt3dadd(420.5, 205, -3, 4.3, sec = self.dend[224]) h.pt3dadd(422, 205, -3, 3.6, sec = self.dend[224]) h.pt3dadd(426, 205, -3, 3.6, sec = self.dend[224]) h.pt3dadd(430.5, 205, -3, 3.6, sec = self.dend[224]) h.pt3dadd(434, 205.5, -3, 3.6, sec = self.dend[224]) h.pt3dadd(438.5, 206.5, -3, 4.3, sec = self.dend[224]) h.pt3dadd(443, 209, -3, 4.2, sec = self.dend[224]) h.pt3dadd(447, 209, 0, 3.7, sec = self.dend[224]) h.pt3dadd(451.5, 209.5, 0, 3.8, sec = self.dend[224]) h.pt3dadd(455, 210, -5.5, 4.1, sec = self.dend[224]) h.pt3dadd(462.5, 211, -5.5, 4.1, sec = self.dend[224]) h.pt3dadd(467, 211, -5.5, 4.1, sec = self.dend[224]) h.pt3dadd(471, 213, -3, 4.1, sec = self.dend[224]) h.pt3dadd(475.5, 214.5, 0, 4.1, sec = self.dend[224]) h.pt3dadd(480, 214.5, -1, 7, sec = self.dend[224]) h.pt3dadd(488, 214.5, -3, 6.4, sec = self.dend[224]) h.pt3dadd(496.5, 217, -3, 6.1, sec = self.dend[224]) h.pt3dadd(500, 217, -4, 6.5, sec = self.dend[224]) h.pt3dadd(503, 217, -4, 6.5, sec = self.dend[224]) h.pt3dadd(505.5, 217, -4, 5.6, sec = self.dend[224]) h.pt3dadd(507.5, 217, -5, 5.2, sec = self.dend[224]) h.pt3dadd(510, 215, -3, 4.7, sec = self.dend[224]) h.pt3dadd(514, 215, -3, 4.5, sec = self.dend[224]) h.pt3dadd(518.5, 214.5, -4, 4.5, sec = self.dend[224]) h.pt3dadd(522, 215, -4, 4.5, sec = self.dend[224]) h.pt3dadd(525.5, 215, -4, 4.5, sec = self.dend[224]) h.pt3dadd(528.5, 217, -2, 4.8, sec = self.dend[224]) h.pt3dadd(532, 218.5, -3, 4.7, sec = self.dend[224]) h.pt3dadd(534, 218.5, -4, 4.7, sec = self.dend[224]) h.pt3dadd(538.5, 218, -4, 4.7, sec = self.dend[224]) h.pt3dadd(543, 218, -4, 4.7, sec = self.dend[224]) h.pt3dadd(546, 220, -6, 4.6, sec = self.dend[224]) h.pt3dadd(549, 220, -6, 4.6, sec = self.dend[224]) h.pt3dadd(553, 220, -6, 4, sec = self.dend[224]) h.pt3dadd(558, 220, -6, 3.8, sec = self.dend[224]) h.pt3dadd(561.5, 220, -7.5, 3.6, sec = self.dend[224]) h.pt3dadd(566, 220, -7.5, 3.6, sec = self.dend[224]) h.pt3dadd(569, 220, -7.5, 3.8, sec = self.dend[224]) h.pt3dadd(573, 220, -7.5, 4, sec = self.dend[224]) h.pt3dadd(577, 219.5, -6, 4, sec = self.dend[224]) h.pt3dadd(579.5, 219, -6, 4, sec = self.dend[224]) h.pt3dadd(583, 219.5, -7, 3.1, sec = self.dend[224]) h.pt3dadd(585, 219.5, -7, 3.6, sec = self.dend[224]) h.pt3dadd(587.5, 218.5, -7, 3.8, sec = self.dend[224]) h.pt3dadd(591, 218.5, -7, 3.8, sec = self.dend[224]) h.pt3dadd(593.5, 217.5, -7.5, 4.3, sec = self.dend[224]) h.pt3dadd(597, 219.5, -9.5, 4.8, sec = self.dend[224]) h.pt3dadd(600.5, 219.5, -9.5, 4.2, sec = self.dend[224]) h.pt3dadd(604, 218.5, -10.5, 4.2, sec = self.dend[224]) h.pt3dadd(607.5, 218.5, -10.5, 4.6, sec = self.dend[224]) h.pt3dadd(610, 218.5, -7, 5.2, sec = self.dend[224]) h.pt3dadd(614, 218.5, -7, 5.9, sec = self.dend[224]) h.pt3dadd(618, 218.5, -7, 5.9, sec = self.dend[224]) h.pt3dadd(621.5, 218.5, -8.5, 4.9, sec = self.dend[224]) h.pt3dadd(624.5, 219.5, -9.5, 5.2, sec = self.dend[224]) h.pt3dadd(627.5, 219.5, -7.5, 4.6, sec = self.dend[224]) h.pt3dadd(630, 221.5, -7.5, 3.8, sec = self.dend[224]) h.pt3dadd(633, 221.5, -9.5, 3.3, sec = self.dend[224]) h.pt3dadd(635, 221.5, -9.5, 3, sec = self.dend[224]) h.pt3dadd(637.5, 222.5, -9.5, 3.4, sec = self.dend[224]) h.pt3dadd(640, 223, -9.5, 3.1, sec = self.dend[224]) h.pt3dadd(642, 224, -9.5, 3, sec = self.dend[224]) h.pt3dadd(644.5, 224, -9.5, 3.2, sec = self.dend[224]) h.pt3dadd(647.5, 224, -10.5, 3.8, sec = self.dend[224]) h.pt3dadd(649, 222.5, -10.5, 3.7, sec = self.dend[224]) h.pt3dadd(652, 221.5, -10.5, 3.4, sec = self.dend[224]) h.pt3dadd(657, 220, -10.5, 3.4, sec = self.dend[224]) h.pt3dadd(659.5, 220, -7.5, 4.1, sec = self.dend[224]) h.pt3dadd(661.5, 222.5, -7.5, 4.5, sec = self.dend[224]) h.pt3dadd(666, 223, -7.5, 5.2, sec = self.dend[224]) h.pt3dadd(669, 223.5, -7.5, 5, sec = self.dend[224]) h.pt3dadd(672.5, 224.5, -7.5, 4.9, sec = self.dend[224]) h.pt3dadd(676.5, 225.5, -7.5, 4.9, sec = self.dend[224]) h.pt3dadd(678.5, 227, -7.5, 4.9, sec = self.dend[224]) h.pt3dadd(681.5, 228, -7.5, 5.2, sec = self.dend[224]) h.pt3dadd(684, 230, -7.5, 6.2, sec = self.dend[224]) h.pt3dadd(686.5, 233, -7.5, 4.1, sec = self.dend[224]) h.pt3dadd(687, 233, -7.5, 3.5, sec = self.dend[224]) h.pt3dadd(690, 234, -7.5, 4, sec = self.dend[224]) h.pt3dadd(693, 237, -7.5, 3.7, sec = self.dend[224]) h.pt3dadd(695.5, 237, -7.5, 3.3, sec = self.dend[224]) h.pt3dadd(697.5, 238, -6, 3.8, sec = self.dend[224]) h.pt3dadd(700, 238.5, -6, 4.4, sec = self.dend[224]) h.pt3dadd(704, 238.5, -6, 4.8, sec = self.dend[224]) h.pt3dadd(707.5, 240, -6, 5, sec = self.dend[224]) h.pt3dadd(711, 240, -6, 5.1, sec = self.dend[224]) h.pt3dadd(713.5, 240, -6, 5.1, sec = self.dend[224]) h.pt3dadd(715.5, 239, -7, 4.3, sec = self.dend[224]) h.pt3dadd(716.5, 238.5, -3, 3.6, sec = self.dend[224]) h.pt3dadd(720, 238, -3, 3.9, sec = self.dend[224]) h.pt3dclear(sec = self.dend[225]) h.pt3dadd(720, 238, -3, 3.9, sec = self.dend[225]) h.pt3dadd(725, 233.5, -6, 1.6, sec = self.dend[225]) h.pt3dadd(729.5, 233, -6, 1.6, sec = self.dend[225]) h.pt3dadd(732.5, 232, -6, 1.8, sec = self.dend[225]) h.pt3dadd(738, 231, -7, 1.1, sec = self.dend[225]) h.pt3dadd(742.5, 230, -7, 1.1, sec = self.dend[225]) h.pt3dadd(745, 228.5, -7, 1.3, sec = self.dend[225]) h.pt3dadd(748, 226, -7, 1.6, sec = self.dend[225]) h.pt3dclear(sec = self.dend[226]) h.pt3dadd(748, 226, -7, 1.6, sec = self.dend[226]) h.pt3dadd(748, 223.5, -6, 0.7, sec = self.dend[226]) h.pt3dadd(751.5, 219, -6, 0.7, sec = self.dend[226]) h.pt3dadd(754, 219, -6, 0.7, sec = self.dend[226]) h.pt3dadd(758.5, 219, -8.5, 0.9, sec = self.dend[226]) h.pt3dadd(761.5, 218, -7.5, 1.2, sec = self.dend[226]) h.pt3dadd(763.5, 217.5, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(765, 217.5, -7, 1.4, sec = self.dend[226]) h.pt3dadd(770, 218, -7.5, 1.4, sec = self.dend[226]) h.pt3dadd(773, 216, -7.5, 1.2, sec = self.dend[226]) h.pt3dadd(774.5, 215.5, -9.5, 1.2, sec = self.dend[226]) h.pt3dadd(777.5, 217.5, -9.5, 1.5, sec = self.dend[226]) h.pt3dadd(779, 217.5, -9.5, 1.3, sec = self.dend[226]) h.pt3dadd(782, 220.5, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(785.5, 220.5, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(790.5, 221.5, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(794, 221.5, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(797, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(800, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(804, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(808.5, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(815, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(817, 222, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(823.5, 222, -9.5, 1.3, sec = self.dend[226]) h.pt3dadd(826.5, 223.5, -9.5, 1.3, sec = self.dend[226]) h.pt3dadd(827.5, 223.5, -9.5, 1.2, sec = self.dend[226]) h.pt3dadd(829, 224.5, -9.5, 1.8, sec = self.dend[226]) h.pt3dadd(831, 224.5, -9.5, 2.4, sec = self.dend[226]) h.pt3dadd(832.5, 224.5, -9.5, 1.2, sec = self.dend[226]) h.pt3dadd(835.5, 224.5, -10.5, 0.4, sec = self.dend[226]) h.pt3dadd(837.5, 223.5, -10.5, 0.4, sec = self.dend[226]) h.pt3dadd(841, 223.5, -10.5, 0.4, sec = self.dend[226]) h.pt3dadd(842.5, 223, -11.5, 0.5, sec = self.dend[226]) h.pt3dadd(845, 222, -12, 0.5, sec = self.dend[226]) h.pt3dadd(847.5, 221, -11.5, 0.5, sec = self.dend[226]) h.pt3dadd(850, 220, -11.5, 0.5, sec = self.dend[226]) h.pt3dadd(851.5, 220, -11.5, 1, sec = self.dend[226]) h.pt3dadd(853, 220, -10.5, 1.3, sec = self.dend[226]) h.pt3dadd(856, 220, -10.5, 1.7, sec = self.dend[226]) h.pt3dadd(858.5, 220, -10.5, 1.7, sec = self.dend[226]) h.pt3dadd(859.5, 220, -12, 0.6, sec = self.dend[226]) h.pt3dadd(862.5, 222, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(865, 223.5, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(867, 222, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(869.5, 223, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(871, 223, -9.5, 1.2, sec = self.dend[226]) h.pt3dadd(872.5, 221.5, -9.5, 2, sec = self.dend[226]) h.pt3dadd(874.5, 221.5, -10.5, 1, sec = self.dend[226]) h.pt3dadd(877, 221.5, -9.5, 0.3, sec = self.dend[226]) h.pt3dadd(878.5, 221, -8.5, 0.3, sec = self.dend[226]) h.pt3dadd(879.5, 220.5, -8.5, 1.2, sec = self.dend[226]) h.pt3dadd(880.5, 220, -8.5, 1.6, sec = self.dend[226]) h.pt3dadd(882, 218, -8.5, 2.1, sec = self.dend[226]) h.pt3dadd(885.5, 219, -8.5, 1.2, sec = self.dend[226]) h.pt3dadd(887, 219, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(890, 219, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(891, 219, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(893, 219, -9.5, 1.7, sec = self.dend[226]) h.pt3dadd(894.5, 219, -9.5, 2.2, sec = self.dend[226]) h.pt3dadd(897, 219, -9.5, 0.6, sec = self.dend[226]) h.pt3dadd(900, 219, -10.5, 0.5, sec = self.dend[226]) h.pt3dadd(902, 219.5, -10.5, 0.5, sec = self.dend[226]) h.pt3dadd(904, 219.5, -7.5, 1.3, sec = self.dend[226]) h.pt3dadd(906, 219.5, -7.5, 0.3, sec = self.dend[226]) h.pt3dadd(908.5, 221, -8.5, 0.3, sec = self.dend[226]) h.pt3dadd(909.5, 221, -8.5, 1.7, sec = self.dend[226]) h.pt3dadd(911.5, 219.5, -7, 1.3, sec = self.dend[226]) h.pt3dadd(913, 219.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(915, 219.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(915.5, 219, -5, 1.6, sec = self.dend[226]) h.pt3dadd(917, 218.5, -5, 2, sec = self.dend[226]) h.pt3dadd(918.5, 218.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(920.5, 218.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(924, 218.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(925.5, 219, -6, 1.6, sec = self.dend[226]) h.pt3dadd(926, 219, -7, 1.8, sec = self.dend[226]) h.pt3dadd(927.5, 219.5, -7.5, 0.7, sec = self.dend[226]) h.pt3dadd(928, 220.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(928.5, 220.5, -7.5, 0.2, sec = self.dend[226]) h.pt3dadd(931, 219, -7, 1.8, sec = self.dend[226]) h.pt3dadd(933.5, 219, -8.5, 0.3, sec = self.dend[226]) h.pt3dadd(936.5, 218, -9.5, 0.3, sec = self.dend[226]) h.pt3dadd(940.5, 217.5, -7.5, 0.3, sec = self.dend[226]) h.pt3dadd(942.5, 216, -3, 1.4, sec = self.dend[226]) h.pt3dadd(943.5, 216, -3, 1.8, sec = self.dend[226]) h.pt3dadd(946, 215.5, -2, 1.2, sec = self.dend[226]) h.pt3dadd(947, 215.5, -2, 0.3, sec = self.dend[226]) h.pt3dadd(950.5, 212.5, -2, 0.3, sec = self.dend[226]) h.pt3dadd(952.5, 213, -2, 1.7, sec = self.dend[226]) h.pt3dadd(955, 213, -2, 2.8, sec = self.dend[226]) h.pt3dadd(956.5, 213, -2, 1.5, sec = self.dend[226]) h.pt3dadd(959, 213, -2, 0.3, sec = self.dend[226]) h.pt3dadd(963.5, 214.5, -3, 0.3, sec = self.dend[226]) h.pt3dadd(966.5, 214.5, -3, 0.3, sec = self.dend[226]) h.pt3dadd(967.5, 211.5, -2, 0.3, sec = self.dend[226]) h.pt3dadd(969.5, 211.5, -2, 1.6, sec = self.dend[226]) h.pt3dadd(971, 211, -2, 2, sec = self.dend[226]) h.pt3dadd(973, 211, -3, 0.5, sec = self.dend[226]) h.pt3dadd(976.5, 211, -3, 0.5, sec = self.dend[226]) h.pt3dadd(978, 210, -2, 1.7, sec = self.dend[226]) h.pt3dadd(978.5, 209, -2, 2.1, sec = self.dend[226]) h.pt3dadd(980, 209, -3, 0.1, sec = self.dend[226]) h.pt3dadd(984, 209, -2, 0.2, sec = self.dend[226]) h.pt3dadd(986.5, 208, -2, 0.5, sec = self.dend[226]) h.pt3dadd(988.5, 206, -2, 0.7, sec = self.dend[226]) h.pt3dadd(990, 206, -2, 0.7, sec = self.dend[226]) h.pt3dadd(993.5, 205.5, -2, 0.7, sec = self.dend[226]) h.pt3dadd(995.5, 202, -2, 0.7, sec = self.dend[226]) h.pt3dadd(997.5, 200.5, -4, 0.7, sec = self.dend[226]) h.pt3dadd(999, 199, -4, 0.7, sec = self.dend[226]) h.pt3dadd(1001, 198, -5, 0.7, sec = self.dend[226]) h.pt3dadd(1003, 195, -5, 0.7, sec = self.dend[226]) h.pt3dadd(1006, 195, -6, 0.7, sec = self.dend[226]) h.pt3dadd(1011, 193, -5, 0.7, sec = self.dend[226]) h.pt3dadd(1013, 189.5, -5, 0.7, sec = self.dend[226]) h.pt3dadd(1016, 188.5, -5, 0.7, sec = self.dend[226]) h.pt3dadd(1016.5, 186.5, -6, 0.6, sec = self.dend[226]) h.pt3dadd(1017.5, 186.5, -6, 0.6, sec = self.dend[226]) h.pt3dadd(1022.5, 185, -7, 0.6, sec = self.dend[226]) h.pt3dadd(1024.5, 182, -6, 0.1, sec = self.dend[226]) h.pt3dadd(1026, 182, -5, 2, sec = self.dend[226]) h.pt3dadd(1027, 180, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1030, 179, -6, 0.1, sec = self.dend[226]) h.pt3dadd(1033.5, 179, -4, 3.1, sec = self.dend[226]) h.pt3dadd(1034, 176, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1034.5, 174.5, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1034.5, 171.5, -5, 1.2, sec = self.dend[226]) h.pt3dadd(1035, 170.5, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1033, 168.5, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1034.5, 168.5, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1035.5, 165.5, -8.5, 1.8, sec = self.dend[226]) h.pt3dadd(1036.5, 164, -7, 0.4, sec = self.dend[226]) h.pt3dadd(1037.5, 161.5, -7, 1.1, sec = self.dend[226]) h.pt3dadd(1036.5, 159.5, -7, 0.2, sec = self.dend[226]) h.pt3dadd(1039.5, 159.5, -3, 0.3, sec = self.dend[226]) h.pt3dadd(1041.5, 159, -2, 0.2, sec = self.dend[226]) h.pt3dadd(1045.5, 157, -2, 0.1, sec = self.dend[226]) h.pt3dadd(1046.5, 156, -2, 0.1, sec = self.dend[226]) h.pt3dadd(1047.5, 154, -2, 1.6, sec = self.dend[226]) h.pt3dadd(1050.5, 153, -3, 0.3, sec = self.dend[226]) h.pt3dadd(1051.5, 151.5, -3, 0.3, sec = self.dend[226]) h.pt3dadd(1053.5, 150.5, -3, 0.3, sec = self.dend[226]) h.pt3dadd(1053.5, 148.5, -4, 1.5, sec = self.dend[226]) h.pt3dadd(1054.5, 146, -4, 0.2, sec = self.dend[226]) h.pt3dadd(1055, 143.5, -4, 0.1, sec = self.dend[226]) h.pt3dadd(1057, 141, -4, 0.1, sec = self.dend[226]) h.pt3dadd(1056.5, 140.5, -2, 1.1, sec = self.dend[226]) h.pt3dadd(1058.5, 139, -1, 0.1, sec = self.dend[226]) h.pt3dadd(1058.5, 138, -1, 0.1, sec = self.dend[226]) h.pt3dadd(1060.5, 135.5, -1, 1.2, sec = self.dend[226]) h.pt3dadd(1062.5, 134.5, -3, 0.1, sec = self.dend[226]) h.pt3dadd(1065.5, 134, -3, 0.1, sec = self.dend[226]) h.pt3dadd(1069, 132.5, -3, 0.1, sec = self.dend[226]) h.pt3dadd(1070.5, 131, -2, 1.3, sec = self.dend[226]) h.pt3dadd(1072.5, 130, -6, 0.1, sec = self.dend[226]) h.pt3dadd(1073, 130, -6, 0.1, sec = self.dend[226]) h.pt3dadd(1075.5, 130, -2, 1.2, sec = self.dend[226]) h.pt3dadd(1076.5, 130, -4, 0.1, sec = self.dend[226]) h.pt3dadd(1078.5, 130, -4, 0.1, sec = self.dend[226]) h.pt3dadd(1079.5, 130, -4, 1.3, sec = self.dend[226]) h.pt3dadd(1079.5, 130, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1082, 130, -5, 0.1, sec = self.dend[226]) h.pt3dadd(1084.5, 130, -4, 1.2, sec = self.dend[226]) h.pt3dadd(1086, 130, -7, 0.1, sec = self.dend[226]) h.pt3dadd(1086, 130.5, -4, 0.9, sec = self.dend[226]) h.pt3dadd(1088, 132.5, -4, 0.6, sec = self.dend[226]) h.pt3dadd(1089.5, 132.5, -4, 0.6, sec = self.dend[226]) h.pt3dadd(1090, 134.5, -6, 0.1, sec = self.dend[226]) h.pt3dadd(1092, 134.5, -7, 0.1, sec = self.dend[226]) h.pt3dadd(1092.5, 135, -3, 0.8, sec = self.dend[226]) h.pt3dadd(1094, 136, -7, 0.1, sec = self.dend[226]) h.pt3dadd(1096.5, 136.5, -3, 0.1, sec = self.dend[226]) h.pt3dadd(1098.5, 136, -2, 1, sec = self.dend[226]) h.pt3dadd(1100, 135, -7, 0.1, sec = self.dend[226]) h.pt3dadd(1101, 135, -1, 0.1, sec = self.dend[226]) h.pt3dadd(1103.5, 136, -1, 1.2, sec = self.dend[226]) h.pt3dadd(1106, 136, -4, 0.1, sec = self.dend[226]) h.pt3dadd(1105.5, 135.5, -2, 0.1, sec = self.dend[226]) h.pt3dclear(sec = self.dend[227]) h.pt3dadd(748, 226, -7, 1.6, sec = self.dend[227]) h.pt3dadd(749.5, 226.5, -7.5, 0.5, sec = self.dend[227]) h.pt3dadd(752, 230.5, -8.5, 0.5, sec = self.dend[227]) h.pt3dadd(755.5, 231, -8.5, 0.5, sec = self.dend[227]) h.pt3dadd(757, 233.5, -8.5, 0.7, sec = self.dend[227]) h.pt3dadd(757, 235, -7, 1.3, sec = self.dend[227]) h.pt3dadd(759, 234, -9.5, 0.8, sec = self.dend[227]) h.pt3dadd(762.5, 234, -12, 0.8, sec = self.dend[227]) h.pt3dadd(763.5, 234, -11.5, 0.8, sec = self.dend[227]) h.pt3dclear(sec = self.dend[228]) h.pt3dadd(763.5, 234, -11.5, 0.8, sec = self.dend[228]) h.pt3dadd(766.5, 233, -15, 0.1, sec = self.dend[228]) h.pt3dadd(767.5, 235.5, -14, 0.1, sec = self.dend[228]) h.pt3dadd(769, 235.5, -14, 0.1, sec = self.dend[228]) h.pt3dadd(770, 235.5, -14, 0.1, sec = self.dend[228]) h.pt3dadd(772.5, 234.5, -14, 0.1, sec = self.dend[228]) h.pt3dadd(776, 234.5, -14, 0.1, sec = self.dend[228]) h.pt3dadd(778, 233.5, -16, 0.1, sec = self.dend[228]) h.pt3dadd(781, 234.5, -16, 0.1, sec = self.dend[228]) h.pt3dadd(782.5, 233, -16, 0.1, sec = self.dend[228]) h.pt3dadd(786, 233, -17, 0.1, sec = self.dend[228]) h.pt3dadd(787.5, 232.5, -17, 0.9, sec = self.dend[228]) h.pt3dadd(788.5, 232.5, -17, 1.3, sec = self.dend[228]) h.pt3dadd(791, 233, -17, 0.1, sec = self.dend[228]) h.pt3dadd(792.5, 233, -17, 0.1, sec = self.dend[228]) h.pt3dadd(793.5, 231.5, -16, 0.7, sec = self.dend[228]) h.pt3dadd(795.5, 231, -19.5, 0.1, sec = self.dend[228]) h.pt3dadd(796.5, 231, -19.5, 0.1, sec = self.dend[228]) h.pt3dadd(797, 231, -17, 0.9, sec = self.dend[228]) h.pt3dadd(801, 231.5, -18.5, 0.1, sec = self.dend[228]) h.pt3dadd(804, 232, -18.5, 0.1, sec = self.dend[228]) h.pt3dadd(804.5, 232, -17, 1.1, sec = self.dend[228]) h.pt3dadd(807.5, 232.5, -18.5, 0.1, sec = self.dend[228]) h.pt3dadd(808.5, 232.5, -17, 0.1, sec = self.dend[228]) h.pt3dadd(810, 232.5, -17, 1.5, sec = self.dend[228]) h.pt3dadd(812, 232.5, -17, 0.1, sec = self.dend[228]) h.pt3dadd(813.5, 232.5, -17, 0.1, sec = self.dend[228]) h.pt3dadd(816, 233, -17, 1.3, sec = self.dend[228]) h.pt3dadd(817.5, 232.5, -19.5, 0.1, sec = self.dend[228]) h.pt3dadd(819, 231.5, -19.5, 0.1, sec = self.dend[228]) h.pt3dadd(821.5, 231, -19.5, 0.8, sec = self.dend[228]) h.pt3dadd(823, 231.5, -19.5, 0.5, sec = self.dend[228]) h.pt3dadd(824, 231.5, -19.5, 0.9, sec = self.dend[228]) h.pt3dadd(826.5, 231.5, -19.5, 1.4, sec = self.dend[228]) h.pt3dadd(827.5, 231.5, -19.5, 0.4, sec = self.dend[228]) h.pt3dadd(828.5, 231.5, -19.5, 0.1, sec = self.dend[228]) h.pt3dadd(830.5, 229, -18.5, 0.1, sec = self.dend[228]) h.pt3dclear(sec = self.dend[229]) h.pt3dadd(763.5, 234, -11.5, 0.8, sec = self.dend[229]) h.pt3dadd(769.5, 234, -11.5, 2.8, sec = self.dend[229]) h.pt3dadd(771.5, 233.5, -11.5, 2.3, sec = self.dend[229]) h.pt3dadd(773, 233, -14, 2.5, sec = self.dend[229]) h.pt3dadd(775, 233, -14, 2.9, sec = self.dend[229]) h.pt3dadd(777, 232.5, -11.5, 3.3, sec = self.dend[229]) h.pt3dadd(779, 230, -3, 4, sec = self.dend[229]) h.pt3dadd(783, 230, -14, 4, sec = self.dend[229]) h.pt3dadd(786, 230, -14, 3.4, sec = self.dend[229]) h.pt3dadd(788, 229.5, -14, 3.3, sec = self.dend[229]) h.pt3dadd(791, 229, -14, 2.8, sec = self.dend[229]) h.pt3dadd(793, 229.5, -14, 2.5, sec = self.dend[229]) h.pt3dadd(795, 229.5, -17, 2.6, sec = self.dend[229]) h.pt3dadd(797.5, 228.5, -14, 3.2, sec = self.dend[229]) h.pt3dadd(798, 226.5, -14, 3.2, sec = self.dend[229]) h.pt3dadd(801, 229.5, -8.5, 2.6, sec = self.dend[229]) h.pt3dadd(804, 230, -8.5, 3.3, sec = self.dend[229]) h.pt3dadd(805.5, 232.5, -14, 3.6, sec = self.dend[229]) h.pt3dadd(808, 232.5, -14, 3.2, sec = self.dend[229]) h.pt3dadd(811, 235.5, -5.5, 3.2, sec = self.dend[229]) h.pt3dadd(814.5, 235.5, -5.5, 3.2, sec = self.dend[229]) h.pt3dadd(817, 236.5, -3, 2.5, sec = self.dend[229]) h.pt3dadd(821.5, 238.5, -5.5, 2.8, sec = self.dend[229]) h.pt3dadd(824, 240, -5.5, 3.3, sec = self.dend[229]) h.pt3dadd(826, 241, -5.5, 3.8, sec = self.dend[229]) h.pt3dadd(829, 242, -8.5, 5.5, sec = self.dend[229]) h.pt3dclear(sec = self.dend[230]) h.pt3dadd(829, 242, -8.5, 5.5, sec = self.dend[230]) h.pt3dadd(830.5, 237.5, -11.5, 3.1, sec = self.dend[230]) h.pt3dadd(833.5, 236.5, -14, 2.3, sec = self.dend[230]) h.pt3dadd(841.5, 233, -8.5, 2.6, sec = self.dend[230]) h.pt3dadd(847.5, 231.5, -8.5, 2.6, sec = self.dend[230]) h.pt3dadd(849.5, 230.5, -5.5, 1.8, sec = self.dend[230]) h.pt3dadd(852, 228.5, -8.5, 3.1, sec = self.dend[230]) h.pt3dadd(854.5, 228.5, -8.5, 1.5, sec = self.dend[230]) h.pt3dclear(sec = self.dend[231]) h.pt3dadd(829, 242, -8.5, 5.5, sec = self.dend[231]) h.pt3dadd(831.5, 247, -5.5, 1.2, sec = self.dend[231]) h.pt3dadd(834, 248.5, -5.5, 1.3, sec = self.dend[231]) h.pt3dadd(836, 251, -5.5, 1.6, sec = self.dend[231]) h.pt3dadd(837, 253, -5.5, 1.5, sec = self.dend[231]) h.pt3dadd(837.5, 253.5, -3, 1.2, sec = self.dend[231]) h.pt3dadd(839.5, 254.5, -3, 1.5, sec = self.dend[231]) h.pt3dadd(841.5, 256.5, 0, 2, sec = self.dend[231]) h.pt3dadd(843, 258.5, 0, 2.4, sec = self.dend[231]) h.pt3dadd(844.5, 259, 0, 1.6, sec = self.dend[231]) h.pt3dadd(846.5, 260.5, 0, 1.5, sec = self.dend[231]) h.pt3dadd(848.5, 262, 0, 1.4, sec = self.dend[231]) h.pt3dadd(851, 264.5, -3, 1.5, sec = self.dend[231]) h.pt3dadd(853, 265.5, -3, 1.7, sec = self.dend[231]) h.pt3dadd(855, 267.5, -3, 1.8, sec = self.dend[231]) h.pt3dadd(857.5, 267.5, 0, 2.2, sec = self.dend[231]) h.pt3dadd(860, 267.5, 0, 2.5, sec = self.dend[231]) h.pt3dadd(862, 267.5, 0, 2.8, sec = self.dend[231]) h.pt3dadd(864.5, 267.5, 0, 2.8, sec = self.dend[231]) h.pt3dadd(866.5, 268, 0, 2.8, sec = self.dend[231]) h.pt3dadd(868, 269, 0, 1.3, sec = self.dend[231]) h.pt3dadd(871, 269, 0, 1.6, sec = self.dend[231]) h.pt3dadd(872.5, 268, 0, 2.4, sec = self.dend[231]) h.pt3dadd(875.5, 269, 2.5, 1.6, sec = self.dend[231]) h.pt3dadd(877.5, 268.5, 2.5, 0.9, sec = self.dend[231]) h.pt3dadd(881, 268, 0, 0.9, sec = self.dend[231]) h.pt3dadd(885, 268, 0, 0.9, sec = self.dend[231]) h.pt3dadd(886, 267.5, 0, 1.3, sec = self.dend[231]) h.pt3dadd(889.5, 267, -3, 1.1, sec = self.dend[231]) h.pt3dadd(892.5, 267, -3, 1.1, sec = self.dend[231]) h.pt3dadd(896, 264, 0, 1.3, sec = self.dend[231]) h.pt3dadd(899.5, 262.5, 0, 1.3, sec = self.dend[231]) h.pt3dadd(902, 261.5, -3, 1.6, sec = self.dend[231]) h.pt3dadd(904, 261.5, -3, 1.1, sec = self.dend[231]) h.pt3dadd(907.5, 260.5, 2.5, 1.1, sec = self.dend[231]) h.pt3dadd(910.5, 259.5, 0, 1.1, sec = self.dend[231]) h.pt3dadd(913.5, 259, 0, 1.1, sec = self.dend[231]) h.pt3dadd(917, 258.5, 0, 1.1, sec = self.dend[231]) h.pt3dadd(919, 256.5, 0, 1.1, sec = self.dend[231]) h.pt3dadd(922.5, 256.5, 0, 1.3, sec = self.dend[231]) h.pt3dadd(926, 256.5, 0, 1.3, sec = self.dend[231]) h.pt3dadd(926, 255, 0, 1.3, sec = self.dend[231]) h.pt3dadd(930, 254, -5.5, 1.3, sec = self.dend[231]) h.pt3dadd(934, 252.5, -5.5, 1.3, sec = self.dend[231]) h.pt3dadd(936.5, 253, -5.5, 1.2, sec = self.dend[231]) h.pt3dadd(940, 253, -5.5, 1.2, sec = self.dend[231]) h.pt3dadd(942.5, 253, -5.5, 1.5, sec = self.dend[231]) h.pt3dadd(945, 251.5, -5.5, 1.5, sec = self.dend[231]) h.pt3dadd(947, 249.5, -5.5, 1.5, sec = self.dend[231]) h.pt3dadd(951.5, 249, -5.5, 1.5, sec = self.dend[231]) h.pt3dadd(954.5, 247.5, -5.5, 1.3, sec = self.dend[231]) h.pt3dadd(956.5, 247.5, -5.5, 1.4, sec = self.dend[231]) h.pt3dadd(959.5, 245, -8.5, 1.6, sec = self.dend[231]) h.pt3dadd(961.5, 244, -8.5, 1.7, sec = self.dend[231]) h.pt3dadd(964, 242.5, -8.5, 1.3, sec = self.dend[231]) h.pt3dadd(967, 241.5, -8.5, 1.1, sec = self.dend[231]) h.pt3dadd(970, 238, -11.5, 1.1, sec = self.dend[231]) h.pt3dadd(972, 238, -11.5, 1.1, sec = self.dend[231]) h.pt3dadd(973.5, 238, -11.5, 1.9, sec = self.dend[231]) h.pt3dadd(976, 236, -11.5, 2.7, sec = self.dend[231]) h.pt3dadd(979, 236, -11.5, 2, sec = self.dend[231]) h.pt3dadd(981.5, 235, -11.5, 1, sec = self.dend[231]) h.pt3dadd(983.5, 235, -11.5, 1, sec = self.dend[231]) h.pt3dadd(985.5, 234, -5.5, 1.6, sec = self.dend[231]) h.pt3dadd(987, 233.5, -8.5, 1.9, sec = self.dend[231]) h.pt3dadd(989.5, 232, -8.5, 1.9, sec = self.dend[231]) h.pt3dadd(991.5, 230.5, -8.5, 0.8, sec = self.dend[231]) h.pt3dadd(997.5, 231, -8.5, 1.2, sec = self.dend[231]) h.pt3dadd(1001, 231, -11.5, 1.2, sec = self.dend[231]) h.pt3dadd(1005, 231, -11.5, 1.2, sec = self.dend[231]) h.pt3dadd(1008.5, 231, -11.5, 1.2, sec = self.dend[231]) h.pt3dadd(1010, 230, -11.5, 0.8, sec = self.dend[231]) h.pt3dadd(1016, 231.5, -14, 0.7, sec = self.dend[231]) h.pt3dadd(1017.5, 231, -14, 0.7, sec = self.dend[231]) h.pt3dadd(1020.5, 230.5, -14, 1.3, sec = self.dend[231]) h.pt3dadd(1022.5, 228, -11.5, 1.5, sec = self.dend[231]) h.pt3dadd(1026, 226.5, -11.5, 1.4, sec = self.dend[231]) h.pt3dadd(1028.5, 226.5, -19.5, 0.8, sec = self.dend[231]) h.pt3dadd(1032, 225, -14, 0.7, sec = self.dend[231]) h.pt3dadd(1037.5, 223, -14, 0.7, sec = self.dend[231]) h.pt3dadd(1038.5, 222, -14, 0.7, sec = self.dend[231]) h.pt3dadd(1042.5, 221.5, -14, 0.9, sec = self.dend[231]) h.pt3dadd(1045.5, 218.5, -14, 0.9, sec = self.dend[231]) h.pt3dadd(1054.5, 218, -14, 0.9, sec = self.dend[231]) h.pt3dadd(1059.5, 218, -14, 0.9, sec = self.dend[231]) h.pt3dadd(1062, 217.5, -14, 0.9, sec = self.dend[231]) h.pt3dadd(1069.5, 213.5, -17, 0.9, sec = self.dend[231]) h.pt3dclear(sec = self.dend[232]) h.pt3dadd(720, 238, -3, 3.9, sec = self.dend[232]) h.pt3dadd(724, 237.5, -2, 3.3, sec = self.dend[232]) h.pt3dadd(728.5, 236, -5, 4, sec = self.dend[232]) h.pt3dadd(733, 236, -5, 4, sec = self.dend[232]) h.pt3dadd(735.5, 234.5, -2, 3.5, sec = self.dend[232]) h.pt3dadd(739.5, 234, -1, 3.8, sec = self.dend[232]) h.pt3dadd(742, 233, 0, 3.7, sec = self.dend[232]) h.pt3dadd(745, 233, -1, 3.8, sec = self.dend[232]) h.pt3dadd(749.5, 230.5, -1, 3.6, sec = self.dend[232]) h.pt3dadd(751, 229.5, -1, 3.9, sec = self.dend[232]) h.pt3dadd(755, 226.5, 1, 4.4, sec = self.dend[232]) h.pt3dclear(sec = self.dend[233]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[233]) h.pt3dadd(72, 43, -17.5, 6.2, sec = self.dend[233]) h.pt3dadd(74, 40, -17.5, 6.1, sec = self.dend[233]) h.pt3dadd(76, 38, -16.5, 8.2, sec = self.dend[233]) h.pt3dadd(78.5, 36, -17.5, 8.2, sec = self.dend[233]) h.pt3dadd(80.5, 32.5, -18.5, 7.1, sec = self.dend[233]) h.pt3dadd(84, 29, -19.5, 7.3, sec = self.dend[233]) h.pt3dadd(87, 23.5, -18.5, 7.4, sec = self.dend[233]) h.pt3dadd(86, 22, -18.5, 7.4, sec = self.dend[233]) h.pt3dadd(85.5, 18, -22, 7.4, sec = self.dend[233]) h.pt3dadd(87.5, 16, -20.5, 7.4, sec = self.dend[233]) h.pt3dadd(89, 12.5, -19.5, 7.4, sec = self.dend[233]) h.pt3dadd(89.5, 9.5, -20.5, 6.3, sec = self.dend[233]) h.pt3dadd(89.5, 8.5, -22, 6.5, sec = self.dend[233]) h.pt3dadd(91.5, 5.5, -22, 5.7, sec = self.dend[233]) h.pt3dadd(92.5, 5, -24, 6.3, sec = self.dend[233]) h.pt3dadd(95, 2.5, -25, 5.9, sec = self.dend[233]) h.pt3dadd(98.5, 1.5, -26.5, 6.5, sec = self.dend[233]) h.pt3dadd(102, -0.5, -26.5, 6.5, sec = self.dend[233]) h.pt3dadd(103.5, -2.5, -26.5, 7.4, sec = self.dend[233]) h.pt3dadd(106.5, -2.5, -26.5, 7.8, sec = self.dend[233]) h.pt3dadd(112.5, -5, -28.5, 7.9, sec = self.dend[233]) h.pt3dadd(115, -5.5, -26.5, 7.9, sec = self.dend[233]) h.pt3dadd(118.5, -7.5, -26.5, 8.2, sec = self.dend[233]) h.pt3dadd(122, -7, -26.5, 8.2, sec = self.dend[233]) h.pt3dadd(126.5, -8, -27.5, 7.8, sec = self.dend[233]) h.pt3dadd(129, -9, -29.5, 7.8, sec = self.dend[233]) h.pt3dadd(135.5, -9, -30.5, 5.3, sec = self.dend[233]) h.pt3dadd(141, -9, -31, 5.3, sec = self.dend[233]) h.pt3dadd(146, -11.5, -29.5, 4.6, sec = self.dend[233]) h.pt3dadd(148.5, -11.5, -29.5, 4.4, sec = self.dend[233]) h.pt3dadd(152, -9.5, -30.5, 4.9, sec = self.dend[233]) h.pt3dadd(156.5, -9.5, -31, 5.7, sec = self.dend[233]) h.pt3dadd(161, -9.5, -31, 5.2, sec = self.dend[233]) h.pt3dadd(163.5, -9.5, -31, 5.2, sec = self.dend[233]) h.pt3dadd(165.5, -9.5, -31, 5.3, sec = self.dend[233]) h.pt3dadd(169, -9.5, -31, 8.8, sec = self.dend[233]) h.pt3dclear(sec = self.dend[234]) h.pt3dadd(169, -9.5, -31, 8.8, sec = self.dend[234]) h.pt3dadd(167, -14, -29.5, 3.2, sec = self.dend[234]) h.pt3dadd(172.5, -16.5, -29.5, 3.4, sec = self.dend[234]) h.pt3dadd(176, -18.5, -29.5, 4.5, sec = self.dend[234]) h.pt3dadd(178, -21.5, -31.5, 3.6, sec = self.dend[234]) h.pt3dadd(181.5, -21.5, -31.5, 3.4, sec = self.dend[234]) h.pt3dadd(184.5, -23.5, -29, 3.8, sec = self.dend[234]) h.pt3dadd(188, -26, -31, 4.6, sec = self.dend[234]) h.pt3dadd(192, -26, -31, 4.7, sec = self.dend[234]) h.pt3dadd(196.5, -29, -31.5, 4.7, sec = self.dend[234]) h.pt3dadd(200, -30, -32.5, 4.6, sec = self.dend[234]) h.pt3dadd(203.5, -31, -31.5, 4.6, sec = self.dend[234]) h.pt3dadd(207, -34, -31.5, 4.2, sec = self.dend[234]) h.pt3dadd(209, -34, -31, 4.3, sec = self.dend[234]) h.pt3dadd(210.5, -36.5, -31, 4.9, sec = self.dend[234]) h.pt3dclear(sec = self.dend[235]) h.pt3dadd(210.5, -36.5, -31, 4.9, sec = self.dend[235]) h.pt3dadd(218.5, -38, -31, 2.3, sec = self.dend[235]) h.pt3dadd(222.5, -38, -31, 2.3, sec = self.dend[235]) h.pt3dadd(226, -41.5, -31, 2.5, sec = self.dend[235]) h.pt3dadd(227.5, -46, -31, 2.8, sec = self.dend[235]) h.pt3dadd(231, -50, -31.5, 2.8, sec = self.dend[235]) h.pt3dadd(232.5, -51.5, -31, 2.2, sec = self.dend[235]) h.pt3dadd(234.5, -54.5, -31, 2.2, sec = self.dend[235]) h.pt3dadd(236, -56.5, -31, 3.7, sec = self.dend[235]) h.pt3dadd(238.5, -58, -32.5, 4.1, sec = self.dend[235]) h.pt3dadd(240.5, -59, -32.5, 4.5, sec = self.dend[235]) h.pt3dadd(244, -61.5, -31.5, 3.8, sec = self.dend[235]) h.pt3dadd(247.5, -62, -31.5, 4.6, sec = self.dend[235]) h.pt3dadd(251, -63.5, -32.5, 6, sec = self.dend[235]) h.pt3dadd(254, -65, -33.5, 6.5, sec = self.dend[235]) h.pt3dclear(sec = self.dend[236]) h.pt3dadd(254, -65, -33.5, 6.5, sec = self.dend[236]) h.pt3dadd(258.5, -65.5, -33.5, 1.9, sec = self.dend[236]) h.pt3dadd(262.5, -65.5, -34.5, 1.5, sec = self.dend[236]) h.pt3dadd(265.5, -65.5, -32.5, 1.4, sec = self.dend[236]) h.pt3dadd(267.5, -65.5, -33.5, 1.8, sec = self.dend[236]) h.pt3dadd(269.5, -65.5, -33.5, 1.8, sec = self.dend[236]) h.pt3dadd(275, -65.5, -32.5, 1.8, sec = self.dend[236]) h.pt3dadd(275, -65.5, -33, 2.5, sec = self.dend[236]) h.pt3dadd(279, -64.5, -30.5, 3.1, sec = self.dend[236]) h.pt3dadd(280.5, -63.5, -31, 1.8, sec = self.dend[236]) h.pt3dadd(282.5, -63.5, -31, 2.5, sec = self.dend[236]) h.pt3dadd(285, -62.5, -30.5, 2.9, sec = self.dend[236]) h.pt3dadd(287, -61.5, -30.5, 2.9, sec = self.dend[236]) h.pt3dadd(289, -60.5, -31, 3.3, sec = self.dend[236]) h.pt3dadd(290, -59, -31, 2.4, sec = self.dend[236]) h.pt3dadd(292.5, -57.5, -31, 1.7, sec = self.dend[236]) h.pt3dadd(293.5, -57.5, -31, 1.1, sec = self.dend[236]) h.pt3dadd(295.5, -56.5, -31, 1.4, sec = self.dend[236]) h.pt3dadd(297, -56.5, -31, 1.7, sec = self.dend[236]) h.pt3dadd(299, -56.5, -31, 0.3, sec = self.dend[236]) h.pt3dadd(300, -56.5, -31, 0.3, sec = self.dend[236]) h.pt3dadd(301.5, -55, -31, 1.8, sec = self.dend[236]) h.pt3dadd(304, -54, -29.5, 2.3, sec = self.dend[236]) h.pt3dadd(306.5, -54, -30.5, 2.8, sec = self.dend[236]) h.pt3dadd(307.5, -54, -29, 3.1, sec = self.dend[236]) h.pt3dadd(310, -54, -29.5, 1.8, sec = self.dend[236]) h.pt3dadd(313, -53.5, -29, 1, sec = self.dend[236]) h.pt3dadd(314, -53.5, -29, 0.7, sec = self.dend[236]) h.pt3dadd(316, -53.5, -29, 1.4, sec = self.dend[236]) h.pt3dadd(317.5, -53.5, -29, 1.8, sec = self.dend[236]) h.pt3dadd(318.5, -54.5, -29, 1.4, sec = self.dend[236]) h.pt3dadd(320, -54.5, -29, 1, sec = self.dend[236]) h.pt3dadd(321.5, -54.5, -29, 1, sec = self.dend[236]) h.pt3dadd(323.5, -55.5, -28.5, 1.4, sec = self.dend[236]) h.pt3dadd(324.5, -56.5, -28.5, 2.1, sec = self.dend[236]) h.pt3dadd(326, -56.5, -28.5, 2.4, sec = self.dend[236]) h.pt3dadd(328, -56.5, -28.5, 2.4, sec = self.dend[236]) h.pt3dadd(331, -56.5, -27.5, 1.1, sec = self.dend[236]) h.pt3dadd(334.5, -56.5, -27.5, 1.4, sec = self.dend[236]) h.pt3dadd(335.5, -56.5, -27.5, 1.4, sec = self.dend[236]) h.pt3dadd(338.5, -56, -28.5, 1.8, sec = self.dend[236]) h.pt3dadd(341, -56, -27.5, 2.4, sec = self.dend[236]) h.pt3dadd(344.5, -53.5, -27, 1.6, sec = self.dend[236]) h.pt3dadd(349.5, -53.5, -28.5, 1.2, sec = self.dend[236]) h.pt3dadd(351.5, -53.5, -27, 1.1, sec = self.dend[236]) h.pt3dadd(353, -53, -27.5, 1.4, sec = self.dend[236]) h.pt3dadd(355, -53, -27.5, 1.9, sec = self.dend[236]) h.pt3dadd(356, -52.5, -27, 2.3, sec = self.dend[236]) h.pt3dadd(358.5, -52.5, -26.5, 3.3, sec = self.dend[236]) h.pt3dadd(362, -52.5, -27, 1.8, sec = self.dend[236]) h.pt3dadd(363.5, -52.5, -27, 1.6, sec = self.dend[236]) h.pt3dadd(366, -52.5, -27, 1.4, sec = self.dend[236]) h.pt3dadd(369.5, -53.5, -27, 1.1, sec = self.dend[236]) h.pt3dadd(371, -53.5, -27, 1.1, sec = self.dend[236]) h.pt3dadd(372.5, -53.5, -27, 2.5, sec = self.dend[236]) h.pt3dadd(375, -55, -27, 3.7, sec = self.dend[236]) h.pt3dadd(378, -55, -27, 2.8, sec = self.dend[236]) h.pt3dadd(379, -55, -27, 1.2, sec = self.dend[236]) h.pt3dadd(381, -56, -27, 0.9, sec = self.dend[236]) h.pt3dadd(385, -58, -27, 1.1, sec = self.dend[236]) h.pt3dadd(389, -58, -27, 1.1, sec = self.dend[236]) h.pt3dadd(394, -59.5, -27, 1.1, sec = self.dend[236]) h.pt3dadd(397.5, -61.5, -26.5, 1, sec = self.dend[236]) h.pt3dadd(400, -62.5, -27, 1, sec = self.dend[236]) h.pt3dadd(406.5, -65.5, -27, 1, sec = self.dend[236]) h.pt3dadd(409, -67, -27, 1.2, sec = self.dend[236]) h.pt3dadd(415, -67, -27, 1.2, sec = self.dend[236]) h.pt3dadd(419.5, -69.5, -27, 1.2, sec = self.dend[236]) h.pt3dadd(421, -69.5, -27, 1.2, sec = self.dend[236]) h.pt3dadd(424.5, -70.5, -27, 1.2, sec = self.dend[236]) h.pt3dadd(427.5, -70.5, -27.5, 1.2, sec = self.dend[236]) h.pt3dadd(430.5, -71, -28.5, 1.4, sec = self.dend[236]) h.pt3dadd(433, -72, -29, 1.4, sec = self.dend[236]) h.pt3dadd(435, -73.5, -28.5, 1.3, sec = self.dend[236]) h.pt3dadd(437, -73.5, -27, 1.7, sec = self.dend[236]) h.pt3dadd(439, -73.5, -27, 2.6, sec = self.dend[236]) h.pt3dadd(442, -75, -27.5, 1.8, sec = self.dend[236]) h.pt3dadd(444, -75, -28.5, 1.1, sec = self.dend[236]) h.pt3dadd(446, -75, -28.5, 0.9, sec = self.dend[236]) h.pt3dadd(449.5, -74.5, -27.5, 0.9, sec = self.dend[236]) h.pt3dadd(452.5, -74.5, -27.5, 0.9, sec = self.dend[236]) h.pt3dadd(456, -74.5, -27.5, 0.9, sec = self.dend[236]) h.pt3dadd(457, -74.5, -27.5, 1.2, sec = self.dend[236]) h.pt3dadd(458.5, -74.5, -27.5, 1.2, sec = self.dend[236]) h.pt3dadd(461.5, -75.5, -27.5, 2.4, sec = self.dend[236]) h.pt3dadd(465.5, -78, -27.5, 2.1, sec = self.dend[236]) h.pt3dadd(466, -78, -27.5, 0.9, sec = self.dend[236]) h.pt3dadd(469, -78, -27.5, 0.9, sec = self.dend[236]) h.pt3dadd(471.5, -78.5, -27.5, 1.7, sec = self.dend[236]) h.pt3dadd(474.5, -79.5, -27.5, 2.4, sec = self.dend[236]) h.pt3dadd(477, -79.5, -27.5, 1.9, sec = self.dend[236]) h.pt3dadd(479.5, -79.5, -28.5, 0.6, sec = self.dend[236]) h.pt3dadd(482, -80.5, -27.5, 1.2, sec = self.dend[236]) h.pt3dadd(484.5, -80.5, -27.5, 1.8, sec = self.dend[236]) h.pt3dadd(487, -81.5, -27, 4.4, sec = self.dend[236]) h.pt3dclear(sec = self.dend[237]) h.pt3dadd(487, -81.5, -27, 4.4, sec = self.dend[237]) h.pt3dadd(493, -83.5, -25.5, 0.7, sec = self.dend[237]) h.pt3dadd(492, -86.5, -25.5, 0.9, sec = self.dend[237]) h.pt3dadd(492.5, -88.5, -25.5, 2.1, sec = self.dend[237]) h.pt3dadd(494.5, -88.5, -25.5, 3.8, sec = self.dend[237]) h.pt3dadd(496, -88.5, -25.5, 1.1, sec = self.dend[237]) h.pt3dadd(498, -89.5, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(500, -89.5, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(503, -90.5, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(505.5, -90.5, -26.5, 0.1, sec = self.dend[237]) h.pt3dadd(509, -92, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(511, -93.5, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(512.5, -93.5, -24.5, 1.4, sec = self.dend[237]) h.pt3dadd(514.5, -94, -24.5, 2.7, sec = self.dend[237]) h.pt3dadd(517, -94, -23.5, 0.1, sec = self.dend[237]) h.pt3dadd(522.5, -91.5, -23.5, 0.1, sec = self.dend[237]) h.pt3dadd(531, -91.5, -25, 0.1, sec = self.dend[237]) h.pt3dadd(538, -91, -25, 0.1, sec = self.dend[237]) h.pt3dadd(546, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(556, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(560, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(564.5, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(565.5, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(567.5, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(571, -89, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(572, -89, -24.5, 1.3, sec = self.dend[237]) h.pt3dadd(573, -93.5, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(574, -95, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(576, -97, -24.5, 1.6, sec = self.dend[237]) h.pt3dadd(578, -97, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(582, -98.5, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(584.5, -100.5, -24.5, 1.2, sec = self.dend[237]) h.pt3dadd(588.5, -100.5, -24.5, 0.1, sec = self.dend[237]) h.pt3dadd(591.5, -101, -25, 0.1, sec = self.dend[237]) h.pt3dadd(593.5, -101, -24.5, 1.1, sec = self.dend[237]) h.pt3dadd(595, -103, -25, 0.1, sec = self.dend[237]) h.pt3dadd(596, -103, -25, 0.1, sec = self.dend[237]) h.pt3dadd(598, -103, -24.5, 1.1, sec = self.dend[237]) h.pt3dadd(599, -103, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(602.5, -103, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(604.5, -103, -25.5, 1.6, sec = self.dend[237]) h.pt3dadd(606.5, -105, -25.5, 0.1, sec = self.dend[237]) h.pt3dadd(608, -103.5, -25, 0.1, sec = self.dend[237]) h.pt3dadd(609.5, -104, -25, 1.3, sec = self.dend[237]) h.pt3dadd(611.5, -103.5, -25, 0.1, sec = self.dend[237]) h.pt3dclear(sec = self.dend[238]) h.pt3dadd(487, -81.5, -27, 4.4, sec = self.dend[238]) h.pt3dadd(493.5, -81.5, -27, 0.8, sec = self.dend[238]) h.pt3dadd(496, -81.5, -28.5, 0.8, sec = self.dend[238]) h.pt3dadd(498, -81.5, -30.5, 0.8, sec = self.dend[238]) h.pt3dadd(500.5, -81.5, -27.5, 2.8, sec = self.dend[238]) h.pt3dadd(504.5, -81.5, -29.5, 0.4, sec = self.dend[238]) h.pt3dadd(507, -81.5, -30.5, 0.3, sec = self.dend[238]) h.pt3dadd(509, -80, -28.5, 0.3, sec = self.dend[238]) h.pt3dadd(511, -80, -27.5, 1.6, sec = self.dend[238]) h.pt3dadd(513, -79.5, -28.5, 2.1, sec = self.dend[238]) h.pt3dadd(515, -79.5, -28.5, 1.2, sec = self.dend[238]) h.pt3dadd(516, -79.5, -29, 0.6, sec = self.dend[238]) h.pt3dadd(520, -79.5, -29, 1.5, sec = self.dend[238]) h.pt3dadd(524.5, -79.5, -29, 0.5, sec = self.dend[238]) h.pt3dadd(526, -79, -29, 1.4, sec = self.dend[238]) h.pt3dadd(527.5, -78, -29, 0.5, sec = self.dend[238]) h.pt3dadd(531, -78, -29, 0.5, sec = self.dend[238]) h.pt3dadd(532.5, -78, -27.5, 1.5, sec = self.dend[238]) h.pt3dadd(536, -77.5, -29.5, 0.4, sec = self.dend[238]) h.pt3dadd(540, -75, -30.5, 0.4, sec = self.dend[238]) h.pt3dadd(546.5, -72, -30.5, 0.4, sec = self.dend[238]) h.pt3dadd(548, -72, -30.5, 0.4, sec = self.dend[238]) h.pt3dadd(551, -70.5, -29, 2.1, sec = self.dend[238]) h.pt3dadd(556, -70.5, -29.5, 0.2, sec = self.dend[238]) h.pt3dadd(560, -70.5, -29.5, 0.2, sec = self.dend[238]) h.pt3dadd(563, -70.5, -29.5, 1, sec = self.dend[238]) h.pt3dadd(564, -70.5, -29.5, 1.6, sec = self.dend[238]) h.pt3dadd(565.5, -70.5, -29.5, 0.6, sec = self.dend[238]) h.pt3dadd(567, -70.5, -29, 0.3, sec = self.dend[238]) h.pt3dadd(569, -70.5, -29, 2.2, sec = self.dend[238]) h.pt3dadd(572, -70.5, -30.5, 0.2, sec = self.dend[238]) h.pt3dadd(573, -71.5, -29.5, 0.8, sec = self.dend[238]) h.pt3dadd(572.5, -74, -29, 1.3, sec = self.dend[238]) h.pt3dadd(577.5, -76.5, -29.5, 0.1, sec = self.dend[238]) h.pt3dadd(578.5, -76.5, -29.5, 0.7, sec = self.dend[238]) h.pt3dadd(581.5, -77.5, -31, 0.1, sec = self.dend[238]) h.pt3dadd(583.5, -77.5, -31, 0.1, sec = self.dend[238]) h.pt3dadd(586.5, -76.5, -31, 1.4, sec = self.dend[238]) h.pt3dadd(588.5, -75, -29.5, 0.1, sec = self.dend[238]) h.pt3dadd(592.5, -75, -33, 0.1, sec = self.dend[238]) h.pt3dadd(598.5, -75, -34.5, 0.1, sec = self.dend[238]) h.pt3dadd(600.5, -73.5, -41, 1.1, sec = self.dend[238]) h.pt3dadd(602, -73.5, -34.5, 1.4, sec = self.dend[238]) h.pt3dadd(603.5, -73.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(606.5, -73.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(607, -73.5, -34.5, 0.9, sec = self.dend[238]) h.pt3dadd(608, -74.5, -34.5, 1.6, sec = self.dend[238]) h.pt3dadd(610.5, -74, -34.5, 0.7, sec = self.dend[238]) h.pt3dadd(611.5, -74, -34.5, 0.1, sec = self.dend[238]) h.pt3dadd(614, -75.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(615.5, -75.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(617, -76, -41, 0.1, sec = self.dend[238]) h.pt3dadd(618.5, -76, -41, 1.1, sec = self.dend[238]) h.pt3dadd(619.5, -77.5, -41, 1.6, sec = self.dend[238]) h.pt3dadd(621.5, -78, -41, 0.8, sec = self.dend[238]) h.pt3dadd(623, -78, -41, 0.2, sec = self.dend[238]) h.pt3dadd(625.5, -77.5, -47, 0.2, sec = self.dend[238]) h.pt3dadd(626.5, -77, -34.5, 0.2, sec = self.dend[238]) h.pt3dadd(627.5, -75.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(628, -75.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(629, -74, -41, 0.9, sec = self.dend[238]) h.pt3dadd(630.5, -74, -41, 1, sec = self.dend[238]) h.pt3dadd(632, -73, -41, 0.3, sec = self.dend[238]) h.pt3dadd(633, -73, -41, 0.1, sec = self.dend[238]) h.pt3dadd(634.5, -73, -41, 0.9, sec = self.dend[238]) h.pt3dadd(635.5, -73, -41, 1.3, sec = self.dend[238]) h.pt3dadd(636, -73, -41, 0.7, sec = self.dend[238]) h.pt3dadd(637, -73, -41, 0.1, sec = self.dend[238]) h.pt3dadd(638, -72, -41, 0.1, sec = self.dend[238]) h.pt3dadd(639.5, -72, -41, 0.8, sec = self.dend[238]) h.pt3dadd(640.5, -71.5, -41, 1.1, sec = self.dend[238]) h.pt3dadd(641, -71.5, -41, 0.6, sec = self.dend[238]) h.pt3dadd(642.5, -71, -41, 0.6, sec = self.dend[238]) h.pt3dadd(642.5, -70.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(644.5, -70, -41, 0.1, sec = self.dend[238]) h.pt3dadd(644.5, -69, -41, 0.1, sec = self.dend[238]) h.pt3dadd(645.5, -68.5, -41, 1.4, sec = self.dend[238]) h.pt3dadd(647, -67, -41, 1.8, sec = self.dend[238]) h.pt3dadd(649, -67, -41, 0.1, sec = self.dend[238]) h.pt3dadd(650, -67, -41, 0.1, sec = self.dend[238]) h.pt3dadd(650.5, -67, -41, 1.2, sec = self.dend[238]) h.pt3dadd(653, -66.5, -41, 1.7, sec = self.dend[238]) h.pt3dadd(654.5, -66, -41, 0.8, sec = self.dend[238]) h.pt3dadd(655, -64, -47, 0.1, sec = self.dend[238]) h.pt3dadd(656, -64, -47, 0.1, sec = self.dend[238]) h.pt3dadd(657.5, -62, -47, 0.1, sec = self.dend[238]) h.pt3dadd(658, -62, -47, 1, sec = self.dend[238]) h.pt3dadd(658.5, -61, -47, 1.6, sec = self.dend[238]) h.pt3dadd(659, -59, -47, 1.2, sec = self.dend[238]) h.pt3dadd(660, -59, -47, 0.1, sec = self.dend[238]) h.pt3dadd(663, -57.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(664.5, -57.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(667, -57, -41, 0.1, sec = self.dend[238]) h.pt3dadd(669, -56, -47, 1.4, sec = self.dend[238]) h.pt3dadd(671, -56, -41, 3.2, sec = self.dend[238]) h.pt3dadd(672.5, -56, -41, 1.4, sec = self.dend[238]) h.pt3dadd(674.5, -55, -41, 0.1, sec = self.dend[238]) h.pt3dadd(675.5, -55, -41, 0.1, sec = self.dend[238]) h.pt3dadd(678, -54.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(681, -53.5, -41, 1.3, sec = self.dend[238]) h.pt3dadd(683.5, -51, -47, 0.1, sec = self.dend[238]) h.pt3dadd(684, -51, -47, 0.1, sec = self.dend[238]) h.pt3dadd(686, -51, -47, 0.1, sec = self.dend[238]) h.pt3dadd(687, -50.5, -47, 0.1, sec = self.dend[238]) h.pt3dadd(689, -50, -47, 0.1, sec = self.dend[238]) h.pt3dadd(690, -49.5, -47, 0.1, sec = self.dend[238]) h.pt3dadd(692, -49.5, -47, 1.9, sec = self.dend[238]) h.pt3dadd(694, -47, -47, 0.1, sec = self.dend[238]) h.pt3dadd(696, -47, -47, 0.1, sec = self.dend[238]) h.pt3dadd(698, -47, -47, 1.4, sec = self.dend[238]) h.pt3dadd(699, -47, -47, 0.1, sec = self.dend[238]) h.pt3dadd(700.5, -46.5, -47, 0.1, sec = self.dend[238]) h.pt3dadd(703, -46, -47, 1.1, sec = self.dend[238]) h.pt3dadd(706, -45.5, -47, 0.1, sec = self.dend[238]) h.pt3dadd(706.5, -45, -47, 0.1, sec = self.dend[238]) h.pt3dadd(708.5, -43.5, -47, 1, sec = self.dend[238]) h.pt3dadd(709.5, -42, -47, 0.1, sec = self.dend[238]) h.pt3dadd(710, -40, -47, 0.1, sec = self.dend[238]) h.pt3dadd(710, -38, -47, 0.1, sec = self.dend[238]) h.pt3dadd(712, -38, -47, 0.1, sec = self.dend[238]) h.pt3dadd(713, -35.5, -41, 1, sec = self.dend[238]) h.pt3dadd(714.5, -33, -41, 0.1, sec = self.dend[238]) h.pt3dadd(715, -33, -41, 0.1, sec = self.dend[238]) h.pt3dadd(715.5, -31, -41, 0.3, sec = self.dend[238]) h.pt3dadd(716.5, -30, -41, 0.1, sec = self.dend[238]) h.pt3dadd(717.5, -30, -41, 0.1, sec = self.dend[238]) h.pt3dadd(718, -29, -41, 1.5, sec = self.dend[238]) h.pt3dadd(720.5, -27, -41, 0.1, sec = self.dend[238]) h.pt3dadd(722, -27, -41, 0.1, sec = self.dend[238]) h.pt3dadd(722.5, -27, -41, 0.1, sec = self.dend[238]) h.pt3dadd(725.5, -27.5, -47, 1.2, sec = self.dend[238]) h.pt3dadd(728.5, -27.5, -41, 0.1, sec = self.dend[238]) h.pt3dadd(730, -28, -41, 0.1, sec = self.dend[238]) h.pt3dadd(732, -29.5, -47, 0.1, sec = self.dend[238]) h.pt3dclear(sec = self.dend[239]) h.pt3dadd(254, -65, -33.5, 6.5, sec = self.dend[239]) h.pt3dadd(255.5, -70.5, -33, 2.4, sec = self.dend[239]) h.pt3dadd(257.5, -71.5, -33, 2.4, sec = self.dend[239]) h.pt3dadd(260.5, -72.5, -34.5, 2.4, sec = self.dend[239]) h.pt3dadd(263.5, -73, -35, 2.4, sec = self.dend[239]) h.pt3dadd(267, -73, -33.5, 2.5, sec = self.dend[239]) h.pt3dadd(270.5, -72, -34.5, 2.5, sec = self.dend[239]) h.pt3dadd(275, -72, -40.5, 4.3, sec = self.dend[239]) h.pt3dadd(278.5, -71.5, -34.5, 4.3, sec = self.dend[239]) h.pt3dadd(281, -70.5, -40.5, 3.7, sec = self.dend[239]) h.pt3dadd(283, -70.5, -40.5, 3.5, sec = self.dend[239]) h.pt3dadd(286, -69, -40.5, 3.8, sec = self.dend[239]) h.pt3dadd(289, -69, -40.5, 3.8, sec = self.dend[239]) h.pt3dadd(290.5, -69, -40.5, 4.3, sec = self.dend[239]) h.pt3dadd(293.5, -69, -40.5, 5.2, sec = self.dend[239]) h.pt3dadd(295.5, -70, -40.5, 4.3, sec = self.dend[239]) h.pt3dadd(297.5, -70, -40.5, 3.6, sec = self.dend[239]) h.pt3dadd(298.5, -70, -40.5, 2.9, sec = self.dend[239]) h.pt3dadd(300, -70, -40.5, 2.8, sec = self.dend[239]) h.pt3dadd(303, -71.5, -40.5, 2.5, sec = self.dend[239]) h.pt3dadd(306, -71.5, -40.5, 2.7, sec = self.dend[239]) h.pt3dadd(308.5, -72, -40.5, 3.1, sec = self.dend[239]) h.pt3dadd(309.5, -72, -40.5, 3.8, sec = self.dend[239]) h.pt3dadd(315, -73, -47, 4.6, sec = self.dend[239]) h.pt3dadd(317, -73, -47, 4.4, sec = self.dend[239]) h.pt3dadd(318, -74, -47, 3.7, sec = self.dend[239]) h.pt3dadd(320.5, -75, -47, 3.1, sec = self.dend[239]) h.pt3dadd(322.5, -75, -47, 2.5, sec = self.dend[239]) h.pt3dadd(324, -75, -53, 2, sec = self.dend[239]) h.pt3dadd(328.5, -75, -53, 2.1, sec = self.dend[239]) h.pt3dadd(330.5, -74, -53, 2.5, sec = self.dend[239]) h.pt3dadd(333, -74, -53, 2.5, sec = self.dend[239]) h.pt3dadd(334.5, -74, -53, 3.6, sec = self.dend[239]) h.pt3dadd(336, -74, -53, 4, sec = self.dend[239]) h.pt3dadd(338.5, -73, -53, 3.8, sec = self.dend[239]) h.pt3dadd(341, -71.5, -53, 4, sec = self.dend[239]) h.pt3dadd(342.5, -71.5, -47, 4.3, sec = self.dend[239]) h.pt3dadd(346, -70.5, -47, 4.3, sec = self.dend[239]) h.pt3dadd(348.5, -70, -47, 3.2, sec = self.dend[239]) h.pt3dadd(350.5, -68, -47, 2, sec = self.dend[239]) h.pt3dadd(352, -68.5, -47, 1.5, sec = self.dend[239]) h.pt3dadd(355, -68.5, -47, 1.2, sec = self.dend[239]) h.pt3dadd(357, -69, -53, 2.6, sec = self.dend[239]) h.pt3dadd(359, -67, -53, 2.8, sec = self.dend[239]) h.pt3dadd(360.5, -66.5, -53, 3.7, sec = self.dend[239]) h.pt3dadd(363.5, -64.5, -53, 4.9, sec = self.dend[239]) h.pt3dadd(366.5, -64.5, -53, 4.1, sec = self.dend[239]) h.pt3dadd(368, -64.5, -47, 2.5, sec = self.dend[239]) h.pt3dadd(370.5, -64, -47, 1.9, sec = self.dend[239]) h.pt3dadd(371, -64, -47, 1.4, sec = self.dend[239]) h.pt3dadd(374, -64, -47, 2.3, sec = self.dend[239]) h.pt3dadd(376, -64, -47, 3.2, sec = self.dend[239]) h.pt3dadd(377.5, -64, -47, 4.2, sec = self.dend[239]) h.pt3dadd(380.5, -64, -53, 4.3, sec = self.dend[239]) h.pt3dadd(384, -64, -53, 3.5, sec = self.dend[239]) h.pt3dadd(386.5, -64, -53, 2, sec = self.dend[239]) h.pt3dadd(388, -64, -53, 1.6, sec = self.dend[239]) h.pt3dadd(391, -64, -59.5, 1.9, sec = self.dend[239]) h.pt3dadd(393, -64.5, -53, 2.7, sec = self.dend[239]) h.pt3dadd(395.5, -65, -53, 2.5, sec = self.dend[239]) h.pt3dadd(397, -65, -53, 3.4, sec = self.dend[239]) h.pt3dadd(399, -65, -53, 3.8, sec = self.dend[239]) h.pt3dadd(401.5, -64.5, -53, 4.9, sec = self.dend[239]) h.pt3dadd(405, -65, -53, 2.9, sec = self.dend[239]) h.pt3dadd(408, -65, -53, 2.7, sec = self.dend[239]) h.pt3dadd(410, -65, -53, 2.6, sec = self.dend[239]) h.pt3dadd(411.5, -65, -53, 3.3, sec = self.dend[239]) h.pt3dadd(414, -65, -53, 4.1, sec = self.dend[239]) h.pt3dadd(416.5, -65, -53, 3.3, sec = self.dend[239]) h.pt3dadd(419, -66, -59.5, 3.7, sec = self.dend[239]) h.pt3dadd(422, -66, -59.5, 3.3, sec = self.dend[239]) h.pt3dadd(424, -66.5, -59.5, 2.2, sec = self.dend[239]) h.pt3dadd(426, -68, -53, 2.3, sec = self.dend[239]) h.pt3dadd(429.5, -69.5, -53, 2.3, sec = self.dend[239]) h.pt3dadd(432, -69.5, -53, 2, sec = self.dend[239]) h.pt3dadd(434, -69.5, -59.5, 2.6, sec = self.dend[239]) h.pt3dadd(436, -70, -59.5, 3.7, sec = self.dend[239]) h.pt3dadd(439, -70.5, -59.5, 2.3, sec = self.dend[239]) h.pt3dadd(442.5, -70.5, -59.5, 2.4, sec = self.dend[239]) h.pt3dadd(446.5, -70.5, -59.5, 2.4, sec = self.dend[239]) h.pt3dadd(449.5, -70.5, -59.5, 2.4, sec = self.dend[239]) h.pt3dadd(454.5, -70.5, -59.5, 2.4, sec = self.dend[239]) h.pt3dadd(456, -72, -59.5, 3.5, sec = self.dend[239]) h.pt3dadd(459, -72.5, -59.5, 3.1, sec = self.dend[239]) h.pt3dadd(462.5, -75, -65.5, 2.8, sec = self.dend[239]) h.pt3dadd(468.5, -75, -61.5, 2.7, sec = self.dend[239]) h.pt3dadd(472.5, -76, -59.5, 2.7, sec = self.dend[239]) h.pt3dadd(477.5, -76, -61.5, 3.4, sec = self.dend[239]) h.pt3dadd(479.5, -76, -59.5, 2.4, sec = self.dend[239]) h.pt3dadd(481, -76, -63.5, 2.4, sec = self.dend[239]) h.pt3dadd(483, -76.5, -63.5, 2.1, sec = self.dend[239]) h.pt3dadd(486.5, -76, -63.5, 1.6, sec = self.dend[239]) h.pt3dadd(487.5, -77, -61.5, 1.2, sec = self.dend[239]) h.pt3dadd(490, -77, -61.5, 2, sec = self.dend[239]) h.pt3dadd(492, -78.5, -61.5, 3.1, sec = self.dend[239]) h.pt3dadd(496, -78, -65.5, 4.3, sec = self.dend[239]) h.pt3dadd(499, -77.5, -65.5, 2.4, sec = self.dend[239]) h.pt3dadd(500.5, -77.5, -63.5, 1.1, sec = self.dend[239]) h.pt3dadd(503.5, -78, -65.5, 2.3, sec = self.dend[239]) h.pt3dadd(507, -78, -67.5, 2.3, sec = self.dend[239]) h.pt3dadd(510.5, -75.5, -67.5, 2.3, sec = self.dend[239]) h.pt3dadd(514.5, -76, -67.5, 2.3, sec = self.dend[239]) h.pt3dadd(517, -76, -67.5, 1.4, sec = self.dend[239]) h.pt3dadd(521, -76.5, -67.5, 1.2, sec = self.dend[239]) h.pt3dadd(523, -76.5, -67.5, 1.2, sec = self.dend[239]) h.pt3dadd(525.5, -77.5, -69.5, 2.9, sec = self.dend[239]) h.pt3dclear(sec = self.dend[240]) h.pt3dadd(525.5, -77.5, -69.5, 2.9, sec = self.dend[240]) h.pt3dadd(529, -76, -69.5, 0.5, sec = self.dend[240]) h.pt3dadd(530.5, -75, -69.5, 0.5, sec = self.dend[240]) h.pt3dadd(533.5, -75, -69.5, 0.5, sec = self.dend[240]) h.pt3dadd(536.5, -75, -69.5, 0.5, sec = self.dend[240]) h.pt3dadd(539, -75, -69.5, 0.5, sec = self.dend[240]) h.pt3dadd(540.5, -74.5, -69.5, 0.9, sec = self.dend[240]) h.pt3dadd(542, -74.5, -67.5, 0.9, sec = self.dend[240]) h.pt3dadd(545, -74.5, -69.5, 0.7, sec = self.dend[240]) h.pt3dclear(sec = self.dend[241]) h.pt3dadd(525.5, -77.5, -69.5, 2.9, sec = self.dend[241]) h.pt3dadd(528, -80, -69.5, 2.3, sec = self.dend[241]) h.pt3dadd(531.5, -81.5, -71, 2.5, sec = self.dend[241]) h.pt3dadd(534.5, -81.5, -69.5, 2.7, sec = self.dend[241]) h.pt3dadd(535.5, -81.5, -69.5, 3.3, sec = self.dend[241]) h.pt3dadd(538.5, -82, -69.5, 3.3, sec = self.dend[241]) h.pt3dadd(541.5, -82, -69.5, 2.7, sec = self.dend[241]) h.pt3dadd(544.5, -82, -69.5, 3.1, sec = self.dend[241]) h.pt3dadd(545, -82.5, -69.5, 2.5, sec = self.dend[241]) h.pt3dadd(547.5, -82.5, -73, 1.4, sec = self.dend[241]) h.pt3dadd(550.5, -84, -75, 0.9, sec = self.dend[241]) h.pt3dadd(553, -85, -75, 0.7, sec = self.dend[241]) h.pt3dadd(555, -85, -75, 2.6, sec = self.dend[241]) h.pt3dadd(561.5, -88, -79, 2.8, sec = self.dend[241]) h.pt3dadd(562.5, -88, -75, 1.4, sec = self.dend[241]) h.pt3dadd(565, -88, -75, 1.4, sec = self.dend[241]) h.pt3dadd(568.5, -89, -77, 0.5, sec = self.dend[241]) h.pt3dadd(570.5, -92.5, -77, 0.5, sec = self.dend[241]) h.pt3dadd(573.5, -95.5, -80, 2.5, sec = self.dend[241]) h.pt3dadd(575, -97, -83, 3.3, sec = self.dend[241]) h.pt3dadd(577.5, -97, -83, 2.8, sec = self.dend[241]) h.pt3dadd(580, -98, -86, 2, sec = self.dend[241]) h.pt3dadd(581, -98, -89, 1.5, sec = self.dend[241]) h.pt3dadd(583, -98, -89, 1.3, sec = self.dend[241]) h.pt3dadd(585, -98.5, -86, 1.6, sec = self.dend[241]) h.pt3dadd(586.5, -99, -86, 2, sec = self.dend[241]) h.pt3dadd(589.5, -101.5, -89, 2.3, sec = self.dend[241]) h.pt3dadd(591.5, -101.5, -89, 1.9, sec = self.dend[241]) h.pt3dadd(593.5, -101.5, -89, 1.5, sec = self.dend[241]) h.pt3dadd(595.5, -101.5, -89, 2.7, sec = self.dend[241]) h.pt3dadd(598.5, -102, -89, 3.2, sec = self.dend[241]) h.pt3dadd(601.5, -102, -89, 2.1, sec = self.dend[241]) h.pt3dadd(603.5, -102.5, -89, 1.5, sec = self.dend[241]) h.pt3dadd(605, -103.5, -89, 1.6, sec = self.dend[241]) h.pt3dadd(605.5, -105, -89, 1.5, sec = self.dend[241]) h.pt3dadd(608.5, -105, -92, 1.9, sec = self.dend[241]) h.pt3dadd(609.5, -105.5, -92, 2.3, sec = self.dend[241]) h.pt3dadd(613, -106.5, -95, 2.5, sec = self.dend[241]) h.pt3dadd(615, -107, -95, 2, sec = self.dend[241]) h.pt3dadd(617, -107.5, -95, 1.7, sec = self.dend[241]) h.pt3dadd(618.5, -108, -95, 1.8, sec = self.dend[241]) h.pt3dadd(621, -109, -97.5, 1.8, sec = self.dend[241]) h.pt3dadd(623.5, -110.5, -95, 2.3, sec = self.dend[241]) h.pt3dadd(627, -111, -100.5, 2.8, sec = self.dend[241]) h.pt3dadd(628.5, -111, -100.5, 2.8, sec = self.dend[241]) h.pt3dadd(631.5, -112, -100.5, 2.8, sec = self.dend[241]) h.pt3dadd(632.5, -114, -103.5, 1.9, sec = self.dend[241]) h.pt3dadd(635.5, -116, -95, 1.6, sec = self.dend[241]) h.pt3dadd(637, -116.5, -95, 2.5, sec = self.dend[241]) h.pt3dadd(639.5, -118, -95, 2.6, sec = self.dend[241]) h.pt3dadd(642.5, -117, -97.5, 2.3, sec = self.dend[241]) h.pt3dadd(646.5, -116, -97.5, 1.5, sec = self.dend[241]) h.pt3dadd(648.5, -116, -97.5, 1.4, sec = self.dend[241]) h.pt3dadd(651.5, -117, -97.5, 1.5, sec = self.dend[241]) h.pt3dadd(654, -117.5, -97.5, 2.3, sec = self.dend[241]) h.pt3dadd(656.5, -117.5, -97.5, 3.2, sec = self.dend[241]) h.pt3dadd(659, -119.5, -100.5, 3, sec = self.dend[241]) h.pt3dadd(662, -119.5, -100.5, 2.3, sec = self.dend[241]) h.pt3dadd(665, -121, -103.5, 1.6, sec = self.dend[241]) h.pt3dadd(666.5, -121, -103.5, 1.1, sec = self.dend[241]) h.pt3dadd(668, -121, -103.5, 1.3, sec = self.dend[241]) h.pt3dadd(669, -123, -103.5, 1.5, sec = self.dend[241]) h.pt3dadd(671.5, -124, -103.5, 2.2, sec = self.dend[241]) h.pt3dadd(673.5, -124.5, -103.5, 3.4, sec = self.dend[241]) h.pt3dadd(675.5, -125.5, -103.5, 3.6, sec = self.dend[241]) h.pt3dadd(677.5, -126.5, -106.5, 1.7, sec = self.dend[241]) h.pt3dadd(679.5, -127, -103.5, 1.1, sec = self.dend[241]) h.pt3dadd(682, -127, -103.5, 1.5, sec = self.dend[241]) h.pt3dadd(685.5, -128, -106.5, 1.5, sec = self.dend[241]) h.pt3dadd(686, -128.5, -106.5, 1.6, sec = self.dend[241]) h.pt3dadd(688, -129.5, -106.5, 2.3, sec = self.dend[241]) h.pt3dadd(690, -130, -106.5, 3.3, sec = self.dend[241]) h.pt3dadd(691, -130.5, -109.5, 4, sec = self.dend[241]) h.pt3dadd(693, -132.5, -106.5, 3.9, sec = self.dend[241]) h.pt3dclear(sec = self.dend[242]) h.pt3dadd(693, -132.5, -106.5, 3.9, sec = self.dend[242]) h.pt3dadd(692.5, -133.5, -100.5, 0.1, sec = self.dend[242]) h.pt3dadd(692.5, -136.5, -100.5, 0.1, sec = self.dend[242]) h.pt3dadd(693, -136.5, -100.5, 0.9, sec = self.dend[242]) h.pt3dadd(693.5, -137.5, -100.5, 1.1, sec = self.dend[242]) h.pt3dadd(694.5, -138, -100.5, 1.1, sec = self.dend[242]) h.pt3dadd(696, -139, -100.5, 0.1, sec = self.dend[242]) h.pt3dclear(sec = self.dend[243]) h.pt3dadd(693, -132.5, -106.5, 3.9, sec = self.dend[243]) h.pt3dadd(695, -132.5, -106.5, 1.2, sec = self.dend[243]) h.pt3dadd(696.5, -134, -106.5, 1.4, sec = self.dend[243]) h.pt3dadd(699, -137, -109.5, 1.4, sec = self.dend[243]) h.pt3dadd(702.5, -137, -107, 1.7, sec = self.dend[243]) h.pt3dadd(704, -137, -107, 1.2, sec = self.dend[243]) h.pt3dadd(705, -138, -109.5, 1.4, sec = self.dend[243]) h.pt3dadd(707, -139, -109.5, 1.7, sec = self.dend[243]) h.pt3dadd(709, -140, -109.5, 2.4, sec = self.dend[243]) h.pt3dadd(710, -142, -109.5, 2.9, sec = self.dend[243]) h.pt3dadd(711, -145, -109.5, 2.4, sec = self.dend[243]) h.pt3dadd(712.5, -145.5, -112, 1.4, sec = self.dend[243]) h.pt3dadd(714.5, -148, -112, 1.3, sec = self.dend[243]) h.pt3dadd(715, -150.5, -112, 1.5, sec = self.dend[243]) h.pt3dadd(715.5, -152.5, -109.5, 1.7, sec = self.dend[243]) h.pt3dadd(715.5, -154.5, -114.5, 1.7, sec = self.dend[243]) h.pt3dadd(716.5, -157, -114.5, 2.2, sec = self.dend[243]) h.pt3dadd(717, -159, -114.5, 2.2, sec = self.dend[243]) h.pt3dadd(717.5, -160.5, -114.5, 2.2, sec = self.dend[243]) h.pt3dadd(717, -162, -116.5, 0.8, sec = self.dend[243]) h.pt3dadd(717, -163, -116.5, 0.4, sec = self.dend[243]) h.pt3dadd(718, -164, -116.5, 0.4, sec = self.dend[243]) h.pt3dadd(720, -166.5, -116.5, 0.4, sec = self.dend[243]) h.pt3dadd(720, -167.5, -116.5, 0.4, sec = self.dend[243]) h.pt3dadd(721, -168.5, -116.5, 1.2, sec = self.dend[243]) h.pt3dadd(721, -169, -116.5, 1.5, sec = self.dend[243]) h.pt3dadd(720.5, -170.5, -119, 0.8, sec = self.dend[243]) h.pt3dadd(721, -173.5, -124, 0.6, sec = self.dend[243]) h.pt3dadd(723, -173.5, -124, 0.6, sec = self.dend[243]) h.pt3dadd(723.5, -173, -124, 0.5, sec = self.dend[243]) h.pt3dadd(724, -175, -124, 0.5, sec = self.dend[243]) h.pt3dadd(724, -177, -124, 0.5, sec = self.dend[243]) h.pt3dadd(725, -177, -124, 1.1, sec = self.dend[243]) h.pt3dadd(727, -178.5, -124, 1.3, sec = self.dend[243]) h.pt3dadd(728, -180, -128.5, 1.6, sec = self.dend[243]) h.pt3dadd(729.5, -181.5, -126, 1.9, sec = self.dend[243]) h.pt3dadd(730.5, -183.5, -128.5, 2.7, sec = self.dend[243]) h.pt3dadd(731, -185.5, -128.5, 1.6, sec = self.dend[243]) h.pt3dadd(731.5, -187, -128.5, 1.6, sec = self.dend[243]) h.pt3dadd(731.5, -190, -128.5, 1.3, sec = self.dend[243]) h.pt3dadd(733, -191, -128.5, 1, sec = self.dend[243]) h.pt3dadd(733, -191.5, -135.5, 0.8, sec = self.dend[243]) h.pt3dadd(733, -194.5, -135.5, 0.8, sec = self.dend[243]) h.pt3dclear(sec = self.dend[244]) h.pt3dadd(210.5, -36.5, -31, 4.9, sec = self.dend[244]) h.pt3dadd(211, -37.5, -34.5, 4.4, sec = self.dend[244]) h.pt3dadd(213.5, -41.5, -33.5, 4.9, sec = self.dend[244]) h.pt3dadd(213.5, -46.5, -33.5, 4.6, sec = self.dend[244]) h.pt3dadd(215.5, -50.5, -33.5, 4, sec = self.dend[244]) h.pt3dadd(216.5, -53, -33.5, 4, sec = self.dend[244]) h.pt3dadd(219, -53, -34.5, 4, sec = self.dend[244]) h.pt3dadd(224.5, -59.5, -34.5, 4.6, sec = self.dend[244]) h.pt3dadd(227.5, -61.5, -41, 4.4, sec = self.dend[244]) h.pt3dadd(230, -64, -41, 4, sec = self.dend[244]) h.pt3dadd(232.5, -64.5, -41, 3.6, sec = self.dend[244]) h.pt3dadd(235, -66, -41, 3.6, sec = self.dend[244]) h.pt3dadd(237.5, -68.5, -41, 3.6, sec = self.dend[244]) h.pt3dadd(240, -69.5, -41, 4.1, sec = self.dend[244]) h.pt3dadd(242, -70.5, -41, 5, sec = self.dend[244]) h.pt3dadd(243.5, -73, -41, 4.7, sec = self.dend[244]) h.pt3dadd(246, -73.5, -41, 4, sec = self.dend[244]) h.pt3dadd(248.5, -75.5, -47, 3.7, sec = self.dend[244]) h.pt3dadd(250.5, -77.5, -41, 3.3, sec = self.dend[244]) h.pt3dadd(253.5, -79, -41, 2.9, sec = self.dend[244]) h.pt3dadd(254.5, -81.5, -41, 2.2, sec = self.dend[244]) h.pt3dadd(255.5, -82.5, -41, 1.6, sec = self.dend[244]) h.pt3dadd(256.5, -84.5, -47, 1.6, sec = self.dend[244]) h.pt3dadd(258, -86.5, -47, 2.5, sec = self.dend[244]) h.pt3dadd(260, -87.5, -47, 3, sec = self.dend[244]) h.pt3dadd(262, -89, -47, 3.6, sec = self.dend[244]) h.pt3dadd(264.5, -90.5, -53.5, 3.1, sec = self.dend[244]) h.pt3dadd(268, -92.5, -47, 3.1, sec = self.dend[244]) h.pt3dadd(272, -98.5, -51, 2.3, sec = self.dend[244]) h.pt3dadd(273.5, -100, -49, 2.1, sec = self.dend[244]) h.pt3dadd(275.5, -102, -49, 2.3, sec = self.dend[244]) h.pt3dadd(277, -104, -51, 3.7, sec = self.dend[244]) h.pt3dadd(279, -106, -51, 3.9, sec = self.dend[244]) h.pt3dadd(282, -108.5, -51, 3.4, sec = self.dend[244]) h.pt3dadd(284, -110.5, -51, 2.7, sec = self.dend[244]) h.pt3dadd(285.5, -111.5, -51, 2.6, sec = self.dend[244]) h.pt3dadd(286.5, -113, -51, 2.8, sec = self.dend[244]) h.pt3dadd(288, -114, -57, 2.4, sec = self.dend[244]) h.pt3dadd(289.5, -115, -57, 2.3, sec = self.dend[244]) h.pt3dadd(291, -117, -58.5, 2.2, sec = self.dend[244]) h.pt3dadd(292.5, -117, -58.5, 2.7, sec = self.dend[244]) h.pt3dadd(293.5, -119.5, -58.5, 3.1, sec = self.dend[244]) h.pt3dadd(294, -122.5, -57, 3.6, sec = self.dend[244]) h.pt3dadd(295, -123.5, -60.5, 4.6, sec = self.dend[244]) h.pt3dadd(296.5, -125, -60.5, 4.6, sec = self.dend[244]) h.pt3dadd(298.5, -127, -64.5, 4, sec = self.dend[244]) h.pt3dadd(300, -128.5, -68.5, 3.7, sec = self.dend[244]) h.pt3dadd(302, -132.5, -71.5, 2.3, sec = self.dend[244]) h.pt3dadd(302, -134, -74.5, 1.9, sec = self.dend[244]) h.pt3dadd(303, -137, -74.5, 1.9, sec = self.dend[244]) h.pt3dadd(304.5, -139, -71.5, 2, sec = self.dend[244]) h.pt3dadd(306, -141, -74.5, 4, sec = self.dend[244]) h.pt3dadd(308, -142.5, -77.5, 4.6, sec = self.dend[244]) h.pt3dadd(308.5, -145, -77.5, 4.6, sec = self.dend[244]) h.pt3dadd(310, -148.5, -77.5, 4.3, sec = self.dend[244]) h.pt3dadd(311, -150.5, -77.5, 3.6, sec = self.dend[244]) h.pt3dadd(313, -151.5, -80.5, 3.1, sec = self.dend[244]) h.pt3dadd(314, -154.5, -83.5, 2.2, sec = self.dend[244]) h.pt3dadd(314, -155.5, -83.5, 2, sec = self.dend[244]) h.pt3dadd(315, -159, -83.5, 2.3, sec = self.dend[244]) h.pt3dadd(316, -160, -83.5, 2.5, sec = self.dend[244]) h.pt3dadd(316.5, -161.5, -83.5, 2.1, sec = self.dend[244]) h.pt3dadd(317, -163, -86, 1.8, sec = self.dend[244]) h.pt3dadd(318, -164, -89, 1.6, sec = self.dend[244]) h.pt3dadd(319, -164.5, -89, 2.2, sec = self.dend[244]) h.pt3dadd(319.5, -166, -89, 2.4, sec = self.dend[244]) h.pt3dadd(321, -168.5, -89, 2.6, sec = self.dend[244]) h.pt3dadd(321, -169.5, -89, 2.2, sec = self.dend[244]) h.pt3dadd(322.5, -171.5, -89, 2.6, sec = self.dend[244]) h.pt3dadd(322, -174, -95, 3.7, sec = self.dend[244]) h.pt3dadd(323.5, -178, -98, 4, sec = self.dend[244]) h.pt3dadd(323, -180.5, -93.5, 2.8, sec = self.dend[244]) h.pt3dadd(322.5, -183.5, -98, 2.7, sec = self.dend[244]) h.pt3dadd(322.5, -183.5, -103, 3.7, sec = self.dend[244]) h.pt3dadd(323, -187.5, -103, 4.4, sec = self.dend[244]) h.pt3dadd(323.5, -189, -100.5, 4.8, sec = self.dend[244]) h.pt3dadd(322.5, -191, -100.5, 4.4, sec = self.dend[244]) h.pt3dadd(323, -194, -100.5, 3.6, sec = self.dend[244]) h.pt3dadd(323.5, -196.5, -105.5, 2, sec = self.dend[244]) h.pt3dadd(323.5, -199.5, -105.5, 2, sec = self.dend[244]) h.pt3dadd(324, -203.5, -105.5, 3.8, sec = self.dend[244]) h.pt3dadd(324.5, -205, -107.5, 6, sec = self.dend[244]) h.pt3dadd(326.5, -205.5, -107.5, 6.7, sec = self.dend[244]) h.pt3dadd(327.5, -206.5, -107.5, 4.9, sec = self.dend[244]) h.pt3dadd(328.5, -208, -107.5, 3.6, sec = self.dend[244]) h.pt3dadd(329.5, -210.5, -107.5, 2.7, sec = self.dend[244]) h.pt3dadd(329.5, -212.5, -107.5, 2.2, sec = self.dend[244]) h.pt3dadd(329.5, -213.5, -110, 1.8, sec = self.dend[244]) h.pt3dadd(329, -214.5, -110, 1, sec = self.dend[244]) h.pt3dadd(329, -215.5, -110, 0.8, sec = self.dend[244]) h.pt3dadd(329, -217, -110, 1, sec = self.dend[244]) h.pt3dadd(329, -218.5, -110, 1, sec = self.dend[244]) h.pt3dadd(329, -220, -110, 1.8, sec = self.dend[244]) h.pt3dadd(329, -221, -110, 2.4, sec = self.dend[244]) h.pt3dadd(329, -222.5, -112.5, 3.1, sec = self.dend[244]) h.pt3dadd(329.5, -225, -112.5, 2.9, sec = self.dend[244]) h.pt3dadd(329.5, -226.5, -112.5, 2.6, sec = self.dend[244]) h.pt3dadd(329, -228.5, -112.5, 2.3, sec = self.dend[244]) h.pt3dadd(329, -231, -112.5, 1.7, sec = self.dend[244]) h.pt3dadd(329, -232.5, -112.5, 2.9, sec = self.dend[244]) h.pt3dadd(329.5, -236, -115, 4.3, sec = self.dend[244]) h.pt3dadd(330, -239, -115, 3.8, sec = self.dend[244]) h.pt3dadd(330, -240, -112.5, 2.9, sec = self.dend[244]) h.pt3dadd(330, -241.5, -115, 1.6, sec = self.dend[244]) h.pt3dadd(330, -242.5, -115, 1.2, sec = self.dend[244]) h.pt3dadd(332, -245, -110, 2.3, sec = self.dend[244]) h.pt3dadd(333, -245.5, -112.5, 2, sec = self.dend[244]) h.pt3dadd(336, -248.5, -115, 0.9, sec = self.dend[244]) h.pt3dadd(336.5, -249.5, -115, 0.9, sec = self.dend[244]) h.pt3dadd(337, -250.5, -115, 2, sec = self.dend[244]) h.pt3dadd(338, -252, -117, 0.9, sec = self.dend[244]) h.pt3dadd(338.5, -254, -117, 1.1, sec = self.dend[244]) h.pt3dadd(339.5, -254.5, -115, 0.9, sec = self.dend[244]) h.pt3dadd(341, -255.5, -115, 0.9, sec = self.dend[244]) h.pt3dadd(342, -256, -117, 0.9, sec = self.dend[244]) h.pt3dadd(342.5, -258, -110, 0.9, sec = self.dend[244]) h.pt3dadd(343, -259, -112.5, 0.9, sec = self.dend[244]) h.pt3dadd(345.5, -261, -117, 0.5, sec = self.dend[244]) h.pt3dclear(sec = self.dend[245]) h.pt3dadd(169, -9.5, -31, 8.8, sec = self.dend[245]) h.pt3dadd(176.5, -6.5, -31, 2.9, sec = self.dend[245]) h.pt3dadd(179.5, -5.5, -29.5, 2.9, sec = self.dend[245]) h.pt3dadd(183, -3.5, -29.5, 3.4, sec = self.dend[245]) h.pt3dadd(186.5, -2.5, -30.5, 3.4, sec = self.dend[245]) h.pt3dadd(190, -1, -30.5, 3.1, sec = self.dend[245]) h.pt3dadd(193, -1, -30.5, 3.3, sec = self.dend[245]) h.pt3dadd(197, -1, -30.5, 3.6, sec = self.dend[245]) h.pt3dadd(200.5, -1, -31, 3.3, sec = self.dend[245]) h.pt3dadd(203.5, -1.5, -31, 3, sec = self.dend[245]) h.pt3dadd(206, -1.5, -31.5, 2.4, sec = self.dend[245]) h.pt3dadd(209, -0.5, -31, 3.7, sec = self.dend[245]) h.pt3dadd(212.5, -0.5, -31, 4.3, sec = self.dend[245]) h.pt3dadd(216.5, -0.5, -31.5, 3.8, sec = self.dend[245]) h.pt3dadd(218.5, -0.5, -31.5, 2.9, sec = self.dend[245]) h.pt3dadd(221.5, 2, -32.5, 2.3, sec = self.dend[245]) h.pt3dadd(224, 1, -31.5, 2.3, sec = self.dend[245]) h.pt3dadd(228, 0, -34.5, 2.8, sec = self.dend[245]) h.pt3dadd(232, 0, -34.5, 3.1, sec = self.dend[245]) h.pt3dadd(235.5, 0, -33.5, 3.1, sec = self.dend[245]) h.pt3dadd(239, 0, -33.5, 3.3, sec = self.dend[245]) h.pt3dadd(242.5, 0, -36, 3.6, sec = self.dend[245]) h.pt3dadd(246, 0, -36, 4, sec = self.dend[245]) h.pt3dadd(250, 0, -36, 4.4, sec = self.dend[245]) h.pt3dadd(252.5, 0, -36, 5.1, sec = self.dend[245]) h.pt3dadd(254.5, 0, -36, 5.2, sec = self.dend[245]) h.pt3dadd(257, 0, -42.5, 3.9, sec = self.dend[245]) h.pt3dadd(258.5, 0.5, -42.5, 3.6, sec = self.dend[245]) h.pt3dadd(260, 1.5, -42.5, 3.3, sec = self.dend[245]) h.pt3dadd(262.5, 1.5, -42.5, 3.5, sec = self.dend[245]) h.pt3dadd(263.5, 1.5, -42.5, 3.5, sec = self.dend[245]) h.pt3dadd(266.5, 1.5, -42.5, 2.8, sec = self.dend[245]) h.pt3dadd(267.5, 1.5, -48.5, 2.7, sec = self.dend[245]) h.pt3dadd(270.5, 1.5, -42.5, 3.5, sec = self.dend[245]) h.pt3dadd(272.5, 1.5, -42.5, 3.8, sec = self.dend[245]) h.pt3dadd(275.5, 1.5, -42.5, 4, sec = self.dend[245]) h.pt3dadd(277.5, 2, -42.5, 4.4, sec = self.dend[245]) h.pt3dadd(280, 2, -42.5, 3.8, sec = self.dend[245]) h.pt3dadd(281.5, 2, -48.5, 3.6, sec = self.dend[245]) h.pt3dadd(283.5, 2, -48.5, 3.3, sec = self.dend[245]) h.pt3dadd(285.5, 2, -48.5, 3.3, sec = self.dend[245]) h.pt3dadd(288, 2, -48.5, 3.1, sec = self.dend[245]) h.pt3dadd(290, 2, -48.5, 2.5, sec = self.dend[245]) h.pt3dadd(290.5, 2.5, -48.5, 1.8, sec = self.dend[245]) h.pt3dadd(293.5, 3.5, -48.5, 2.5, sec = self.dend[245]) h.pt3dadd(295, 4, -48.5, 3.1, sec = self.dend[245]) h.pt3dadd(296.5, 3.5, -48.5, 3.7, sec = self.dend[245]) h.pt3dadd(298.5, 3.5, -48.5, 6.6, sec = self.dend[245]) h.pt3dadd(300, 3.5, -48.5, 6, sec = self.dend[245]) h.pt3dadd(302, 5, -48.5, 4.4, sec = self.dend[245]) h.pt3dadd(303.5, 5, -48.5, 3.4, sec = self.dend[245]) h.pt3dadd(305, 5, -55, 2.7, sec = self.dend[245]) h.pt3dadd(307, 4.5, -55, 3.3, sec = self.dend[245]) h.pt3dadd(310, 4.5, -48.5, 3.4, sec = self.dend[245]) h.pt3dadd(312, 3.5, -48.5, 3.7, sec = self.dend[245]) h.pt3dadd(314, 3.5, -48.5, 3.8, sec = self.dend[245]) h.pt3dadd(316, 3.5, -48.5, 3.8, sec = self.dend[245]) h.pt3dadd(318, 5, -55, 3.6, sec = self.dend[245]) h.pt3dadd(320, 6, -55, 3.6, sec = self.dend[245]) h.pt3dadd(321.5, 6, -55, 3.6, sec = self.dend[245]) h.pt3dadd(322.5, 6, -48.5, 4.4, sec = self.dend[245]) h.pt3dadd(325, 6.5, -48.5, 4, sec = self.dend[245]) h.pt3dadd(327, 6.5, -55, 3.1, sec = self.dend[245]) h.pt3dadd(329.5, 7, -55, 2.9, sec = self.dend[245]) h.pt3dadd(332, 7, -55, 3.3, sec = self.dend[245]) h.pt3dadd(333.5, 7, -55, 3.3, sec = self.dend[245]) h.pt3dadd(335, 7, -55, 2.8, sec = self.dend[245]) h.pt3dadd(337.5, 7.5, -55, 3.8, sec = self.dend[245]) h.pt3dadd(338.5, 8, -61, 4.1, sec = self.dend[245]) h.pt3dadd(340, 9.5, -61, 4.9, sec = self.dend[245]) h.pt3dadd(342, 9.5, -61, 4.9, sec = self.dend[245]) h.pt3dadd(344, 10.5, -61, 1.5, sec = self.dend[245]) h.pt3dadd(347, 10.5, -61, 1.4, sec = self.dend[245]) h.pt3dadd(348, 10.5, -61, 1.1, sec = self.dend[245]) h.pt3dadd(348.5, 12, -55, 1.2, sec = self.dend[245]) h.pt3dadd(350, 12, -61, 1.7, sec = self.dend[245]) h.pt3dadd(350.5, 12.5, -61, 2.1, sec = self.dend[245]) h.pt3dadd(351.5, 12.5, -61, 2.6, sec = self.dend[245]) h.pt3dadd(352.5, 14, -61, 2, sec = self.dend[245]) h.pt3dadd(354, 14, -61, 1.5, sec = self.dend[245]) h.pt3dadd(356.5, 14.5, -61, 0.9, sec = self.dend[245]) h.pt3dadd(358, 14.5, -61, 1.1, sec = self.dend[245]) h.pt3dadd(359.5, 14.5, -61, 1.7, sec = self.dend[245]) h.pt3dadd(361, 15.5, -61, 2.4, sec = self.dend[245]) h.pt3dadd(363, 15.5, -67.5, 3.4, sec = self.dend[245]) h.pt3dadd(365.5, 17, -61, 2.4, sec = self.dend[245]) h.pt3dadd(366.5, 16.5, -67.5, 1.9, sec = self.dend[245]) h.pt3dadd(369, 17, -67.5, 0.9, sec = self.dend[245]) h.pt3dadd(370.5, 15.5, -69.5, 1.6, sec = self.dend[245]) h.pt3dadd(373, 15, -67.5, 1.7, sec = self.dend[245]) h.pt3dadd(374.5, 14, -69.5, 1.7, sec = self.dend[245]) h.pt3dadd(376, 15, -69.5, 1.6, sec = self.dend[245]) h.pt3dadd(377, 15, -69.5, 2.1, sec = self.dend[245]) h.pt3dadd(379, 17, -65.5, 2.7, sec = self.dend[245]) h.pt3dadd(382, 16, -69.5, 4.3, sec = self.dend[245]) h.pt3dadd(384, 16, -67.5, 3.4, sec = self.dend[245]) h.pt3dclear(sec = self.dend[246]) h.pt3dadd(384, 16, -67.5, 3.4, sec = self.dend[246]) h.pt3dadd(387, 18.5, -65.5, 1.6, sec = self.dend[246]) h.pt3dadd(389, 19, -65.5, 1.2, sec = self.dend[246]) h.pt3dadd(391, 19.5, -65.5, 0.7, sec = self.dend[246]) h.pt3dadd(393.5, 22, -64, 0.9, sec = self.dend[246]) h.pt3dadd(397, 22, -64, 0.9, sec = self.dend[246]) h.pt3dadd(401, 22, -64, 0.9, sec = self.dend[246]) h.pt3dadd(405.5, 23.5, -65.5, 0.9, sec = self.dend[246]) h.pt3dadd(410.5, 23.5, -69.5, 0.9, sec = self.dend[246]) h.pt3dadd(410, 23.5, -64, 2.5, sec = self.dend[246]) h.pt3dadd(412.5, 23.5, -64, 1.8, sec = self.dend[246]) h.pt3dadd(415.5, 23.5, -65.5, 0.6, sec = self.dend[246]) h.pt3dadd(419, 23, -65.5, 0.6, sec = self.dend[246]) h.pt3dadd(422, 21.5, -65.5, 0.6, sec = self.dend[246]) h.pt3dadd(424.5, 21.5, -64, 1.9, sec = self.dend[246]) h.pt3dadd(425.5, 21, -60, 2.8, sec = self.dend[246]) h.pt3dadd(428, 19, -65.5, 1.6, sec = self.dend[246]) h.pt3dadd(428.5, 18.5, -65.5, 0.4, sec = self.dend[246]) h.pt3dadd(431.5, 16.5, -65.5, 0.7, sec = self.dend[246]) h.pt3dadd(433.5, 15.5, -65.5, 0.7, sec = self.dend[246]) h.pt3dadd(435, 14.5, -64, 2.3, sec = self.dend[246]) h.pt3dadd(436, 12.5, -65.5, 2.8, sec = self.dend[246]) h.pt3dadd(436.5, 11.5, -65.5, 2, sec = self.dend[246]) h.pt3dadd(438, 10.5, -65.5, 1, sec = self.dend[246]) h.pt3dadd(441.5, 9, -65.5, 1, sec = self.dend[246]) h.pt3dadd(442, 8, -65.5, 2.2, sec = self.dend[246]) h.pt3dadd(442.5, 6.5, -65.5, 2.4, sec = self.dend[246]) h.pt3dadd(444.5, 5.5, -64, 1.1, sec = self.dend[246]) h.pt3dadd(445, 5.5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(447.5, 5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(450.5, 3.5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(454.5, 3.5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(456.5, 2.5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(461, -1.5, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(463, -2, -69.5, 1.1, sec = self.dend[246]) h.pt3dadd(465.5, -2, -73.5, 2.6, sec = self.dend[246]) h.pt3dadd(467, -3.5, -71.5, 3.4, sec = self.dend[246]) h.pt3dadd(468.5, -5.5, -75.5, 2.3, sec = self.dend[246]) h.pt3dadd(471, -6.5, -79, 1.2, sec = self.dend[246]) h.pt3dadd(473, -8, -81, 1.1, sec = self.dend[246]) h.pt3dadd(475, -10.5, -81, 1.1, sec = self.dend[246]) h.pt3dadd(477.5, -13.5, -81, 0.7, sec = self.dend[246]) h.pt3dadd(481.5, -13.5, -81, 2, sec = self.dend[246]) h.pt3dadd(482.5, -13.5, -78, 1.2, sec = self.dend[246]) h.pt3dadd(484, -13.5, -78, 0.9, sec = self.dend[246]) h.pt3dadd(486, -13.5, -81, 0.9, sec = self.dend[246]) h.pt3dadd(488, -13.5, -81, 1.3, sec = self.dend[246]) h.pt3dadd(489, -12.5, -81, 1.9, sec = self.dend[246]) h.pt3dadd(492, -11.5, -81, 1.1, sec = self.dend[246]) h.pt3dadd(493, -11.5, -84, 0.6, sec = self.dend[246]) h.pt3dadd(495, -10.5, -81, 0.9, sec = self.dend[246]) h.pt3dadd(496, -10.5, -81, 1.6, sec = self.dend[246]) h.pt3dadd(498.5, -9.5, -81, 3.2, sec = self.dend[246]) h.pt3dadd(499, -9.5, -81, 2.7, sec = self.dend[246]) h.pt3dadd(500, -10.5, -81, 2.4, sec = self.dend[246]) h.pt3dadd(503, -10.5, -84, 0.2, sec = self.dend[246]) h.pt3dadd(503.5, -12, -84, 1.4, sec = self.dend[246]) h.pt3dadd(505.5, -12, -84, 1.8, sec = self.dend[246]) h.pt3dadd(506.5, -12.5, -84, 0.9, sec = self.dend[246]) h.pt3dadd(506.5, -12.5, -87, 0.1, sec = self.dend[246]) h.pt3dadd(507.5, -10.5, -84, 0.1, sec = self.dend[246]) h.pt3dadd(508.5, -11.5, -84, 1.2, sec = self.dend[246]) h.pt3dadd(511.5, -11.5, -81, 0.3, sec = self.dend[246]) h.pt3dadd(513, -11.5, -81, 0.7, sec = self.dend[246]) h.pt3dadd(514, -11.5, -87, 0.8, sec = self.dend[246]) h.pt3dadd(516.5, -12, -87, 0.9, sec = self.dend[246]) h.pt3dadd(517.5, -12.5, -87, 0.9, sec = self.dend[246]) h.pt3dadd(519.5, -13.5, -87, 0.9, sec = self.dend[246]) h.pt3dadd(521, -14.5, -87, 1.8, sec = self.dend[246]) h.pt3dadd(524, -14.5, -87, 3.1, sec = self.dend[246]) h.pt3dadd(526.5, -15, -93, 1.8, sec = self.dend[246]) h.pt3dadd(528.5, -15, -93, 0.2, sec = self.dend[246]) h.pt3dadd(530.5, -15.5, -93, 1, sec = self.dend[246]) h.pt3dadd(532.5, -15.5, -93, 1.2, sec = self.dend[246]) h.pt3dadd(533.5, -15.5, -93, 1.2, sec = self.dend[246]) h.pt3dadd(535, -15.5, -93, 0.1, sec = self.dend[246]) h.pt3dadd(537, -16, -96, 0.1, sec = self.dend[246]) h.pt3dadd(538.5, -16.5, -93, 2.1, sec = self.dend[246]) h.pt3dadd(541, -16.5, -93, 3.1, sec = self.dend[246]) h.pt3dadd(542.5, -18.5, -93, 1.3, sec = self.dend[246]) h.pt3dadd(545, -18, -93, 0.2, sec = self.dend[246]) h.pt3dadd(546.5, -17.5, -96, 0.9, sec = self.dend[246]) h.pt3dadd(548.5, -16.5, -98.5, 0.9, sec = self.dend[246]) h.pt3dadd(549.5, -16.5, -98.5, 0.9, sec = self.dend[246]) h.pt3dadd(550, -17, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(552, -17, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(554, -17, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(556.5, -17, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(559, -16.5, -101.5, 0.1, sec = self.dend[246]) h.pt3dadd(561.5, -16.5, -104.5, 0.1, sec = self.dend[246]) h.pt3dadd(562.5, -16, -101.5, 1.2, sec = self.dend[246]) h.pt3dadd(564.5, -16, -101.5, 2, sec = self.dend[246]) h.pt3dadd(566.5, -16, -98.5, 0.7, sec = self.dend[246]) h.pt3dadd(568, -16, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(570, -16, -98.5, 0.1, sec = self.dend[246]) h.pt3dadd(571, -15, -101.5, 1.4, sec = self.dend[246]) h.pt3dadd(574, -14.5, -101.5, 2.4, sec = self.dend[246]) h.pt3dadd(576, -14.5, -101.5, 0.7, sec = self.dend[246]) h.pt3dadd(578.5, -13.5, -101.5, 0.2, sec = self.dend[246]) h.pt3dadd(579, -13, -101.5, 0.2, sec = self.dend[246]) h.pt3dadd(582.5, -13, -101.5, 0.2, sec = self.dend[246]) h.pt3dadd(583.5, -14, -101.5, 0.2, sec = self.dend[246]) h.pt3dadd(590.5, -15, -104, 0.1, sec = self.dend[246]) h.pt3dadd(591.5, -15.5, -101.5, 1.1, sec = self.dend[246]) h.pt3dadd(594, -16, -104, 1.4, sec = self.dend[246]) h.pt3dadd(595.5, -18.5, -101.5, 1.1, sec = self.dend[246]) h.pt3dadd(596, -20, -104, 0.1, sec = self.dend[246]) h.pt3dadd(597.5, -20.5, -104, 0.1, sec = self.dend[246]) h.pt3dadd(601, -20.5, -104, 1.6, sec = self.dend[246]) h.pt3dadd(602, -21, -104, 1.1, sec = self.dend[246]) h.pt3dadd(603, -21, -106.5, 0.1, sec = self.dend[246]) h.pt3dadd(604, -22, -106.5, 0.1, sec = self.dend[246]) h.pt3dadd(605, -22, -106.5, 1.3, sec = self.dend[246]) h.pt3dadd(606, -22.5, -106.5, 2.2, sec = self.dend[246]) h.pt3dadd(607.5, -24.5, -106.5, 0.9, sec = self.dend[246]) h.pt3dadd(608.5, -24.5, -106.5, 0.1, sec = self.dend[246]) h.pt3dadd(613, -25.5, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(615, -26.5, -104, 1.1, sec = self.dend[246]) h.pt3dadd(615.5, -28, -104, 1.6, sec = self.dend[246]) h.pt3dadd(616.5, -28, -104, 2, sec = self.dend[246]) h.pt3dadd(617.5, -29.5, -108.5, 1.2, sec = self.dend[246]) h.pt3dadd(618, -29.5, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(621, -29.5, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(622, -31.5, -108.5, 1.3, sec = self.dend[246]) h.pt3dadd(623.5, -31.5, -108.5, 2, sec = self.dend[246]) h.pt3dadd(625.5, -32.5, -108.5, 0.3, sec = self.dend[246]) h.pt3dadd(626.5, -32.5, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(629, -33, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(630, -33, -111, 1.5, sec = self.dend[246]) h.pt3dadd(631.5, -36, -113.5, 1.2, sec = self.dend[246]) h.pt3dadd(633.5, -36, -113.5, 0.7, sec = self.dend[246]) h.pt3dadd(635.5, -36, -113.5, 0.4, sec = self.dend[246]) h.pt3dadd(638.5, -36, -113.5, 0.4, sec = self.dend[246]) h.pt3dadd(643, -36, -116, 0.4, sec = self.dend[246]) h.pt3dadd(645, -37, -108.5, 0.1, sec = self.dend[246]) h.pt3dadd(646, -38.5, -111, 0.1, sec = self.dend[246]) h.pt3dadd(648.5, -38.5, -106.5, 0.1, sec = self.dend[246]) h.pt3dadd(650, -35.5, -106.5, 0.1, sec = self.dend[246]) h.pt3dadd(651.5, -35.5, -108.5, 1.6, sec = self.dend[246]) h.pt3dadd(653, -35.5, -108.5, 0.8, sec = self.dend[246]) h.pt3dadd(654.5, -36, -111, 0.5, sec = self.dend[246]) h.pt3dadd(655.5, -36.5, -113.5, 0.6, sec = self.dend[246]) h.pt3dadd(657.5, -36.5, -113.5, 1.5, sec = self.dend[246]) h.pt3dadd(659.5, -37.5, -111, 1.9, sec = self.dend[246]) h.pt3dadd(661, -37.5, -111, 0.2, sec = self.dend[246]) h.pt3dadd(662, -38, -111, 0.1, sec = self.dend[246]) h.pt3dadd(664.5, -38, -111, 0.1, sec = self.dend[246]) h.pt3dadd(667, -39.5, -111, 1.6, sec = self.dend[246]) h.pt3dadd(668, -39.5, -113.5, 0.1, sec = self.dend[246]) h.pt3dadd(673, -41.5, -111, 0.1, sec = self.dend[246]) h.pt3dadd(673.5, -42, -111, 1.8, sec = self.dend[246]) h.pt3dadd(674.5, -44.5, -113.5, 2.7, sec = self.dend[246]) h.pt3dadd(675.5, -46.5, -111, 0.8, sec = self.dend[246]) h.pt3dadd(677, -46.5, -111, 0.1, sec = self.dend[246]) h.pt3dadd(681, -50.5, -111, 0.1, sec = self.dend[246]) h.pt3dadd(682, -51, -111, 1.3, sec = self.dend[246]) h.pt3dadd(682.5, -52.5, -111, 1.6, sec = self.dend[246]) h.pt3dadd(683.5, -53.5, -113.5, 0.1, sec = self.dend[246]) h.pt3dadd(685.5, -53.5, -113.5, 0.1, sec = self.dend[246]) h.pt3dadd(688, -53.5, -113.5, 0.1, sec = self.dend[246]) h.pt3dadd(689, -57, -108.5, 2.1, sec = self.dend[246]) h.pt3dadd(691.5, -57, -118, 0.1, sec = self.dend[246]) h.pt3dadd(691.5, -58.5, -118, 0.1, sec = self.dend[246]) h.pt3dadd(692, -60, -118, 0.1, sec = self.dend[246]) h.pt3dadd(692, -61.5, -118, 0.1, sec = self.dend[246]) h.pt3dadd(694, -66, -118, 0.1, sec = self.dend[246]) h.pt3dclear(sec = self.dend[247]) h.pt3dadd(384, 16, -67.5, 3.4, sec = self.dend[247]) h.pt3dadd(385.5, 15, -67.5, 2.7, sec = self.dend[247]) h.pt3dadd(386.5, 14, -69.5, 1.8, sec = self.dend[247]) h.pt3dadd(389.5, 13, -71.5, 2.3, sec = self.dend[247]) h.pt3dadd(390.5, 13.5, -73.5, 2.5, sec = self.dend[247]) h.pt3dadd(393, 13, -75.5, 3.5, sec = self.dend[247]) h.pt3dadd(395, 13, -75.5, 4, sec = self.dend[247]) h.pt3dadd(397, 11, -75.5, 2.7, sec = self.dend[247]) h.pt3dadd(398.5, 10, -75.5, 2, sec = self.dend[247]) h.pt3dadd(401.5, 8.5, -75.5, 2, sec = self.dend[247]) h.pt3dadd(403.5, 6, -75.5, 1.7, sec = self.dend[247]) h.pt3dadd(405.5, 6, -77, 1.9, sec = self.dend[247]) h.pt3dadd(407.5, 3.5, -79, 1.9, sec = self.dend[247]) h.pt3dadd(412, 2, -79, 2.6, sec = self.dend[247]) h.pt3dadd(413, 0.5, -79, 4.3, sec = self.dend[247]) h.pt3dadd(415, 0.5, -79, 3.8, sec = self.dend[247]) h.pt3dadd(416, -2, -82, 4, sec = self.dend[247]) h.pt3dadd(418, -1.5, -85, 2.8, sec = self.dend[247]) h.pt3dadd(420, -1, -85, 1.9, sec = self.dend[247]) h.pt3dadd(422.5, -1, -85, 1.8, sec = self.dend[247]) h.pt3dadd(424.5, -1, -88, 2.2, sec = self.dend[247]) h.pt3dadd(426, -1, -88, 2, sec = self.dend[247]) h.pt3dadd(428, -1.5, -88, 1.5, sec = self.dend[247]) h.pt3dadd(428.5, -3.5, -88, 1.1, sec = self.dend[247]) h.pt3dadd(429.5, -5.5, -88, 3.2, sec = self.dend[247]) h.pt3dadd(429.5, -8, -94, 3.2, sec = self.dend[247]) h.pt3dadd(431.5, -7.5, -97, 3.3, sec = self.dend[247]) h.pt3dadd(433.5, -6, -97, 2.4, sec = self.dend[247]) h.pt3dadd(434.5, -3, -97, 1.7, sec = self.dend[247]) h.pt3dadd(435.5, -2, -97, 1.7, sec = self.dend[247]) h.pt3dadd(439.5, 1.5, -99.5, 1.6, sec = self.dend[247]) h.pt3dadd(442, 1, -102, 1.4, sec = self.dend[247]) h.pt3dadd(443.5, 0, -102, 1.2, sec = self.dend[247]) h.pt3dadd(443.5, -0.5, -102, 2, sec = self.dend[247]) h.pt3dadd(446.5, -1.5, -104.5, 3, sec = self.dend[247]) h.pt3dadd(448, -3.5, -104.5, 3, sec = self.dend[247]) h.pt3dadd(450.5, -3.5, -106.5, 2.4, sec = self.dend[247]) h.pt3dadd(451.5, -3.5, -106.5, 2.4, sec = self.dend[247]) h.pt3dadd(452.5, -3.5, -109, 2.3, sec = self.dend[247]) h.pt3dadd(453.5, -3.5, -111.5, 2.3, sec = self.dend[247]) h.pt3dadd(454.5, -2.5, -109, 2.3, sec = self.dend[247]) h.pt3dadd(456, -2, -106.5, 2.3, sec = self.dend[247]) h.pt3dadd(458, -2, -106.5, 2.5, sec = self.dend[247]) h.pt3dadd(460, -2, -111.5, 2.5, sec = self.dend[247]) h.pt3dadd(461.5, -1.5, -109, 2.1, sec = self.dend[247]) h.pt3dadd(461, -3, -111.5, 1.2, sec = self.dend[247]) h.pt3dadd(461, -3.5, -109, 0.9, sec = self.dend[247]) h.pt3dadd(461.5, -4.5, -109, 0.9, sec = self.dend[247]) h.pt3dadd(463, -5, -109, 1.6, sec = self.dend[247]) h.pt3dadd(464.5, -5.5, -109, 1.8, sec = self.dend[247]) h.pt3dadd(466.5, -5.5, -114, 2.2, sec = self.dend[247]) h.pt3dadd(468.5, -6.5, -114, 1.7, sec = self.dend[247]) h.pt3dadd(470, -6.5, -114, 1.2, sec = self.dend[247]) h.pt3dadd(470.5, -7.5, -114, 0.9, sec = self.dend[247]) h.pt3dadd(472.5, -8.5, -116, 0.9, sec = self.dend[247]) h.pt3dadd(474.5, -11, -116, 0.9, sec = self.dend[247]) h.pt3dadd(474, -12.5, -121, 0.9, sec = self.dend[247]) h.pt3dadd(473, -14, -123.5, 0.9, sec = self.dend[247]) h.pt3dadd(471.5, -12.5, -121, 0.9, sec = self.dend[247]) h.pt3dadd(471.5, -12.5, -125.5, 1, sec = self.dend[247]) h.pt3dclear(sec = self.dend[248]) #h.pt3dstyle(1, 39.34, 29.98, -13.49, sec = self.dend[248]) h.pt3dadd(4.5, 24.5, -21, 6.7, sec = self.dend[248]) h.pt3dadd(1.5, 25.5, -22, 5.7, sec = self.dend[248]) h.pt3dadd(-1.5, 25.5, -22, 5.3, sec = self.dend[248]) h.pt3dadd(-3.5, 23.5, -25, 5.6, sec = self.dend[248]) h.pt3dadd(1.5, 27.5, -23, 3.8, sec = self.dend[248]) h.pt3dadd(2.5, 32.5, -23, 3.8, sec = self.dend[248])
penguinscontrol/Spinal-Cord-Modeling
Python/Mn_geometry_output3.py
Python
gpl-2.0
894,622
[ "NEURON" ]
d1854e182c641a477bacb540fb17c94146a38c41c12bcca86c9dcd6f5795d4f4
# tests/test_tensorflow_imagenet_adapter.py - unit test for the tensorflow ImageNet adapter. # # Copyright (c) 2017 SingularityNET # # Distributed under the MIT software license, see LICENSE file. # import logging import os from pathlib import Path import base64 import pytest from adapters.tensorflow.imagenet import TensorflowImageNet, IMAGENET_CLASSIFIER_ID from sn_agent import ontology as onto from sn_agent.job.job_descriptor import JobDescriptor from sn_agent.log import setup_logging from sn_agent.ontology.service_descriptor import ServiceDescriptor from sn_agent.service_adapter import setup_service_manager from sn_agent.test.mocks import MockApp log = logging.getLogger(__name__) TEST_DIRECTORY = Path(__file__).parent @pytest.fixture def app(): app = MockApp() onto.setup_ontology(app) return app def test_tensorflow_imagenet_adapter(app): setup_logging() log.debug("Testing Tensorflow ImageNet Adapter") # Load the bucket JPEG image and encode it base 64. image_path = os.path.join(TEST_DIRECTORY, "data", "imagenet", "bucket.jpg") image_file = open(image_path, 'rb') image_bytes = image_file.read() bucket_image_encoded = base64.b64encode(image_bytes) # Load the cup JPEG image and encode it base 64. image_path = os.path.join(TEST_DIRECTORY, "data", "imagenet", "cup.jpg") image_file = open(image_path, 'rb') image_bytes = image_file.read() cup_image_encoded = base64.b64encode(image_bytes) # Load the bowtie PNG image and encode it base 64. image_path = os.path.join(TEST_DIRECTORY, "data", "imagenet", "bowtie.png") image_file = open(image_path, 'rb') image_bytes = image_file.read() bowtie_image_encoded = base64.b64encode(image_bytes) # # Load the clock BMP image and encode it base 64. # image_path = os.path.join(TEST_DIRECTORY, "data", "imagenet", "clock.bmp") # image_file = open(image_path, 'rb') # image_bytes = image_file.read() # clock_image_encoded = base64.b64encode(image_bytes) # # # Load the coffeepot GIF image and encode it base 64. # image_path = os.path.join(TEST_DIRECTORY, "data", "imagenet", "coffeepot.gif") # image_file = open(image_path, 'rb') # image_bytes = image_file.read() # coffeepot_image_encoded = base64.b64encode(image_bytes) # Setup a test job for classifying a test images. We are going to test two images, a bucket # adnd a cup. job_parameters = { 'input_type': 'attached', 'input_data': { 'images': [bucket_image_encoded, cup_image_encoded, bowtie_image_encoded], 'image_types': ['jpg','jpeg','png'] }, 'output_type': 'attached', } # Get the service for an ImageNet classifier. A service identifies a unique service provided by # SingularityNET and is part of the ontology. ontology = app['ontology'] imagenet_service = ontology.get_service(IMAGENET_CLASSIFIER_ID) # Create the Tensorflow ImageNet service adapter. imagenet_service_adapter = TensorflowImageNet(app, imagenet_service) # Create a service descriptor. These are post-contract negotiated descriptors that may include # other parameters like quality of service, input and output formats, etc. imagenet_service_descriptor = ServiceDescriptor(IMAGENET_CLASSIFIER_ID) # Create a new job descriptor with a single set of parameters for the test image of a 7 in the # format defined above for the python variable: mnist_seven_image. job_list = [job_parameters] job = JobDescriptor(imagenet_service_descriptor, job_list) # Setup the service manager. NOTE: This will add services that are (optionally) passed in # so you can manually create services in addition to those that are loaded from the config # file. After all the services are added, it will call post_load_initialize on all the # services. setup_service_manager(app, [imagenet_service_adapter]) # Test perform for the ImageNet service adapter. try: exception_caught = False results = imagenet_service_adapter.perform(job) except RuntimeError as exception: exception_caught = True log.error(" Exception caught %s", exception) log.debug(" Error performing %s %s", job, imagenet_service_adapter) assert not exception_caught print(results) # Check our results for format and content. assert len(results) == 1 assert results[0]['predictions'] == [['bucket, pail'],['cup','coffee mug'],['bow tie, bow-tie, bowtie']] assert results[0]['confidences'][0][0] > 0.9600 and results[0]['confidences'][2][0] < 1.0 assert results[0]['confidences'][1][0] > 0.4000 and results[0]['confidences'][1][1] < 0.4200 assert results[0]['confidences'][1][1] > 0.4000 and results[0]['confidences'][1][1] < 0.4100 assert results[0]['confidences'][2][0] > 0.9990 and results[0]['confidences'][2][0] < 1.0
jensenbox/singnet
agent/tests/test_tensorflow_imagenet_adapter.py
Python
mit
5,023
[ "Bowtie" ]
5a8989ca72f357edf37d58b70ad608250c2b221d9e9ecac345bf6b712f2f7291
#!/usr/bin/env python """ Created on Fri Dec 5 10:41:33 2014 Author: Oren Freifeld Email: freifeld@csail.mit.edu """ import numpy as np from pylab import plt from cpab.cpa2d.inference.transformation.Register import Register from of.utils import * import pylab from get_data import get_data if not inside_spyder(): pylab.ion() def main(data,infernece_params,dispOn ): img1=data.img1 # src img2=data.img2 # dst if img1.shape != img2.shape: raise ValueError(img1.shape,img2.shape) nRows,nCols = img1.shape[:2] nPts = nRows * nCols reg = Register(nRows=nRows, nCols=nCols, base=inference_params.base, nLevels=inference_params.nLevels, tess='I', zero_v_across_bdry=[False,False], sigma_signal=inference_params.sigma_signal , scale_spatial=inference_params.scale_spatial, scale_value=inference_params.scale_value, wlp=inference_params.wlp, ll_type=inference_params.ll_type, only_local=False, valid_outside=infernece_params.valid_outside) reg.set_dense(domain_start=0,domain_end=nPts) reg.set_data(x=reg.tw.pts_src_dense, signal_src=img1,signal_dst=img2, isbinary=inference_params.isbinary) print reg # reg.set_run_lengths([50000]*reg.nLevels) reg.set_run_lengths([infernece_params.MCMCniters_per_level]*reg.nLevels) # if inside_spyder(): # reg.set_run_lengths([100]*reg.nLevels) # # reg.set_run_lengths([50000]*reg.nLevels) # else: # reg.set_run_lengths(run_lengths) theta_est,inference_record = reg.fit(use_prior=infernece_params.use_prior, use_local=infernece_params.use_local, dispOn=dispOn, #interp_type_for_ll=cv2.INTER_LANCZOS4, interp_type_for_ll= 'gpu_linear', interp_type_during_visualization=cv2.INTER_LANCZOS4) if dispOn: plt.figure(1000) plt.clf() reg.plot_inference_summary(inference_record) reg.transformed.gpu2cpu() reg.signal.transformed.gpu2cpu() inference_record.transformed = reg.transformed.cpu inference_record.src = reg.src.cpu inference_record.signal = Bunch() inference_record.signal.src = reg.signal.src.cpu inference_record.signal.dst = reg.signal.dst.cpu inference_record.signal.transformed = reg.signal.transformed.cpu # if TF.dump_results: # Pkl.dump(results_filename,inference_record,create_dir_if_needed=1,override=1) return reg,inference_record,theta_est if __name__ == "__main__": # from pyvision.essentials import * import cv2 class InferenceParamsDefault(object): MCMCniters_per_level = 10000 isbinary = False valid_outside=True # values for the prior scale_spatial = 10 # the larger the smoother scale_value = 500 # variance wlp=1e-3 # weight of log prior use_prior=True use_local = True base=[2,2] nLevels=3 imresize_factor = 2 # >1 is upsamplling. # <1 is downsampling # # class InferenceParams(InferenceParamsDefault): # def __init__(self): ## self.base=[2,2];self.nLevels=2 ## self.base=[3,3];self.nLevels=3 ### self.base=[9,9];self.nLevels=1;self.MCMCniters_per_level=30000 ## self.base=[9,9];self.nLevels=1;self.MCMCniters_per_level=50000 # self.base=[8,8];self.nLevels=1;self.MCMCniters_per_level=20000 ## self.base=[4,4];self.nLevels=2;self.MCMCniters_per_level=10000 ## self.base=[2,2];self.nLevels=1;self.MCMCniters_per_level=1000 # ## self.base=[1,1] # # self.imresize_factor=1.5 ## self.imresize_factor=2 # # self.isbinary=False # if self.isbinary: # self.sigma_signal = 1 * self.imresize_factor # else: # self.sigma_signal = 50 # self.ll_type=['gaussian','gaussian_on_distancetransform'][self.isbinary] # class InferenceParams(InferenceParamsDefault): def __init__(self): self.base = [4,4]; self.nLevels = 1; self.MCMCniters_per_level = 10000 self.imresize_factor = 1.5 self.isbinary=False if self.isbinary: self.sigma_signal = 1 * self.imresize_factor else: self.sigma_signal = 50 self.ll_type=['gaussian','gaussian_on_distancetransform'][self.isbinary] inference_params = InferenceParams() name='MNIST_one_00001_to_00015' # name = 'MNIST_four_00009_to_00013' name = 'MNIST_four_00013_to_00009' # name = 'MNIST_four_00022_to_00009' data = get_data(name=name, imresize_factor=inference_params.imresize_factor) dname_results = os.path.join(HOME,'data/derived/MNIST/examples',name) FilesDirs.mkdirs_if_needed(dname_results) # fname_results = os.path.join(dname_results ,get_time_stamp()+'.pkl') fname_results = os.path.join(dname_results ,'result.pkl') dispOn = False or 1 reg,inference_record,theta_est = main(data,inference_params,dispOn=dispOn) tosave = {'tw_args':inference_record.tw_args, 'theta':inference_record.theta, 'signal':inference_record.signal, 'imresize_factor':inference_params.imresize_factor} tosave = Bunch(**tosave) Pkl.dump(fname_results,tosave,override=True) if not inside_spyder(): raw_input("Press Enter to exit")
freifeld/cpabDiffeo
cpab/cpa2d/apps/register/register_images_MNIST.py
Python
mit
6,138
[ "Gaussian" ]
9ef539668b18ccfb91771beea53908b8e48d6159fa21525ccc15a3bd3c6928b0
# Lint as: python2, python3 # Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Encoders for the machine translation model.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import math import REDACTED.transformer_lingvo.lingvo.compat as tf from REDACTED.transformer_lingvo.lingvo.core import base_layer from REDACTED.transformer_lingvo.lingvo.core import batch_major_attention from REDACTED.transformer_lingvo.lingvo.core import layers from REDACTED.transformer_lingvo.lingvo.core import model_helper from REDACTED.transformer_lingvo.lingvo.core import py_utils from REDACTED.transformer_lingvo.lingvo.core import rnn_cell from REDACTED.transformer_lingvo.lingvo.core import summary_utils from REDACTED.transformer_lingvo.lingvo.tasks.mt import layers as mt_layers from six.moves import range tf.flags.DEFINE_bool('transformer_encoder_truncates_inputs', False, 'Whether TransformerEncoder truncates inputs to max len.') class MTEncoderV1(base_layer.BaseLayer): """Machine translation encoder version 1.""" @classmethod def Params(cls): """Configs for `MTEncoderV1`.""" p = super(MTEncoderV1, cls).Params() p.Define('emb', layers.EmbeddingLayer.Params(), 'Embedding layer params.') p.Define('lstm_tpl', rnn_cell.LSTMCellSimple.Params(), 'Configs template for the RNN layer.') p.Define('lstm_tpl_uni', None, 'Override configs template for the unidirectional RNN layers.') p.Define('lstm_tpl_bidi', None, 'Override configs template for the bidirectional RNN layer.') p.Define('lstm_cell_size', 1024, 'LSTM cell size for the RNN layer.') p.Define('num_lstm_layers', 8, 'Number of rnn layers to create') p.Define('dropout_prob', 0.0, 'Prob at which we do dropout.') p.Define('unidi_rnn_type', 'func', 'Options: func. ' 'func: FRNN.') p.Define('bidi_rnn_type', 'func', 'Options: func. ' 'func: BidirectionalFRNN. ') p.Define('cc_schedule', None, 'Clipping cap schedule.') p.Define( 'packed_input', False, 'If True, encoder and all layers support ' 'multiple examples in a single sequence.') disable_vn = py_utils.VariationalNoiseParams(1.0, False, False) default_params_init = py_utils.WeightInit.Uniform(0.04) # Default config for the embedding. p.emb.vn = disable_vn p.emb.vocab_size = 32000 p.emb.embedding_dim = 1024 p.emb.max_num_shards = 16 p.emb.params_init = default_params_init for tpl in [p.lstm_tpl, p.lstm_tpl_uni, p.lstm_tpl_bidi]: if tpl is not None: tpl.vn = disable_vn tpl.params_init = default_params_init return p @base_layer.initializer def __init__(self, params): super(MTEncoderV1, self).__init__(params) p = self.params assert not p.packed_input, ('Packed inputs are not yet supported for ' 'MTEncoderV1.') with tf.variable_scope(p.name): if p.cc_schedule is not None: self.CreateChild('cc_schedule', p.cc_schedule) self.CreateChild('emb', p.emb) rnn_layers_params = [] # L0 is a bi-directional lstm. # L0's forward lstm cell if p.lstm_tpl_bidi is None: params = p.lstm_tpl.Copy() else: params = p.lstm_tpl_bidi.Copy() params.name = 'L0_rnn_fwd' params.num_input_nodes = p.emb.embedding_dim params.num_output_nodes = p.lstm_cell_size forward_lstm = params # L0's backward lstm cell params = params.Copy() params.name = 'L0_rnn_bak' backward_lstm = params # L0 layer. params = model_helper.CreateBidirectionalRNNParams( self.params, forward_lstm, backward_lstm) params.name = 'L0' rnn_layers_params.append(params) # The latter layers are all uni-directional lstm. input_size = 2 * p.lstm_cell_size for i in range(1, p.num_lstm_layers): # Forward lstm cell. if p.lstm_tpl_uni is None: cell = p.lstm_tpl.Copy() else: cell = p.lstm_tpl_uni.Copy() cell.name = 'L%d_rnn' % i cell.num_input_nodes = input_size cell.num_output_nodes = p.lstm_cell_size # Forward lstm layer. params = model_helper.CreateUnidirectionalRNNParams(self.params, cell) params.name = 'L%d' % i rnn_layers_params.append(params) input_size = p.lstm_cell_size self.CreateChildren('rnn', rnn_layers_params) dropout_p = layers.DropoutLayer.Params().Set( name='dropout_layer', keep_prob=1.0 - p.dropout_prob, random_seed=p.random_seed + 84828474 if p.random_seed else None) self.CreateChild('dropout', dropout_p) def ApplyClipping(self, theta, x): p = self.params if not p.cc_schedule: return x cap = tf.cast(self.cc_schedule.GetState(theta.cc_schedule), x.dtype) return tf.clip_by_value(x, -cap, cap) def FProp(self, theta, input_batch): """Encodes source as represented by `inputs` and `paddings`. Args: theta: A `.NestedMap` object containing weights' values of this layer and its children layers. input_batch: A `.NestedMap` with fields: - ids: The inputs tensor. It is expected to be of shape [batch, time]. - paddings: The paddings tensor. Expected shape [batch, time]. Returns: A NestedMap containing: - encoded: The encoded features, a tensor of shape [time, batch, depth] - padding: of shape [time, batch] - segment_id: [time, batch] if packed inputs are supported by the model (and all layers), or None otherwise. """ p = self.params src_segment_id = None with tf.name_scope(p.name): # Now the rnn layers. inputs = py_utils.with_dependencies([ py_utils.assert_shape_match(tf.shape(input_batch.ids), [-1, -1]), py_utils.assert_shape_match( tf.shape(input_batch.ids), tf.shape(input_batch.paddings)) ], tf.transpose(input_batch.ids)) paddings = tf.expand_dims(tf.transpose(input_batch.paddings), 2) xs = self.emb.EmbLookup(theta.emb, inputs) xs = self.ApplyClipping(theta, xs) self._emb_out = xs ps = paddings # When cc_schedule is specified, make sure lstm_tpl is QuantizedLSTMCell # with the same cc_schedule so that the RNN layer output is within # clipping range. xs = self.rnn[0].FProp(theta.rnn[0], xs, ps) xs = self.dropout.FProp(theta.dropout, xs) for i in range(1, p.num_lstm_layers): layer = self.rnn[i] ys, _ = layer.FProp(theta.rnn[i], xs, ps) ys = self.dropout.FProp(theta.dropout, ys) if hasattr(layer.params, 'cell'): layer_params = layer.params.cell else: layer_params = layer.params if layer_params.num_input_nodes == layer_params.num_output_nodes: xs += ys # Residual skip xs = self.ApplyClipping(theta, xs) else: # When cc_schedule is specified, make sure lstm_tpl is # QuantizedLSTMCell with the same cc_schedule so that the RNN layer # output is within clipping range. xs = ys return py_utils.NestedMap( encoded=xs, padding=tf.squeeze(ps, [2]), segment_id=src_segment_id) class MTEncoderUniRNN(base_layer.BaseLayer): """MT encoder that consists of a stack of uni-directional RNN layers.""" @classmethod def Params(cls): """Configs for `MTEncoderUniRNN`.""" p = super(MTEncoderUniRNN, cls).Params() p.Define('emb', layers.EmbeddingLayer.Params(), 'Embedding layer params.') p.Define('lstm_tpl', rnn_cell.LSTMCellSimple.Params(), 'Configs template for the RNN layer.') p.Define('lstm_cell_size', 512, 'LSTM cell size for the RNN layer.') p.Define('num_lstm_layers', 8, 'Number of rnn layers to create') p.Define('dropout_prob', 0.0, 'Prob at which we do dropout.') p.Define('residual_start', 2, 'Layer at which we start residual connections.') p.Define('unidi_rnn_type', 'func', 'Options: func. ' 'func: FRNN.') p.Define('cc_schedule', None, 'Clipping cap schedule.') p.Define('is_transparent', False, 'If set, outputs a merger of layer outputs.') p.Define('transparent_merger_tpl', layers.WeightedSumLayer.Params().Set(add_weight_summaries=True), 'Merger op for layer outputs.') p.Define( 'packed_input', False, 'If True, encoder and all layers support ' 'multiple examples in a single sequence.') disable_vn = py_utils.VariationalNoiseParams(1.0, False, False) default_params_init = py_utils.WeightInit.Uniform(0.04) # Default config for the embedding. p.emb.vn = disable_vn p.emb.vocab_size = 32000 p.emb.embedding_dim = 1024 p.emb.max_num_shards = 16 p.emb.params_init = default_params_init p.lstm_tpl.vn = disable_vn p.lstm_tpl.params_init = default_params_init return p @base_layer.initializer def __init__(self, params): super(MTEncoderUniRNN, self).__init__(params) p = self.params assert not p.packed_input, ('Packed inputs are not yet supported for ' 'MTEncoderUniRNN.') with tf.variable_scope(p.name): if p.cc_schedule is None: self.cc_schedule = None else: self.CreateChild('cc_schedule', p.cc_schedule) self.CreateChild('emb', p.emb) rnn_layers_params = [] num_input_nodes = p.emb.embedding_dim for i in range(p.num_lstm_layers): cell = p.lstm_tpl.Copy() cell.name = 'L%d_rnn' % i cell.num_input_nodes = num_input_nodes cell.num_output_nodes = p.lstm_cell_size params = model_helper.CreateUnidirectionalRNNParams(self.params, cell) params.name = 'L%d' % i rnn_layers_params.append(params) num_input_nodes = cell.num_output_nodes self.CreateChildren('rnn', rnn_layers_params) dropout_p = layers.DropoutLayer.Params().Set( name='dropout_layer', keep_prob=1.0 - p.dropout_prob, random_seed=p.random_seed + 827366448 if p.random_seed else None) self.CreateChild('dropout', dropout_p) if p.is_transparent: transparent_params = p.transparent_merger_tpl.Copy() transparent_params.name = 'transparent' transparent_params.num_sources = p.num_lstm_layers self.CreateChild('transparent_merger', transparent_params) def ApplyClipping(self, theta, x): if self.cc_schedule: return self.cc_schedule.ApplyClipping(theta.cc_schedule, x) else: return x def zero_state(self, theta, batch_size): return py_utils.NestedMap(rnn=[ self.rnn[i].zero_state(theta.rnn[i], batch_size) for i in range(len(self.rnn)) ]) def FProp(self, theta, input_batch, state0=None): p = self.params src_segment_id = None with tf.name_scope(p.name): # Reshape to [t, b] inputs = py_utils.with_dependencies([ py_utils.assert_shape_match(tf.shape(input_batch.ids), [-1, -1]), py_utils.assert_shape_match( tf.shape(input_batch.ids), tf.shape(input_batch.paddings)) ], tf.transpose(input_batch.ids)) paddings = tf.expand_dims(tf.transpose(input_batch.paddings), 2) # Setup streaming states. if not state0: state0 = self.zero_state(theta, tf.shape(inputs)[1]) state1 = py_utils.NestedMap(rnn=[None] * p.num_lstm_layers) xs = self.emb.EmbLookup(theta.emb, inputs) xs = self.ApplyClipping(theta, xs) summary_utils.histogram('input_emb', xs) xs = self.dropout.FProp(theta.dropout, xs) ps = paddings # Now the rnn layers. outputs_list = [] for i in range(0, p.num_lstm_layers): layer = self.rnn[i] ys, state1.rnn[i] = layer.FProp( theta.rnn[i], xs, ps, state0=state0.rnn[i]) ys = self.dropout.FProp(theta.dropout, ys) if i >= p.residual_start: xs += ys # Residual skip xs = self.ApplyClipping(theta, xs) else: xs = ys outputs_list.append(xs) summary_utils.histogram('layer_out_%s' % i, xs) if p.is_transparent: xs = self.transparent_merger.FProp(theta.transparent_merger, outputs_list) return py_utils.NestedMap( encoded=xs, padding=tf.squeeze(ps, [2]), segment_id=src_segment_id, state=state1) class MTEncoderBiRNN(base_layer.BaseLayer): """MT encoder that consists of a stack of bi-directional RNN layers.""" @classmethod def Params(cls): """Configs for `MTEncoderBiRNN`.""" p = super(MTEncoderBiRNN, cls).Params() p.Define('emb', layers.EmbeddingLayer.Params(), 'Embedding layer params.') p.Define('lstm_tpl', rnn_cell.LSTMCellSimple.Params(), 'Configs template for the RNN layer.') p.Define('proj_tpl', layers.ProjectionLayer.Params(), 'Configs template for the projection layer.') p.Define('lstm_cell_size', 512, 'LSTM cell size for the RNN layer.') p.Define('num_lstm_layers', 8, 'Number of rnn layers to create') p.Define('dropout_prob', 0.0, 'Prob at which we do dropout.') p.Define('residual_start', 2, 'Layer at which we start residual connections.') p.Define('encoder_out_dim', 1024, 'Depth of the encoder output.') p.Define('bidi_rnn_type', 'func', 'Options: func. ' 'func: BidirectionalFRNN. ') p.Define('cc_schedule', None, 'Clipping cap schedule.') p.Define('is_transparent', False, 'If set, outputs a merger of layer outputs.') p.Define('transparent_merger_tpl', layers.WeightedSumLayer.Params().Set(add_weight_summaries=True), 'Merger op for layer outputs.') p.Define( 'packed_input', False, 'If True, encoder and all layers support ' 'multiple examples in a single sequence.') disable_vn = py_utils.VariationalNoiseParams(1.0, False, False) default_params_init = py_utils.WeightInit.Uniform(0.04) # Default config for the embedding. p.emb.vn = disable_vn p.emb.vocab_size = 32000 p.emb.embedding_dim = 1024 p.emb.max_num_shards = 16 p.emb.params_init = default_params_init p.lstm_tpl.vn = disable_vn p.lstm_tpl.params_init = default_params_init return p @base_layer.initializer def __init__(self, params): super(MTEncoderBiRNN, self).__init__(params) p = self.params with tf.variable_scope(p.name): if p.cc_schedule is None: self.cc_schedule = None else: self.CreateChild('cc_schedule', p.cc_schedule) self.CreateChild('emb', p.emb) rnn_layers_params = [] for i in range(p.num_lstm_layers): params = p.lstm_tpl.Copy() params.name = 'L%d_rnn_fwd' % i if i == 0: params.num_input_nodes = p.emb.embedding_dim else: params.num_input_nodes = 2 * p.lstm_cell_size params.num_output_nodes = p.lstm_cell_size params.reset_cell_state = p.packed_input forward_lstm = params params = params.Copy() params.name = 'L%d_rnn_bak' % i params.reset_cell_state = p.packed_input backward_lstm = params params = model_helper.CreateBidirectionalRNNParams( self.params, forward_lstm, backward_lstm) params.packed_input = p.packed_input params.name = 'L%d' % i rnn_layers_params.append(params) self.CreateChildren('rnn', rnn_layers_params) if p.lstm_cell_size * 2 != p.encoder_out_dim: # Project the encoder output to the desired dim. proj_p = p.proj_tpl.Copy().Set( name='proj', batch_norm=False, input_dim=p.lstm_cell_size * 2, output_dim=p.encoder_out_dim) if p.cc_schedule is not None: proj_p.has_bias = False proj_p.activation = 'TANH' else: proj_p.has_bias = True proj_p.activation = 'NONE' self.CreateChild('final_proj', proj_p) dropout_p = layers.DropoutLayer.Params().Set( name='dropout_layer', keep_prob=1.0 - p.dropout_prob, random_seed=p.random_seed + 827366448 if p.random_seed else None) self.CreateChild('dropout', dropout_p) if p.is_transparent: transparent_params = p.transparent_merger_tpl.Copy() transparent_params.name = 'transparent' transparent_params.num_sources = p.num_lstm_layers self.CreateChild('transparent_merger', transparent_params) def ApplyClipping(self, theta, x): if self.cc_schedule: return self.cc_schedule.ApplyClipping(theta.cc_schedule, x) else: return x def FProp(self, theta, input_batch): p = self.params with tf.name_scope(p.name): inputs = py_utils.with_dependencies([ py_utils.assert_shape_match(tf.shape(input_batch.ids), [-1, -1]), py_utils.assert_shape_match( tf.shape(input_batch.ids), tf.shape(input_batch.paddings)) ], tf.transpose(input_batch.ids)) paddings = tf.expand_dims(tf.transpose(input_batch.paddings), 2) if p.packed_input: src_segment_id = tf.expand_dims( tf.transpose(input_batch.segment_ids), 2) else: src_segment_id = None xs = self.emb.EmbLookup(theta.emb, inputs) xs = self.ApplyClipping(theta, xs) summary_utils.histogram('input_emb', xs) xs = self.dropout.FProp(theta.dropout, xs) ps = paddings # Now the rnn layers. outputs_list = [] for i in range(0, p.num_lstm_layers): layer = self.rnn[i] ys = layer.FProp(theta.rnn[i], xs, ps, segment_id=src_segment_id) ys = self.dropout.FProp(theta.dropout, ys) if i >= p.residual_start: xs += ys # Residual skip xs = self.ApplyClipping(theta, xs) else: xs = ys outputs_list.append(xs) summary_utils.histogram('layer_out_%s' % i, xs) if p.is_transparent: xs = self.transparent_merger.FProp(theta.transparent_merger, outputs_list) if p.lstm_cell_size * 2 != p.encoder_out_dim: # Project to the right depth. xs = self.final_proj.FProp(theta.final_proj, xs, ps) summary_utils.histogram('final_proj_out', xs) if src_segment_id is not None: src_segment_id = tf.squeeze(src_segment_id, [2]) return py_utils.NestedMap( encoded=xs, padding=tf.squeeze(ps, [2]), segment_id=src_segment_id) class TransformerEncoder(base_layer.BaseLayer): """Transformer stack with sinusoidal positional embeddings and attention. Implements the encoder of 'Attention is All You Need': https://arxiv.org/abs/1706.03762. """ @classmethod def Params(cls): """Configs for `TransformerEncoder`.""" p = super(TransformerEncoder, cls).Params() # Embedding related p.Define( 'token_emb', layers.EmbeddingLayer.Params().Set( vocab_size=32000, embedding_dim=1024, max_num_shards=16, params_init=py_utils.WeightInit.Gaussian(1.0 / math.sqrt(1024)), scale_sqrt_depth=True), 'Embedding layer params.') p.Define('shared_emb', None, 'Embedding shared with Decoder.') # Positional embedding related p.Define('position_emb', layers.PositionalEmbeddingLayer.Params().Set(embedding_dim=1024), 'Positional Embedding layer params.') # TODO(miachen): Extend this to more general logic of adding multiple # embedding fields. # Task embedding related p.Define('task_emb', None, 'Task embedding layer params.') p.Define('model_dim', 1024, 'Characteristic depth (dimension).') p.Define('input_dropout_prob', 0.0, 'Prob at which we do input dropout.') p.Define('transformer_stack', mt_layers.TransformerStack.Params(), 'TransformerStack layer params.') p.Define( 'packed_input', False, 'If True, encoder and all layers support ' 'multiple examples in a single sequence.') # MASS pretraining related (https://github.com/microsoft/MASS). p.Define( 'apply_source_mask', False, 'If True, apply source mask ' '(corresponding to those masked words) to encoder states.') p.Define( 'source_mask_id', 0, 'Id for masked words in source inputs. ' 'Only needed when p.apply_source_mask is True.') p.transformer_stack.num_transformer_layers = 6 p.transformer_stack.transformer_tpl.tr_atten_tpl.num_attention_heads = 8 p.transformer_stack.transformer_tpl.tr_fflayer_tpl.hidden_dim = 8192 return p @base_layer.initializer def __init__(self, params): super(TransformerEncoder, self).__init__(params) p = self.params if p.shared_emb: with tf.variable_scope('shared_emb', reuse=tf.AUTO_REUSE): # Naming this 'softmax' to match the name of the same component in the # decoder. Variable names need to be the same in order to be reused. self.CreateChild('softmax', p.shared_emb) with tf.variable_scope(p.name): assert p.token_emb.embedding_dim == p.position_emb.embedding_dim p.transformer_stack.Set( model_dim=p.model_dim, packed_input=p.packed_input) if p.model_dim != p.token_emb.embedding_dim: tf.logging.warning('token_emb.embedding_dim != model_dim (%s vs. %s), ' 'creating a projection!') proj_p = layers.ProjectionLayer.Params().Copy() proj_p.name = 'emb_proj' proj_p.input_dim = p.token_emb.embedding_dim proj_p.output_dim = p.model_dim proj_p.batch_norm = True self.CreateChild('emb_proj', proj_p) # Token embeddings if not p.shared_emb: p.token_emb.dtype = p.dtype self.CreateChild('token_emb', p.token_emb) # Positional embeddings self.CreateChild('position_emb', p.position_emb) # Task embeddings. if p.task_emb: assert p.task_emb.embedding_dim == p.token_emb.embedding_dim self.CreateChild('task_emb', p.task_emb) dropout_tpl = layers.DropoutLayer.Params() dropout_tpl.keep_prob = (1.0 - p.input_dropout_prob) self.CreateChild('input_dropout', dropout_tpl) p.transformer_stack.name = p.name self.CreateChild('transformer_stack', p.transformer_stack) def FProp(self, theta, input_batch): """Embeds source ids and transforms with TransformerStack. Args: theta: A `.NestedMap` object containing weights' values of this layer and its children layers. input_batch: A `.NestedMap` with fields: - ids: The inputs tensor. It is expected to be of shape [batch, time]. - paddings: The paddings tensor. Expected shape [batch, time]. - task_ids: If p.task_emb is provided, must contain per-token task ids of shape [batch, time]. Returns: A NestedMap containing - encoded: The encoded features, either a tensor of shape [time, batch, depth], or a list of tensors if is_transparent is set in transformer_stack. - padding: of shape [time, batch] - segment_id: [time, batch] if packed inputs are supported by the model (and all layers), or None otherwise. - embedded_inputs: [time, batch, depth] embedded inputs tokens without positional encodings. """ p = self.params with tf.name_scope(p.name): src_segment_id = None src_segment_pos = None input_ids = py_utils.with_dependencies([ py_utils.assert_shape_match( tf.shape(input_batch.ids), tf.shape(input_batch.paddings)), py_utils.assert_equal(tf.rank(input_batch.ids), 2) ], input_batch.ids) if (not py_utils.use_tpu() and tf.flags.FLAGS.transformer_encoder_truncates_inputs): max_seq_length = tf.cast( tf.reduce_max(tf.reduce_sum(1.0 - input_batch.paddings, 1)), tf.int32) paddings = py_utils.with_dependencies([ py_utils.assert_equal( tf.constant(True, tf.bool), tf.reduce_all(input_batch.paddings[:, max_seq_length:] > 0.5)) ], input_batch.paddings) input_ids = input_ids[:, :max_seq_length] paddings = paddings[:, :max_seq_length] if p.packed_input: src_segment_id = input_batch.segment_ids[:, :max_seq_length] src_segment_pos = input_batch.segment_pos[:, :max_seq_length] else: paddings = input_batch.paddings if p.packed_input: src_segment_id = input_batch.segment_ids src_segment_pos = input_batch.segment_pos max_time = tf.shape(input_ids)[1] # Input token embeddings + positional embeddings if not p.shared_emb: input_embs = self.token_emb.EmbLookup(theta.token_emb, tf.reshape(input_ids, [-1])) else: input_embs = self.softmax.EmbLookup(theta.softmax, tf.reshape(input_ids, [-1])) input_embs = tf.reshape(input_embs, [-1, max_time, p.token_emb.embedding_dim]) # [time, batch, dim] orig_input_embs = tf.transpose(input_embs, [1, 0, 2]) if p.packed_input: position_embs = self.position_emb.FPropWithPosition( theta.position_emb, src_segment_pos) else: position_embs = self.position_emb.FProp(theta.position_emb, max_time) position_embs = tf.reshape(position_embs, [1, max_time, p.token_emb.embedding_dim]) input_embs += position_embs if p.task_emb: input_embs += self.task_emb.EmbLookup(theta.task_emb, input_batch.task_ids) if p.model_dim != p.token_emb.embedding_dim: input_embs = self.emb_proj.FProp(theta.emb_proj, input_embs) paddings = tf.cast(tf.transpose(paddings), py_utils.FPropDtype(p)) if p.packed_input: src_segment_id = tf.transpose(src_segment_id) input_embs = self.input_dropout.FProp(theta.input_dropout, input_embs) # [time, batch, dim] transformer_input = tf.transpose(input_embs, [1, 0, 2]) if not self.do_eval and p.apply_source_mask: # Augment padding for masked source word positions. dtype = paddings.dtype source_mask = tf.where( tf.equal(input_ids, p.source_mask_id), tf.ones_like(input_ids, dtype=dtype), tf.zeros_like(input_ids, dtype=dtype)) # Make sure padding is between 0 and 1. paddings = tf.clip_by_value(paddings + tf.transpose(source_mask), 0.0, 1.0) encoded, padding, segment_id = self.transformer_stack.FProp( theta.transformer_stack, transformer_input, paddings, src_segment_id) return py_utils.NestedMap( encoded=encoded, padding=padding, segment_id=segment_id, embedded_inputs=orig_input_embs) def FPropFullSequence(self, theta, ids, paddings): return self.FProp(theta, py_utils.NestedMap(ids=ids, paddings=paddings))['encoded'] class TransformerBatchMajorEncoder(base_layer.BaseLayer): """Transformer encoder with batch major implementation. This encoder first applies dropout to the input embeddings, then returns encoded output produced by p.transformer_stack using self_attention_layer builder. Example definition for a stack of 6 transformer layers: builder_params = self_attention_layer.Builder.Params().Set( model_dim=model_dim, ff_hidden_dim=ff_hidden_dim, num_heads=num_heads, selfatten_add_unnormalized_input=False, selfatten_enable_value_proj=True) p.transformer_stack = builder_params.Instantiate().TransformerStack( 'transformer_stack', 6) Implements the encoder of 'Attention is All You Need': https://arxiv.org/abs/1706.03762. """ @classmethod def Params(cls): p = super(TransformerBatchMajorEncoder, cls).Params() # Default config for the token embedding. p.Define( 'token_emb', layers.EmbeddingLayer.Params().Set( vocab_size=32000, embedding_dim=1024, max_num_shards=16, params_init=py_utils.WeightInit.Gaussian(1.0 / math.sqrt(1024)), scale_sqrt_depth=True), 'Embedding layer params.') p.Define('shared_emb', None, 'Embedding shared with Decoder.') # Default config for the position embedding. p.Define('position_emb', layers.PositionalEmbeddingLayer.Params().Set(embedding_dim=1024), 'Positional Embedding layer params.') p.Define('model_dim', 1024, 'Characteristic depth (dimension).') p.Define('input_dropout_prob', 0.0, 'Prob at which we do input dropout.') p.Define('input_dropout_tpl', layers.DropoutLayer.Params(), 'Input dropout layer params.') p.Define('transformer_stack', None, 'TransformerStack layer params.') p.Define( 'packed_input', False, 'If True, encoder and all layers support ' 'multiple examples in a single sequence.') p.Define('final_layer_norm', False, 'Whether or not to apply the final layer normalization.') p.Define('use_fused_layernorm', False, 'Whether to use fused layernorm.') p.Define( 'output_data_format', 'TBC', 'The data format of output features: ' 'TBC for [time, batch, feature_dim], ' 'BTC for [batch, time, feature_dim].') return p @base_layer.initializer def __init__(self, params): super(TransformerBatchMajorEncoder, self).__init__(params) p = self.params assert p.output_data_format in ('TBC', 'BTC') if p.shared_emb: with tf.variable_scope('shared_emb', reuse=tf.AUTO_REUSE): self.CreateChild('softmax', p.shared_emb) with tf.variable_scope(p.name): p.token_emb.dtype = p.dtype if not p.shared_emb: self.CreateChild('token_emb', p.token_emb) self.CreateChild('position_emb', p.position_emb) dropout_tpl = p.input_dropout_tpl.Copy() dropout_tpl.keep_prob = (1.0 - p.input_dropout_prob) self.CreateChild('input_dropout', dropout_tpl) if p.transformer_stack: self.CreateChild('transformer_stack', p.transformer_stack) if p.final_layer_norm: layer_norm_p = layers.LayerNorm.Params().Set( name='final_ln', input_dim=p.model_dim, use_fused_layernorm=p.use_fused_layernorm, fprop_dtype=p.input_dropout_tpl.fprop_dtype) self.CreateChild('final_ln', layer_norm_p) def FProp(self, theta, input_batch): """Embeds source ids and transforms with TransformerStack. Args: theta: A `.NestedMap` object containing weights' values of this layer and its children layers. input_batch: A `.NestedMap` object containing: ids - The inputs tensor of shape [batch, time]. paddings - The ids' paddings of shape [batch, time]. Returns: A '.NestedMap' object containing: encoded - The encoded features of shape [time, batch, dim] or [batch, time, dim], depending p.output_data_format. padding - The encoded features' padding of shape [time, batch] or [batch, time]. segment_id - The segmentation of packed inputs of shape [time, batch] or [batch, time] if it is supported by the model, or None otherwise. embedded_inputs - The embedded inputs tokens without positional encodings of shape [time, batch, dim] or [batch, time, dim]. """ p = self.params with tf.name_scope(p.name): # [batch, time] input_ids = input_batch.ids # [batch, time] paddings = input_batch.paddings # [batch, time] segment_ids = input_batch.segment_ids if p.packed_input else None batch = py_utils.GetShape(input_ids)[0] time = py_utils.GetShape(input_ids)[1] # Embedding layer. # [batch, time, dim] if not p.shared_emb: input_embs = self.token_emb.EmbLookup(theta.token_emb, input_ids) else: input_embs = self.softmax.EmbLookup(theta.softmax, input_ids) orig_input_embs = input_embs # [1, time, dim] if p.packed_input: positions = input_batch.segment_pos position_embs = tf.expand_dims( self.position_emb.FPropWithPosition(theta.position_emb, positions), 0) else: position_embs = tf.expand_dims( self.position_emb.FProp(theta.position_emb, time), 0) # [batch, time, dim] input_embs += tf.cast(position_embs, tf.bfloat16) if p.input_dropout_tpl.fprop_dtype: input_embs = tf.cast(input_embs, p.input_dropout_tpl.fprop_dtype) paddings = tf.cast(paddings, p.input_dropout_tpl.fprop_dtype) input_embs = self.input_dropout.FProp(theta.input_dropout, input_embs) # [batch, time, dim] transformer_input = input_embs # Explicitly set the input shape of Transformer layers, to avoid # unknown shape error occurred to tf.einsum on nonTPU devices. transformer_input = tf.reshape(transformer_input, [batch, time, p.model_dim]) # Compute self-attention segment mask once. if p.packed_input: segment_mask = batch_major_attention.SegmentMask( segment_ids, segment_ids, dtype=transformer_input.dtype) else: segment_mask = tf.zeros([batch, 1, time, time]) encoded, padding = self.transformer_stack.FProp(theta.transformer_stack, transformer_input, paddings, segment_mask) if p.final_layer_norm: encoded = self.final_ln.FProp(theta.final_ln, encoded) seq_lengths = tf.cast(tf.reduce_sum(1. - padding, axis=1), tf.int32) if p.output_data_format == 'TBC': encoded = tf.transpose(encoded, [1, 0, 2]) # [time, batch, dim] padding = tf.transpose(padding) # [time, batch] segment_ids = tf.transpose(segment_ids) if p.packed_input else None orig_input_embs = tf.transpose(orig_input_embs, [1, 0, 2]) return py_utils.NestedMap( encoded=encoded, padding=padding, seq_lengths=seq_lengths, # used by beam_search_helper. segment_id=segment_ids, embedded_inputs=orig_input_embs)
mlperf/training_results_v0.7
Google/benchmarks/transformer/implementations/transformer-research-TF-tpu-v4-512/lingvo/tasks/mt/encoder.py
Python
apache-2.0
35,293
[ "Gaussian" ]
8b65acdd4dc25dc6b02ddddeb3d9b9dca764e1404daa7da946729a5d0b4b9e65
import matplotlib matplotlib.use('Agg') import numpy as np import netCDF4 from datetime import datetime import pyroms import pyroms_toolbox import sys def create_HYCOM_file(name, time, lon, lat, z, var): print 'Write with file %s' %name #create netCDF file nc = netCDF4.Dataset(name, 'w', format='NETCDF3_64BIT') nc.Author = sys._getframe().f_code.co_name nc.Created = datetime.now().strftime("%Y-%m-%d %H:%M:%S") nc.title = 'HYCOM + NCODA Global 1/12 Analysis (GLBa0.08)' #create dimensions Mp, Lp = lon.shape N = len(z) nc.createDimension('lon', Lp) nc.createDimension('lat', Mp) nc.createDimension('z', N) nc.createDimension('ocean_time', None) #create variables nc.createVariable('lon', 'f', ('lat', 'lon')) nc.variables['lon'].long_name = 'longitude' nc.variables['lon'].units = 'degrees_east' nc.variables['lon'][:] = lon nc.createVariable('lat', 'f', ('lat', 'lon')) nc.variables['lat'].long_name = 'latitude' nc.variables['lat'].units = 'degrees_north' nc.variables['lat'][:] = lat nc.createVariable('z', 'f', ('z')) nc.variables['z'].long_name = 'depth' nc.variables['z'].units = 'meter' nc.variables['z'][:] = z nc.createVariable('ocean_time', 'f', ('ocean_time')) nc.variables['ocean_time'].units = 'days since 1900-01-01 00:00:00' nc.variables['ocean_time'].calendar = 'LEAP' nc.variables['ocean_time'][0] = time nc.createVariable(outvarname, 'f', ('ocean_time', 'z', 'lat', 'lon'), fill_value=spval) nc.variables[outvarname].long_name = long_name nc.variables[outvarname].units = units nc.variables[outvarname].coordinates = 'lon lat' nc.variables[outvarname][0] = var nc.close() print 'Done with file %s' %name # get HYCOM Northeast Pacific data from 2007 to 2009 year = 2014 retry='True' invarname = 'temperature' outvarname = 'temp' #read grid and variable attributes from the first file url='http://tds.hycom.org/thredds/dodsC/datasets/GLBa0.08/expt_90.6/2009/temp/archv.2009_001_00_3zt.nc' dataset = netCDF4.Dataset(url) lon = dataset.variables['Longitude'][2100:,550:4040] lat = dataset.variables['Latitude'][2100:,550:4040] z = dataset.variables['Depth'][:] #spval = dataset.variables[invarname]._FillValue units = dataset.variables[invarname].units long_name = dataset.variables[invarname].long_name dataset.close() retry_day = [] # loop over daily files if year%4 == 0: daysinyear = 366 else: daysinyear = 365 daysinyear = 94 for day in range(1,daysinyear+1): #for day in range(95,daysinyear+1): print 'Processing file for %s, day %03d, year %04d' %(invarname, day, year) url='http://tds.hycom.org/thredds/dodsC/datasets/GLBa0.08/expt_91.0/2014/temp/archv.%04d_%03d_00_3zt.nc' %(year,day) # url='http://tds.hycom.org/thredds/dodsC/datasets/GLBa0.08/expt_91.1/2014/temp/archv.%04d_%03d_00_3zt.nc' %(year,day) #get data from server try: dataset = netCDF4.Dataset(url) var = dataset.variables[invarname][0,:,2100:,550:4040] spval = var.get_fill_value() dataset.close() print 'Got %s from server...' %invarname except: print 'No file on the server... We skip this day.' retry_day.append(day) continue #create netCDF file outfile = 'data/HYCOM_GLBa0.08_%s_%04d_%03d.nc' %(outvarname,year,day) jday = pyroms_toolbox.date2jday(datetime(year, 1, 1)) + day - 1 create_HYCOM_file(outfile, jday, lon, lat, z, var) if retry == 'True': if len(retry_day) != 0: print "Some file have not been downloded... Let's try again" while len(retry_day) != 0: for day in retry_day: print 'Retry file for %s, day %03d, year %04d' %(invarname, day, year) url='http://tds.hycom.org/thredds/dodsC/datasets/GLBa0.08/expt_91.0/2014/temp/archv.%04d_%03d_00_3zt.nc' %(year,day) # url='http://tds.hycom.org/thredds/dodsC/datasets/GLBa0.08/expt_91.1/2014/temp/archv.%04d_%03d_00_3zt.nc' %(year,day) #get data from server try: dataset = netCDF4.Dataset(url) var = dataset.variables[invarname][0,:,2100:,550:4040] spval = var.get_fill_value() dataset.close() print 'Got %s from server...' %invarname except: print 'No file on the server... We skip this day.' continue #create netCDF file outfile = 'data/HYCOM_GLBa0.08_%s_%04d_%03d.nc' %(outvarname,year,day) jday = pyroms_toolbox.date2jday(datetime(year, 1, 1)) + day - 1 create_HYCOM_file(outfile, jday, lon, lat, z, var) retry_day.remove(day)
dcherian/pyroms
examples/Arctic_HYCOM/get_hycom_GLBa0.08_temp_2014.py
Python
bsd-3-clause
4,746
[ "NetCDF" ]
4773f55eeef1ced5e3cc50af7ea8fe91a1b737437f498c735c26e92e18d7f4b4
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import glob class Chombo(MakefilePackage): """The Chombo package provides a set of tools for implementing finite difference and finite-volume methods for the solution of partial differential equations on block-structured adaptively refined logically rectangular (i.e. Cartesian) grids.""" homepage = "https://commons.lbl.gov/display/chombo" git = "https://bitbucket.org/drhansj/chombo-xsdk.git" tags = ['ecp', 'ecp-apps'] # Use whatever path Brian V. and Terry L. agreed upon, but preserve version version('3.2', commit='71d856c') version('develop', tag='master') variant('mpi', default=True, description='Enable MPI parallel support') variant('hdf5', default=True, description='Enable HDF5 support') variant('dims', default='3', values=('1', '2', '3', '4', '5', '6'), multi=False, description='Number of PDE dimensions [1-6]') patch('hdf5-16api.patch', when='@3.2', level=0) patch('Make.defs.local.template.patch', when='@3.2', level=0) depends_on('blas') depends_on('lapack') depends_on('gmake', type='build') depends_on('tcsh', type='build') depends_on('mpi', when='+mpi') depends_on('hdf5', when='+hdf5') depends_on('hdf5+mpi', when='+mpi+hdf5') def edit(self, spec, prefix): files = glob.glob('lib/mk/local/*.csh') files += ['fixIncludes', 'lib/mk/Make.rules', 'lib/mk/reverse'] files += ['lib/test/BoxTools/mpirun.sh'] filter_file('/bin/csh', 'env csh', *files) # Set fortran name mangling in Make.defs defs_file = FileFilter('./lib/mk/Make.defs') defs_file.filter(r'^#\s*cppcallsfort\s*=.*', 'cppcallsfort = -DCH_FORT_UNDERSCORE') # Set remaining variables in Make.defs.local # Make.defs.local.template.patch ensures lines for USE_TIMER, # USE_LAPACK and lapackincflags are present copy('./lib/mk/Make.defs.local.template', './lib/mk/Make.defs.local') defs_file = FileFilter('./lib/mk/Make.defs.local') # Unconditional settings defs_file.filter(r'^#\s*DEBUG\s*=.*', 'DEBUG = FALSE') defs_file.filter(r'^#\s*OPT\s*=.*', 'OPT = TRUE') # timer code frequently fails compiles. So disable it. defs_file.filter(r'^#\s*USE_TIMER\s*=.*', 'USE_TIMER = FALSE') # LAPACK setup lapack_blas = spec['lapack'].libs + spec['blas'].libs defs_file.filter(r'^#\s*USE_LAPACK\s*=.*', 'USE_LAPACK = TRUE') defs_file.filter( r'^#\s*lapackincflags\s*=.*', 'lapackincflags = -I%s' % spec['lapack'].prefix.include) defs_file.filter( r'^#\s*syslibflags\s*=.*', 'syslibflags = %s' % lapack_blas.ld_flags) # Compilers and Compiler flags defs_file.filter(r'^#\s*CXX\s*=.*', 'CXX = %s' % spack_cxx) defs_file.filter(r'^#\s*FC\s*=.*', 'FC = %s' % spack_fc) if '+mpi' in spec: defs_file.filter( r'^#\s*MPICXX\s*=.*', 'MPICXX = %s' % self.spec['mpi'].mpicxx) # Conditionally determined settings defs_file.filter( r'^#\s*MPI\s*=.*', 'MPI = %s' % ('TRUE' if '+mpi' in spec else 'FALSE')) defs_file.filter( r'^#\s*DIM\s*=.*', 'DIM = %s' % spec.variants['dims'].value) # HDF5 settings if '+hdf5' in spec: defs_file.filter(r'^#\s*USE_HDF5\s*=.*', 'USE_HDF5 = TRUE') defs_file.filter( r'^#\s*HDFINCFLAGS\s*=.*', 'HDFINCFLAGS = -I%s' % spec['hdf5'].prefix.include) defs_file.filter( r'^#\s*HDFLIBFLAGS\s*=.*', 'HDFLIBFLAGS = %s' % spec['hdf5'].libs.ld_flags) if '+mpi' in spec: defs_file.filter( r'^#\s*HDFMPIINCFLAGS\s*=.*', 'HDFMPIINCFLAGS = -I%s' % spec['hdf5'].prefix.include) defs_file.filter( r'^#\s*HDFMPILIBFLAGS\s*=.*', 'HDFMPILIBFLAGS = %s' % spec['hdf5'].libs.ld_flags) def build(self, spec, prefix): with working_dir('lib'): gmake('all') def install(self, spec, prefix): with working_dir('lib'): install_tree('include', prefix.include) # The package only builds static libs on Linux, # maybe it builds shared libs on another OS. # This restores the originally impemented install: libfiles = glob.glob('lib*.a') libfiles += glob.glob('lib*.so') libfiles += glob.glob('lib*.dylib') mkdirp(prefix.lib) for lib in libfiles: install(lib, prefix.lib)
LLNL/spack
var/spack/repos/builtin/packages/chombo/package.py
Python
lgpl-2.1
4,968
[ "Brian" ]
cae6447d4b81be84f179800ea6333fe90d0eb9be9865d5ae7b381fd340f81da2
# -*- coding: utf-8 -*- """ End-to-end tests for the main LMS Dashboard (aka, Student Dashboard). """ from ..helpers import UniqueCourseTest from ...fixtures.course import CourseFixture from ...pages.lms.auto_auth import AutoAuthPage from ...pages.lms.dashboard import DashboardPage class BaseLmsDashboardTest(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard """ def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTest, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], ) self.course_fixture.add_advanced_settings({ u"social_sharing_url": {u"value": "http://custom/course/url"} }) self.course_fixture.install() # Create the test user, register them for the course, and authenticate self.username = "test_{uuid}".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) AutoAuthPage( self.browser, username=self.username, email=self.email, course_id=self.course_id ).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit() class LmsDashboardPageTest(BaseLmsDashboardTest): """ Test suite for the LMS Student Dashboard page """ def test_dashboard_course_listings(self): """ Perform a general validation of the course listings section """ course_listings = self.dashboard_page.get_course_listings() self.assertEqual(len(course_listings), 1) def test_dashboard_social_sharing_feature(self): """ Validate the behavior of the social sharing feature """ twitter_widget = self.dashboard_page.get_course_social_sharing_widget('twitter') twitter_url = "https://twitter.com/intent/tweet?text=Testing+feature%3A%20http%3A%2F%2Fcustom%2Fcourse%2Furl" # pylint: disable=line-too-long self.assertEqual(twitter_widget.attrs('title')[0], 'Share on Twitter') self.assertEqual(twitter_widget.attrs('data-tooltip')[0], 'Share on Twitter') self.assertEqual(twitter_widget.attrs('aria-haspopup')[0], 'true') self.assertEqual(twitter_widget.attrs('aria-expanded')[0], 'false') self.assertEqual(twitter_widget.attrs('target')[0], '_blank') self.assertIn(twitter_url, twitter_widget.attrs('href')[0]) self.assertIn(twitter_url, twitter_widget.attrs('onclick')[0]) facebook_widget = self.dashboard_page.get_course_social_sharing_widget('facebook') facebook_url = "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fcustom%2Fcourse%2Furl" self.assertEqual(facebook_widget.attrs('title')[0], 'Share on Facebook') self.assertEqual(facebook_widget.attrs('data-tooltip')[0], 'Share on Facebook') self.assertEqual(facebook_widget.attrs('aria-haspopup')[0], 'true') self.assertEqual(facebook_widget.attrs('aria-expanded')[0], 'false') self.assertEqual(facebook_widget.attrs('target')[0], '_blank') self.assertIn(facebook_url, facebook_widget.attrs('href')[0]) self.assertIn(facebook_url, facebook_widget.attrs('onclick')[0])
tiagochiavericosta/edx-platform
common/test/acceptance/tests/lms/test_lms_dashboard.py
Python
agpl-3.0
3,835
[ "VisIt" ]
4ff56920b508317b3fbad2c26f4aadaa5c0c0823d191be23bfe12ac80eca3578
#!/usr/bin/env python3 import numpy as np import matplotlib.pyplot as plt from LoLIM.utilities import processed_data_dir from LoLIM.IO.raw_tbb_IO import MultiFile_Dal1, filePaths_by_stationName from LoLIM.signal_processing import remove_saturation from LoLIM.findRFI import window_and_filter from LoLIM.read_pulse_data import read_station_delays, read_antenna_pol_flips, read_bad_antennas, read_antenna_delays ## these lines are anachronistic and should be fixed at some point from LoLIM import utilities utilities.default_raw_data_loc = "/exp_app2/appexp1/public/raw_data" utilities.default_processed_data_loc = "/home/brian/processed_files" if __name__ == "__main__": timeID = 'D20170929T202255.000Z' raw_fpaths = filePaths_by_stationName(timeID) for station, fpaths in raw_fpaths.items(): TBB_data = MultiFile_Dal1( fpaths) locs = TBB_data.get_LOFAR_centered_positions() names = TBB_data.get_antenna_names() print(station) for even_ant_i in range(0,len(locs),2): name = names[even_ant_i] loc = locs[even_ant_i] print(name, loc) print()
Bhare8972/LOFAR-LIM
LIM_scripts/examples/print_all_antenna_locations.py
Python
mit
1,184
[ "Brian" ]
55ea85a64ca9f7fd466ff5a4612872151a1eeca12dbf171cf865759566f24b83
import sys import numpy as np import matplotlib import matplotlib.pyplot as plt from fitFunctions import gaussian import mpfit import scipy.stats import smooth from util.ObsFile import ObsFile from util.FileName import FileName import Utils.bin as binTools import os import struct def smoothBaseline(baselines,nPtsInMode=400): modBases = np.array(baselines) for i in range(len(modBases)): startIdx = i-nPtsInMode//2 if startIdx < 0: startIdx = 0 endIdx = i+nPtsInMode//2 if endIdx >= len(modBases): endIdx = len(modBases)-1 trimmedSample = scipy.stats.mstats.trim(baselines[startIdx:endIdx],(.4,0),relative=True) modBases[i] = np.ma.mean(trimmedSample) return modBases def smoothBaseline(baselines,timestamps,timeToAverage=500e-3): #timeToAverage = 10e-3 #10 ms modBases = np.array(baselines) for i,ts in enumerate(timestamps): startIdx = np.searchsorted(timestamps,ts-timeToAverage/2.) endIdx = np.searchsorted(timestamps,ts+timeToAverage/2.) trimmedSample = scipy.stats.mstats.trim(baselines[startIdx:endIdx],(.5,0),relative=True) modBases[i] = np.ma.mean(trimmedSample) print 2*(endIdx-startIdx) return modBases def fitR(energies): nBins=43 #mask = energies < -250 #energies = energies[mask] energyHist,energyHistBinEdges = np.histogram(energies,bins=nBins,density=True) amplitude = 0.9*np.max(energyHist) #x_offset = np.median(phasebins[ind_left:ind_right]) #sigma = 50. x_offset = energyHistBinEdges[np.argmax(energyHist)] sigma = np.std(energies)*.8 #print 'sigma: ', sigma y_offset = 1.e-8 params=[sigma, x_offset, amplitude, y_offset] # First guess at fit params errs = np.sqrt(energyHist) errs[np.where(errs == 0.)] = 1. quiet = True parinfo = [ {'n':0,'value':params[0],'limits':[sigma/10., 10*sigma], 'limited':[True,True],'fixed':False,'parname':"Sigma",'error':0}, {'n':1,'value':params[1],'limits':[x_offset-sigma*2, x_offset+sigma*2],'limited':[True,True],'fixed':False,'parname':"x offset",'error':0}, {'n':2,'value':params[2],'limits':[0.5*amplitude, 2.*amplitude],'limited':[True,True],'fixed':False,'parname':"Amplitude",'error':0}, {'n':3,'value':params[3],'limited':[False,False],'fixed':False,'parname':"y_offset",'error':0}] fa = {'x':energyHistBinEdges[0:-1],'y':energyHist,'err':errs} m = mpfit.mpfit(gaussian, functkw=fa, parinfo=parinfo, maxiter=1000, quiet=quiet) if m.status <= 0: print m.status, m.errmsg mpp = m.params #The fit params mpperr = m.perror for k,p in enumerate(mpp): parinfo[k]['value'] = p #print parinfo[k]['parname'],p," +/- ",mpperr[j] if k==0: sigma = p if k==1: x_offset = p if k==2: amplitude = p if k==3: y_offset = p gaussfit = y_offset + amplitude * np.exp( - (( energyHistBinEdges[0:-1] - x_offset)**2) / ( 2. * (sigma**2))) resolution = np.abs(x_offset/(2.355*sigma)) return {'gaussfit':gaussfit,'resolution':resolution,'sigma':sigma,'x_offset':x_offset,'amplitude':amplitude,'y_offset':y_offset,'energyHist':energyHist,'energyHistBinEdges':energyHistBinEdges} def extrema(a): nBins=300 hist,binEdges = np.histogram(a,bins=nBins,density=True) smoothWindowSize=50 histSmooth = smooth.smooth(hist,smoothWindowSize,'hanning') binCenters = binEdges[0:-1]+np.diff(binEdges)/2. extremeIdxs = np.where(np.diff(np.sign(np.diff(histSmooth))))[0]+1 bMaximums = np.diff(np.sign(np.diff(histSmooth)))<0 bMaximums = bMaximums[np.where(np.diff(np.sign(np.diff(histSmooth))))] # fig = plt.figure() # ax = fig.add_subplot(111) # ax.plot(binCenters,histSmooth) # ax.plot(binCenters,hist) # ax.plot(binCenters[extremeIdxs],histSmooth[extremeIdxs],'.') # plt.show() return {'extremeX':binCenters[extremeIdxs],'extremeY':hist[extremeIdxs],'bMaximums':bMaximums} def extract(values): newValues = np.array(values,dtype=np.int64) for i in range(len(values)): val = int(values[i]) newValues[i] = binTools.extractBin(int(values[i]),format='deg') return newValues #def detectPulses(sample,threshold,baselines): # filtered = np.array(sample) # # #threshold = calcThreshold(filtered[0:2000]) # filtered -= baselines # derivative = np.diff(filtered) # peakHeights = [] # t = 0 # negDeriv = derivative <= 0 # posDeriv = np.logical_not(negDeriv) # # triggerBooleans = filtered[1:-2] < threshold # peakCondition1 = np.logical_and(negDeriv[0:-2],posDeriv[1:-1]) # peakCondition2 = np.logical_and(triggerBooleans,posDeriv[2:]) # peakBooleans = np.logical_and(peakCondition1,peakCondition2) # try: # peakIndices = np.where(peakBooleans)[0]+1 # i = 0 # p = peakIndices[i] # deadtime=100#us # while p < peakIndices[-1]: # peakIndices = peakIndices[np.logical_or(peakIndices-p > deadtime , peakIndices-p <= 0)]#apply deadtime # i+=1 # if i < len(peakIndices): # p = peakIndices[i] # else: # p = peakIndices[-1] # except IndexError: # return np.array([]),np.array([]),np.array([]) # # # peakHeights = filtered[peakIndices] # return peakIndices,peakHeights def detectPulses(sample,threshold,baselines,deadtime=10): #deadtime in ticks (us) filtered = np.array(sample) #threshold = calcThreshold(filtered[0:2000]) filtered -= baselines derivative = np.diff(filtered) peakHeights = [] t = 0 negDeriv = derivative <= 0 posDeriv = np.logical_not(negDeriv) print np.shape(derivative) print np.shape(filtered) print np.shape(negDeriv) nNegDerivChecks = 10 lenience = 1 triggerBooleans = filtered[nNegDerivChecks:-2] < threshold negDerivChecksSum = np.zeros(len(negDeriv[0:-nNegDerivChecks-1])) for i in range(nNegDerivChecks): negDerivChecksSum += negDeriv[i:i-nNegDerivChecks-1] peakCondition0 = negDerivChecksSum >= nNegDerivChecks-lenience peakCondition1 = np.logical_and(posDeriv[nNegDerivChecks:-1],posDeriv[nNegDerivChecks+1:]) peakCondition01 = np.logical_and(peakCondition0,peakCondition1) peakBooleans = np.logical_and(triggerBooleans,peakCondition01) try: peakIndices = np.where(peakBooleans)[0]+nNegDerivChecks i = 0 p = peakIndices[i] while p < peakIndices[-1]: peakIndices = peakIndices[np.logical_or(peakIndices-p > deadtime , peakIndices-p <= 0)]#apply deadtime i+=1 if i < len(peakIndices): p = peakIndices[i] else: p = peakIndices[-1] except IndexError: return np.array([]),np.array([]),np.array([]) peakHeights = filtered[peakIndices] return peakIndices,peakHeights cmap = matplotlib.cm.jet path = '/Scratch/labData/20131125/' obsFileName = os.path.join(path,'obs_20131126-035710.h5') obs = ObsFile(obsFileName) roachNum = 0 pixelNum = 50 secs=10 cps=500 bFiltered = True phaseFilename = os.path.join(path,'ch_snap_r%dp%d_%dsecs.dat'%(roachNum,pixelNum,secs)) phaseFile = open(phaseFilename,'r') phase = phaseFile.read() numQDRSamples=2**19 numBytesPerSample=4 nLongsnapSamples = numQDRSamples*2*secs qdrValues = struct.unpack('>%dh'%(nLongsnapSamples),phase) qdrValues = qdrValues[0:1048576] qdrPhaseValues = np.array(qdrValues,dtype=np.float32)*360./2**16*4/np.pi #convert from adc units to degrees nPhaseValues=len(qdrValues) offset = (189369-435169)*1.e-6 qdrTimes = 1.e-6*np.arange(nPhaseValues)+offset print nPhaseValues,'us in snapshot' iQdrMin = np.argmin(qdrPhaseValues) print 'min qdr',iQdrMin,qdrPhaseValues[iQdrMin] row,col=38,21 firstSec=0 intTime=5 countRates = [] print (row,col) color='k' packetListDict = obs.getTimedPacketList(row,col,firstSec=firstSec,integrationTime=intTime) timestamps = packetListDict['timestamps'] rawPeakHeights = packetListDict['peakHeights'] rawBaselines = packetListDict['baselines'] peakHeights = (np.array(rawPeakHeights,dtype=np.float)/2.**9-4.)*180./np.pi baselines = (np.array(rawBaselines,dtype=np.float)/2.**9-4.)*180./np.pi iObsMin = np.argmin(peakHeights[0:100]) print 'min obs',iObsMin,timestamps[iObsMin],peakHeights[iObsMin] peakHeightsFilled = np.zeros(intTime*1e6) peakHeightsFilled[np.array(1e6*timestamps,dtype=np.int)] = peakHeights filledTimes = np.arange(intTime*1e6)*1.e-6 baseline = np.mean(baselines) threshold = -25. qdrPeakIdx,qdrPeakHeights = detectPulses(qdrPhaseValues,threshold,baseline) qdrPeakIdxDead,qdrPeakHeightsDead = detectPulses(qdrPhaseValues,threshold,baseline,deadtime=0) qdrPeakHeights += baseline qdrPeakHeightsDead += baseline qdrCorSample = np.zeros(len(qdrPhaseValues)) qdrCorSample[qdrPeakIdx] = qdrPeakHeights #print 'starting correlation' #cor = np.correlate(peakHeightsFilled,qdrCorSample,mode='same') #print 'finished correlation' #imin = np.argmin(cor) #print imin,cor[imin] nCounts = len(timestamps) secs = np.unique(np.array(timestamps,dtype=np.int)) print nCounts if nCounts > 0: duration = np.max(secs)+1 print 1.*nCounts/duration phases = peakHeights-baselines fig = plt.figure() ax = fig.add_subplot(111) ax.plot(qdrTimes,qdrPhaseValues,'k,-') ax.plot(qdrTimes[qdrPeakIdxDead],qdrPeakHeightsDead,'bd') ax.plot(qdrTimes[qdrPeakIdx],qdrPeakHeights,'rd') ax.plot(timestamps,peakHeights,'c.') ax.plot(timestamps,baselines,'r,-') plt.show() # fig = plt.figure() # ax = fig.add_subplot(111) # ax.plot(cor,'m') # plt.show()
bmazin/SDR
Projects/TestBaseline/compareBaseline.py
Python
gpl-2.0
9,678
[ "Gaussian" ]
9bcb82ecfe9138e5e210b05d626d67ca6638dc491b41b21669395ab0305533d9
import test.support # Skip tests if _multiprocessing wasn't built. test.support.import_module('_multiprocessing') # Skip tests if sem_open implementation is broken. test.support.import_module('multiprocessing.synchronize') # import threading after _multiprocessing to raise a more revelant error # message: "No module named _multiprocessing". _multiprocessing is not compiled # without thread support. test.support.import_module('threading') from test.script_helper import assert_python_ok import sys import threading import time import unittest import weakref from concurrent import futures from concurrent.futures._base import ( PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, Future) from concurrent.futures.process import BrokenProcessPool def create_future(state=PENDING, exception=None, result=None): f = Future() f._state = state f._exception = exception f._result = result return f PENDING_FUTURE = create_future(state=PENDING) RUNNING_FUTURE = create_future(state=RUNNING) CANCELLED_FUTURE = create_future(state=CANCELLED) CANCELLED_AND_NOTIFIED_FUTURE = create_future(state=CANCELLED_AND_NOTIFIED) EXCEPTION_FUTURE = create_future(state=FINISHED, exception=OSError()) SUCCESSFUL_FUTURE = create_future(state=FINISHED, result=42) def mul(x, y): return x * y def sleep_and_raise(t): time.sleep(t) raise Exception('this is an exception') def sleep_and_print(t, msg): time.sleep(t) print(msg) sys.stdout.flush() class MyObject(object): def my_method(self): pass class ExecutorMixin: worker_count = 5 def setUp(self): self.t1 = time.time() try: self.executor = self.executor_type(max_workers=self.worker_count) except NotImplementedError as e: self.skipTest(str(e)) self._prime_executor() def tearDown(self): self.executor.shutdown(wait=True) dt = time.time() - self.t1 if test.support.verbose: print("%.2fs" % dt, end=' ') self.assertLess(dt, 60, "synchronization issue: test lasted too long") def _prime_executor(self): # Make sure that the executor is ready to do work before running the # tests. This should reduce the probability of timeouts in the tests. futures = [self.executor.submit(time.sleep, 0.1) for _ in range(self.worker_count)] for f in futures: f.result() class ThreadPoolMixin(ExecutorMixin): executor_type = futures.ThreadPoolExecutor class ProcessPoolMixin(ExecutorMixin): executor_type = futures.ProcessPoolExecutor class ExecutorShutdownTest: def test_run_after_shutdown(self): self.executor.shutdown() self.assertRaises(RuntimeError, self.executor.submit, pow, 2, 5) def test_interpreter_shutdown(self): # Test the atexit hook for shutdown of worker threads and processes rc, out, err = assert_python_ok('-c', """if 1: from concurrent.futures import {executor_type} from time import sleep from test.test_concurrent_futures import sleep_and_print t = {executor_type}(5) t.submit(sleep_and_print, 1.0, "apple") """.format(executor_type=self.executor_type.__name__)) # Errors in atexit hooks don't change the process exit code, check # stderr manually. self.assertFalse(err) self.assertEqual(out.strip(), b"apple") def test_hang_issue12364(self): fs = [self.executor.submit(time.sleep, 0.1) for _ in range(50)] self.executor.shutdown() for f in fs: f.result() class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, unittest.TestCase): def _prime_executor(self): pass def test_threads_terminate(self): self.executor.submit(mul, 21, 2) self.executor.submit(mul, 6, 7) self.executor.submit(mul, 3, 14) self.assertEqual(len(self.executor._threads), 3) self.executor.shutdown() for t in self.executor._threads: t.join() def test_context_manager_shutdown(self): with futures.ThreadPoolExecutor(max_workers=5) as e: executor = e self.assertEqual(list(e.map(abs, range(-5, 5))), [5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) for t in executor._threads: t.join() def test_del_shutdown(self): executor = futures.ThreadPoolExecutor(max_workers=5) executor.map(abs, range(-5, 5)) threads = executor._threads del executor for t in threads: t.join() class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.TestCase): def _prime_executor(self): pass def test_processes_terminate(self): self.executor.submit(mul, 21, 2) self.executor.submit(mul, 6, 7) self.executor.submit(mul, 3, 14) self.assertEqual(len(self.executor._processes), 5) processes = self.executor._processes self.executor.shutdown() for p in processes.values(): p.join() def test_context_manager_shutdown(self): with futures.ProcessPoolExecutor(max_workers=5) as e: processes = e._processes self.assertEqual(list(e.map(abs, range(-5, 5))), [5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) for p in processes.values(): p.join() def test_del_shutdown(self): executor = futures.ProcessPoolExecutor(max_workers=5) list(executor.map(abs, range(-5, 5))) queue_management_thread = executor._queue_management_thread processes = executor._processes del executor queue_management_thread.join() for p in processes.values(): p.join() class WaitTests: def test_first_completed(self): future1 = self.executor.submit(mul, 21, 2) future2 = self.executor.submit(time.sleep, 1.5) done, not_done = futures.wait( [CANCELLED_FUTURE, future1, future2], return_when=futures.FIRST_COMPLETED) self.assertEqual(set([future1]), done) self.assertEqual(set([CANCELLED_FUTURE, future2]), not_done) def test_first_completed_some_already_completed(self): future1 = self.executor.submit(time.sleep, 1.5) finished, pending = futures.wait( [CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE, future1], return_when=futures.FIRST_COMPLETED) self.assertEqual( set([CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE]), finished) self.assertEqual(set([future1]), pending) def test_first_exception(self): future1 = self.executor.submit(mul, 2, 21) future2 = self.executor.submit(sleep_and_raise, 1.5) future3 = self.executor.submit(time.sleep, 3) finished, pending = futures.wait( [future1, future2, future3], return_when=futures.FIRST_EXCEPTION) self.assertEqual(set([future1, future2]), finished) self.assertEqual(set([future3]), pending) def test_first_exception_some_already_complete(self): future1 = self.executor.submit(divmod, 21, 0) future2 = self.executor.submit(time.sleep, 1.5) finished, pending = futures.wait( [SUCCESSFUL_FUTURE, CANCELLED_FUTURE, CANCELLED_AND_NOTIFIED_FUTURE, future1, future2], return_when=futures.FIRST_EXCEPTION) self.assertEqual(set([SUCCESSFUL_FUTURE, CANCELLED_AND_NOTIFIED_FUTURE, future1]), finished) self.assertEqual(set([CANCELLED_FUTURE, future2]), pending) def test_first_exception_one_already_failed(self): future1 = self.executor.submit(time.sleep, 2) finished, pending = futures.wait( [EXCEPTION_FUTURE, future1], return_when=futures.FIRST_EXCEPTION) self.assertEqual(set([EXCEPTION_FUTURE]), finished) self.assertEqual(set([future1]), pending) def test_all_completed(self): future1 = self.executor.submit(divmod, 2, 0) future2 = self.executor.submit(mul, 2, 21) finished, pending = futures.wait( [SUCCESSFUL_FUTURE, CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, future1, future2], return_when=futures.ALL_COMPLETED) self.assertEqual(set([SUCCESSFUL_FUTURE, CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, future1, future2]), finished) self.assertEqual(set(), pending) def test_timeout(self): future1 = self.executor.submit(mul, 6, 7) future2 = self.executor.submit(time.sleep, 6) finished, pending = futures.wait( [CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE, future1, future2], timeout=5, return_when=futures.ALL_COMPLETED) self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE, future1]), finished) self.assertEqual(set([future2]), pending) class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, unittest.TestCase): def test_pending_calls_race(self): # Issue #14406: multi-threaded race condition when waiting on all # futures. event = threading.Event() def future_func(): event.wait() oldswitchinterval = sys.getswitchinterval() sys.setswitchinterval(1e-6) try: fs = {self.executor.submit(future_func) for i in range(100)} event.set() futures.wait(fs, return_when=futures.ALL_COMPLETED) finally: sys.setswitchinterval(oldswitchinterval) class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests, unittest.TestCase): pass class AsCompletedTests: # TODO(brian@sweetapp.com): Should have a test with a non-zero timeout. def test_no_timeout(self): future1 = self.executor.submit(mul, 2, 21) future2 = self.executor.submit(mul, 7, 6) completed = set(futures.as_completed( [CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE, future1, future2])) self.assertEqual(set( [CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE, future1, future2]), completed) def test_zero_timeout(self): future1 = self.executor.submit(time.sleep, 2) completed_futures = set() try: for future in futures.as_completed( [CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE, future1], timeout=0): completed_futures.add(future) except futures.TimeoutError: pass self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE, EXCEPTION_FUTURE, SUCCESSFUL_FUTURE]), completed_futures) def test_duplicate_futures(self): # Issue 20367. Duplicate futures should not raise exceptions or give # duplicate responses. future1 = self.executor.submit(time.sleep, 2) completed = [f for f in futures.as_completed([future1,future1])] self.assertEqual(len(completed), 1) class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.TestCase): pass class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.TestCase): pass class ExecutorTest: # Executor.shutdown() and context manager usage is tested by # ExecutorShutdownTest. def test_submit(self): future = self.executor.submit(pow, 2, 8) self.assertEqual(256, future.result()) def test_submit_keyword(self): future = self.executor.submit(mul, 2, y=8) self.assertEqual(16, future.result()) def test_map(self): self.assertEqual( list(self.executor.map(pow, range(10), range(10))), list(map(pow, range(10), range(10)))) def test_map_exception(self): i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5]) self.assertEqual(i.__next__(), (0, 1)) self.assertEqual(i.__next__(), (0, 1)) self.assertRaises(ZeroDivisionError, i.__next__) def test_map_timeout(self): results = [] try: for i in self.executor.map(time.sleep, [0, 0, 6], timeout=5): results.append(i) except futures.TimeoutError: pass else: self.fail('expected TimeoutError') self.assertEqual([None, None], results) def test_shutdown_race_issue12456(self): # Issue #12456: race condition at shutdown where trying to post a # sentinel in the call queue blocks (the queue is full while processes # have exited). self.executor.map(str, [2] * (self.worker_count + 1)) self.executor.shutdown() @test.support.cpython_only def test_no_stale_references(self): # Issue #16284: check that the executors don't unnecessarily hang onto # references. my_object = MyObject() my_object_collected = threading.Event() my_object_callback = weakref.ref( my_object, lambda obj: my_object_collected.set()) # Deliberately discarding the future. self.executor.submit(my_object.my_method) del my_object collected = my_object_collected.wait(timeout=5.0) self.assertTrue(collected, "Stale reference not collected within timeout.") class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, unittest.TestCase): def test_map_submits_without_iteration(self): """Tests verifying issue 11777.""" finished = [] def record_finished(n): finished.append(n) self.executor.map(record_finished, range(10)) self.executor.shutdown(wait=True) self.assertCountEqual(finished, range(10)) class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase): def test_killed_child(self): # When a child process is abruptly terminated, the whole pool gets # "broken". futures = [self.executor.submit(time.sleep, 3)] # Get one of the processes, and terminate (kill) it p = next(iter(self.executor._processes.values())) p.terminate() for fut in futures: self.assertRaises(BrokenProcessPool, fut.result) # Submitting other jobs fails as well. self.assertRaises(BrokenProcessPool, self.executor.submit, pow, 2, 8) class FutureTests(unittest.TestCase): def test_done_callback_with_result(self): callback_result = None def fn(callback_future): nonlocal callback_result callback_result = callback_future.result() f = Future() f.add_done_callback(fn) f.set_result(5) self.assertEqual(5, callback_result) def test_done_callback_with_exception(self): callback_exception = None def fn(callback_future): nonlocal callback_exception callback_exception = callback_future.exception() f = Future() f.add_done_callback(fn) f.set_exception(Exception('test')) self.assertEqual(('test',), callback_exception.args) def test_done_callback_with_cancel(self): was_cancelled = None def fn(callback_future): nonlocal was_cancelled was_cancelled = callback_future.cancelled() f = Future() f.add_done_callback(fn) self.assertTrue(f.cancel()) self.assertTrue(was_cancelled) def test_done_callback_raises(self): with test.support.captured_stderr() as stderr: raising_was_called = False fn_was_called = False def raising_fn(callback_future): nonlocal raising_was_called raising_was_called = True raise Exception('doh!') def fn(callback_future): nonlocal fn_was_called fn_was_called = True f = Future() f.add_done_callback(raising_fn) f.add_done_callback(fn) f.set_result(5) self.assertTrue(raising_was_called) self.assertTrue(fn_was_called) self.assertIn('Exception: doh!', stderr.getvalue()) def test_done_callback_already_successful(self): callback_result = None def fn(callback_future): nonlocal callback_result callback_result = callback_future.result() f = Future() f.set_result(5) f.add_done_callback(fn) self.assertEqual(5, callback_result) def test_done_callback_already_failed(self): callback_exception = None def fn(callback_future): nonlocal callback_exception callback_exception = callback_future.exception() f = Future() f.set_exception(Exception('test')) f.add_done_callback(fn) self.assertEqual(('test',), callback_exception.args) def test_done_callback_already_cancelled(self): was_cancelled = None def fn(callback_future): nonlocal was_cancelled was_cancelled = callback_future.cancelled() f = Future() self.assertTrue(f.cancel()) f.add_done_callback(fn) self.assertTrue(was_cancelled) def test_repr(self): self.assertRegex(repr(PENDING_FUTURE), '<Future at 0x[0-9a-f]+ state=pending>') self.assertRegex(repr(RUNNING_FUTURE), '<Future at 0x[0-9a-f]+ state=running>') self.assertRegex(repr(CANCELLED_FUTURE), '<Future at 0x[0-9a-f]+ state=cancelled>') self.assertRegex(repr(CANCELLED_AND_NOTIFIED_FUTURE), '<Future at 0x[0-9a-f]+ state=cancelled>') self.assertRegex( repr(EXCEPTION_FUTURE), '<Future at 0x[0-9a-f]+ state=finished raised OSError>') self.assertRegex( repr(SUCCESSFUL_FUTURE), '<Future at 0x[0-9a-f]+ state=finished returned int>') def test_cancel(self): f1 = create_future(state=PENDING) f2 = create_future(state=RUNNING) f3 = create_future(state=CANCELLED) f4 = create_future(state=CANCELLED_AND_NOTIFIED) f5 = create_future(state=FINISHED, exception=OSError()) f6 = create_future(state=FINISHED, result=5) self.assertTrue(f1.cancel()) self.assertEqual(f1._state, CANCELLED) self.assertFalse(f2.cancel()) self.assertEqual(f2._state, RUNNING) self.assertTrue(f3.cancel()) self.assertEqual(f3._state, CANCELLED) self.assertTrue(f4.cancel()) self.assertEqual(f4._state, CANCELLED_AND_NOTIFIED) self.assertFalse(f5.cancel()) self.assertEqual(f5._state, FINISHED) self.assertFalse(f6.cancel()) self.assertEqual(f6._state, FINISHED) def test_cancelled(self): self.assertFalse(PENDING_FUTURE.cancelled()) self.assertFalse(RUNNING_FUTURE.cancelled()) self.assertTrue(CANCELLED_FUTURE.cancelled()) self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.cancelled()) self.assertFalse(EXCEPTION_FUTURE.cancelled()) self.assertFalse(SUCCESSFUL_FUTURE.cancelled()) def test_done(self): self.assertFalse(PENDING_FUTURE.done()) self.assertFalse(RUNNING_FUTURE.done()) self.assertTrue(CANCELLED_FUTURE.done()) self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.done()) self.assertTrue(EXCEPTION_FUTURE.done()) self.assertTrue(SUCCESSFUL_FUTURE.done()) def test_running(self): self.assertFalse(PENDING_FUTURE.running()) self.assertTrue(RUNNING_FUTURE.running()) self.assertFalse(CANCELLED_FUTURE.running()) self.assertFalse(CANCELLED_AND_NOTIFIED_FUTURE.running()) self.assertFalse(EXCEPTION_FUTURE.running()) self.assertFalse(SUCCESSFUL_FUTURE.running()) def test_result_with_timeout(self): self.assertRaises(futures.TimeoutError, PENDING_FUTURE.result, timeout=0) self.assertRaises(futures.TimeoutError, RUNNING_FUTURE.result, timeout=0) self.assertRaises(futures.CancelledError, CANCELLED_FUTURE.result, timeout=0) self.assertRaises(futures.CancelledError, CANCELLED_AND_NOTIFIED_FUTURE.result, timeout=0) self.assertRaises(OSError, EXCEPTION_FUTURE.result, timeout=0) self.assertEqual(SUCCESSFUL_FUTURE.result(timeout=0), 42) def test_result_with_success(self): # TODO(brian@sweetapp.com): This test is timing dependant. def notification(): # Wait until the main thread is waiting for the result. time.sleep(1) f1.set_result(42) f1 = create_future(state=PENDING) t = threading.Thread(target=notification) t.start() self.assertEqual(f1.result(timeout=5), 42) def test_result_with_cancel(self): # TODO(brian@sweetapp.com): This test is timing dependant. def notification(): # Wait until the main thread is waiting for the result. time.sleep(1) f1.cancel() f1 = create_future(state=PENDING) t = threading.Thread(target=notification) t.start() self.assertRaises(futures.CancelledError, f1.result, timeout=5) def test_exception_with_timeout(self): self.assertRaises(futures.TimeoutError, PENDING_FUTURE.exception, timeout=0) self.assertRaises(futures.TimeoutError, RUNNING_FUTURE.exception, timeout=0) self.assertRaises(futures.CancelledError, CANCELLED_FUTURE.exception, timeout=0) self.assertRaises(futures.CancelledError, CANCELLED_AND_NOTIFIED_FUTURE.exception, timeout=0) self.assertTrue(isinstance(EXCEPTION_FUTURE.exception(timeout=0), OSError)) self.assertEqual(SUCCESSFUL_FUTURE.exception(timeout=0), None) def test_exception_with_success(self): def notification(): # Wait until the main thread is waiting for the exception. time.sleep(1) with f1._condition: f1._state = FINISHED f1._exception = OSError() f1._condition.notify_all() f1 = create_future(state=PENDING) t = threading.Thread(target=notification) t.start() self.assertTrue(isinstance(f1.exception(timeout=5), OSError)) @test.support.reap_threads def test_main(): try: test.support.run_unittest(__name__) finally: test.support.reap_children() if __name__ == "__main__": test_main()
Orav/kbengine
kbe/src/lib/python/Lib/test/test_concurrent_futures.py
Python
lgpl-3.0
24,513
[ "Brian" ]
de0bf2527611b5f47ea6306ef4bdf5edad3282b7b40ae237ec7007bc241a9352
# -*- coding: utf-8 -*- # Copyright (C) 2012, Almar Klein, Ant1, Marius van Voorden # # This code is subject to the (new) BSD license: # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ Module images2gif Provides functionality for reading and writing animated GIF images. Use writeGif to write a series of numpy arrays or PIL images as an animated GIF. Use readGif to read an animated gif as a series of numpy arrays. Note that since July 2004, all patents on the LZW compression patent have expired. Therefore the GIF format may now be used freely. Acknowledgements ---------------- Many thanks to Ant1 for: * noting the use of "palette=PIL.Image.ADAPTIVE", which significantly improves the results. * the modifications to save each image with its own palette, or optionally the global palette (if its the same). Many thanks to Marius van Voorden for porting the NeuQuant quantization algorithm of Anthony Dekker to Python (See the NeuQuant class for its license). Many thanks to Alex Robinson for implementing the concept of subrectangles, which (depening on image content) can give a very significant reduction in file size. This code is based on gifmaker (in the scripts folder of the source distribution of PIL) Usefull links ------------- * http://tronche.com/computer-graphics/gif/ * http://en.wikipedia.org/wiki/Graphics_Interchange_Format * http://www.w3.org/Graphics/GIF/spec-gif89a.txt """ # todo: This module should be part of imageio (or at least based on) import os, time def encode(x): if False: return x.encode('utf-8') return x try: import PIL from PIL import Image from PIL.GifImagePlugin import getheader, getdata except ImportError: PIL = None try: import numpy as np except ImportError: np = None def get_cKDTree(): try: from scipy.spatial import cKDTree except ImportError: cKDTree = None return cKDTree # getheader gives a 87a header and a color palette (two elements in a list). # getdata()[0] gives the Image Descriptor up to (including) "LZW min code size". # getdatas()[1:] is the image data itself in chuncks of 256 bytes (well # technically the first byte says how many bytes follow, after which that # amount (max 255) follows). def checkImages(images): """ checkImages(images) Check numpy images and correct intensity range etc. The same for all movie formats. """ # Init results images2 = [] for im in images: if PIL and isinstance(im, PIL.Image.Image): # We assume PIL images are allright images2.append(im) elif np and isinstance(im, np.ndarray): # Check and convert dtype if im.dtype == np.uint8: images2.append(im) # Ok elif im.dtype in [np.float32, np.float64]: im = im.copy() im[im<0] = 0 im[im>1] = 1 im *= 255 images2.append( im.astype(np.uint8) ) else: im = im.astype(np.uint8) images2.append(im) # Check size if im.ndim == 2: pass # ok elif im.ndim == 3: if im.shape[2] not in [3,4]: raise ValueError('This array can not represent an image.') else: raise ValueError('This array can not represent an image.') else: raise ValueError('Invalid image type: ' + str(type(im))) # Done return images2 def intToBin(i): """ Integer to two bytes """ # devide in two parts (bytes) i1 = i % 256 i2 = int( i/256) # make string (little endian) return chr(i1) + chr(i2) class GifWriter: """ GifWriter() Class that contains methods for helping write the animated GIF file. """ def getheaderAnim(self, im): """ getheaderAnim(im) Get animation header. To replace PILs getheader()[0] """ bb = "GIF89a" bb += intToBin(im.size[0]) bb += intToBin(im.size[1]) bb += "\x87\x00\x00" return bb def getImageDescriptor(self, im, xy=None): """ getImageDescriptor(im, xy=None) Used for the local color table properties per image. Otherwise global color table applies to all frames irrespective of whether additional colors comes in play that require a redefined palette. Still a maximum of 256 color per frame, obviously. Written by Ant1 on 2010-08-22 Modified by Alex Robinson in Janurari 2011 to implement subrectangles. """ # Defaule use full image and place at upper left if xy is None: xy = (0,0) # Image separator, bb = '\x2C' # Image position and size bb += intToBin( xy[0] ) # Left position bb += intToBin( xy[1] ) # Top position bb += intToBin( im.size[0] ) # image width bb += intToBin( im.size[1] ) # image height # packed field: local color table flag1, interlace0, sorted table0, # reserved00, lct size111=7=2^(7+1)=256. bb += '\x87' # LZW minimum size code now comes later, begining of [image data] blocks return bb def getAppExt(self, loops=float('inf')): """ getAppExt(loops=float('inf')) Application extention. This part specifies the amount of loops. If loops is 0 or inf, it goes on infinitely. """ if loops==0 or loops==float('inf'): loops = 2**16-1 #bb = "" # application extension should not be used # (the extension interprets zero loops # to mean an infinite number of loops) # Mmm, does not seem to work if True: bb = "\x21\xFF\x0B" # application extension bb += "NETSCAPE2.0" bb += "\x03\x01" bb += intToBin(loops) bb += '\x00' # end return bb def getGraphicsControlExt(self, duration=0.1, dispose=2): """ getGraphicsControlExt(duration=0.1, dispose=2) Graphics Control Extension. A sort of header at the start of each image. Specifies duration and transparancy. Dispose ------- * 0 - No disposal specified. * 1 - Do not dispose. The graphic is to be left in place. * 2 - Restore to background color. The area used by the graphic must be restored to the background color. * 3 - Restore to previous. The decoder is required to restore the area overwritten by the graphic with what was there prior to rendering the graphic. * 4-7 -To be defined. """ bb = '\x21\xF9\x04' bb += chr((dispose & 3) << 2) # low bit 1 == transparency, # 2nd bit 1 == user input , next 3 bits, the low two of which are used, # are dispose. bb += intToBin( int(duration*100) ) # in 100th of seconds bb += '\x00' # no transparant color bb += '\x00' # end return bb def handleSubRectangles(self, images, subRectangles): """ handleSubRectangles(images) Handle the sub-rectangle stuff. If the rectangles are given by the user, the values are checked. Otherwise the subrectangles are calculated automatically. """ if isinstance(subRectangles, (tuple,list)): # xy given directly # Check xy xy = subRectangles if xy is None: xy = (0,0) if hasattr(xy, '__len__'): if len(xy) == len(images): xy = [xxyy for xxyy in xy] else: raise ValueError("len(xy) doesn't match amount of images.") else: xy = [xy for im in images] xy[0] = (0,0) else: # Calculate xy using some basic image processing # Check Numpy if np is None: raise RuntimeError("Need Numpy to use auto-subRectangles.") # First make numpy arrays if required for i in range(len(images)): im = images[i] if isinstance(im, Image.Image): tmp = im.convert() # Make without palette a = np.asarray(tmp) if len(a.shape)==0: raise MemoryError("Too little memory to convert PIL image to array") images[i] = a # Determine the sub rectangles images, xy = self.getSubRectangles(images) # Done return images, xy def getSubRectangles(self, ims): """ getSubRectangles(ims) Calculate the minimal rectangles that need updating each frame. Returns a two-element tuple containing the cropped images and a list of x-y positions. Calculating the subrectangles takes extra time, obviously. However, if the image sizes were reduced, the actual writing of the GIF goes faster. In some cases applying this method produces a GIF faster. """ # Check image count if len(ims) < 2: return ims, [(0,0) for i in ims] # We need numpy if np is None: raise RuntimeError("Need Numpy to calculate sub-rectangles. ") # Prepare ims2 = [ims[0]] xy = [(0,0)] t0 = time.time() # Iterate over images prev = ims[0] for im in ims[1:]: # Get difference, sum over colors diff = np.abs(im-prev) if diff.ndim==3: diff = diff.sum(2) # Get begin and end for both dimensions X = np.argwhere(diff.sum(0)) Y = np.argwhere(diff.sum(1)) # Get rect coordinates if X.size and Y.size: x0, x1 = X[0], X[-1]+1 y0, y1 = Y[0], Y[-1]+1 else: # No change ... make it minimal x0, x1 = 0, 2 y0, y1 = 0, 2 # Cut out and store im2 = im[y0:y1,x0:x1] prev = im ims2.append(im2) xy.append((x0,y0)) # Done #print('%1.2f seconds to determine subrectangles of %i images' % # (time.time()-t0, len(ims2)) ) return ims2, xy def convertImagesToPIL(self, images, dither, nq=0): """ convertImagesToPIL(images, nq=0) Convert images to Paletted PIL images, which can then be written to a single animaged GIF. """ # Convert to PIL images images2 = [] for im in images: if isinstance(im, Image.Image): images2.append(im) elif np and isinstance(im, np.ndarray): if im.ndim==3 and im.shape[2]==3: im = Image.fromarray(im,'RGB') elif im.ndim==3 and im.shape[2]==4: im = Image.fromarray(im[:,:,:3],'RGB') elif im.ndim==2: im = Image.fromarray(im,'L') images2.append(im) # Convert to paletted PIL images images, images2 = images2, [] if nq >= 1: # NeuQuant algorithm for im in images: im = im.convert("RGBA") # NQ assumes RGBA nqInstance = NeuQuant(im, int(nq)) # Learn colors from image if dither: im = im.convert("RGB").quantize(palette=nqInstance.paletteImage()) else: im = nqInstance.quantize(im) # Use to quantize the image itself images2.append(im) else: # Adaptive PIL algorithm AD = Image.ADAPTIVE for im in images: im = im.convert('P', palette=AD, dither=dither) images2.append(im) # Done return images2 def writeGifToFile(self, fp, images, durations, loops, xys, disposes): """ writeGifToFile(fp, images, durations, loops, xys, disposes) Given a set of images writes the bytes to the specified stream. """ # Obtain palette for all images and count each occurance palettes, occur = [], [] for im in images: #palette = getheader(im)[1] palette = getheader(im)[0][-1] if not palette: #palette = PIL.ImagePalette.ImageColor palette = im.palette.tobytes() palettes.append(palette) for palette in palettes: occur.append( palettes.count( palette ) ) # Select most-used palette as the global one (or first in case no max) globalPalette = palettes[ occur.index(max(occur)) ] # Init frames = 0 firstFrame = True for im, palette in zip(images, palettes): if firstFrame: # Write header # Gather info header = self.getheaderAnim(im) appext = self.getAppExt(loops) # Write fp.write(encode(header)) fp.write(globalPalette) fp.write(encode(appext)) # Next frame is not the first firstFrame = False if True: # Write palette and image data # Gather info data = getdata(im) imdes, data = data[0], data[1:] graphext = self.getGraphicsControlExt(durations[frames], disposes[frames]) # Make image descriptor suitable for using 256 local color palette lid = self.getImageDescriptor(im, xys[frames]) # Write local header if (palette != globalPalette) or (disposes[frames] != 2): # Use local color palette fp.write(encode(graphext)) fp.write(encode(lid)) # write suitable image descriptor fp.write(palette) # write local color table fp.write(encode('\x08')) # LZW minimum size code else: # Use global color palette fp.write(encode(graphext)) fp.write(imdes) # write suitable image descriptor # Write image data for d in data: fp.write(d) # Prepare for next round frames = frames + 1 fp.write(encode(";")) # end gif return frames ## Exposed functions def writeGif(filename, images, duration=0.1, repeat=True, dither=False, nq=0, subRectangles=True, dispose=None): """ writeGif(filename, images, duration=0.1, repeat=True, dither=False, nq=0, subRectangles=True, dispose=None) Write an animated gif from the specified images. Parameters ---------- filename : string The name of the file to write the image to. images : list Should be a list consisting of PIL images or numpy arrays. The latter should be between 0 and 255 for integer types, and between 0 and 1 for float types. duration : scalar or list of scalars The duration for all frames, or (if a list) for each frame. repeat : bool or integer The amount of loops. If True, loops infinitetely. dither : bool Whether to apply dithering nq : integer If nonzero, applies the NeuQuant quantization algorithm to create the color palette. This algorithm is superior, but slower than the standard PIL algorithm. The value of nq is the quality parameter. 1 represents the best quality. 10 is in general a good tradeoff between quality and speed. When using this option, better results are usually obtained when subRectangles is False. subRectangles : False, True, or a list of 2-element tuples Whether to use sub-rectangles. If True, the minimal rectangle that is required to update each frame is automatically detected. This can give significant reductions in file size, particularly if only a part of the image changes. One can also give a list of x-y coordinates if you want to do the cropping yourself. The default is True. dispose : int How to dispose each frame. 1 means that each frame is to be left in place. 2 means the background color should be restored after each frame. 3 means the decoder should restore the previous frame. If subRectangles==False, the default is 2, otherwise it is 1. """ # Check PIL if PIL is None: raise RuntimeError("Need PIL to write animated gif files.") # Check images images = checkImages(images) # Instantiate writer object gifWriter = GifWriter() # Check loops if repeat is False: loops = 1 elif repeat is True: loops = 0 # zero means infinite else: loops = int(repeat) # Check duration if hasattr(duration, '__len__'): if len(duration) == len(images): duration = [d for d in duration] else: raise ValueError("len(duration) doesn't match amount of images.") else: duration = [duration for im in images] # Check subrectangles if subRectangles: images, xy = gifWriter.handleSubRectangles(images, subRectangles) defaultDispose = 1 # Leave image in place else: # Normal mode xy = [(0,0) for im in images] defaultDispose = 2 # Restore to background color. # Check dispose if dispose is None: dispose = defaultDispose if hasattr(dispose, '__len__'): if len(dispose) != len(images): raise ValueError("len(xy) doesn't match amount of images.") else: dispose = [dispose for im in images] # Make images in a format that we can write easy images = gifWriter.convertImagesToPIL(images, dither, nq) # Write fp = open(filename, 'wb') try: gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose) finally: fp.close() def readGif(filename, asNumpy=True): """ readGif(filename, asNumpy=True) Read images from an animated GIF file. Returns a list of numpy arrays, or, if asNumpy is false, a list if PIL images. """ # Check PIL if PIL is None: raise RuntimeError("Need PIL to read animated gif files.") # Check Numpy if np is None: raise RuntimeError("Need Numpy to read animated gif files.") # Check whether it exists if not os.path.isfile(filename): raise IOError('File not found: '+str(filename)) # Load file using PIL pilIm = PIL.Image.open(filename) pilIm.seek(0) # Read all images inside images = [] try: while True: # Get image as numpy array tmp = pilIm.convert() # Make without palette a = np.asarray(tmp) if len(a.shape)==0: raise MemoryError("Too little memory to convert PIL image to array") # Store, and next images.append(a) pilIm.seek(pilIm.tell()+1) except EOFError: pass # Convert to normal PIL images if needed if not asNumpy: images2 = images images = [] for im in images2: images.append( PIL.Image.fromarray(im) ) # Done return images class NeuQuant: """ NeuQuant(image, samplefac=10, colors=256) samplefac should be an integer number of 1 or higher, 1 being the highest quality, but the slowest performance. With avalue of 10, one tenth of all pixels are used during training. This value seems a nice tradeof between speed and quality. colors is the amount of colors to reduce the image to. This should best be a power of two. See also: http://members.ozemail.com.au/~dekker/NEUQUANT.HTML License of the NeuQuant Neural-Net Quantization Algorithm --------------------------------------------------------- Copyright (c) 1994 Anthony Dekker Ported to python by Marius van Voorden in 2010 NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See "Kohonen neural networks for optimal colour quantization" in "network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of the algorithm. See also http://members.ozemail.com.au/~dekker/NEUQUANT.HTML Any party obtaining a copy of these files from the author, directly or indirectly, is granted, free of charge, a full and unrestricted irrevocable, world-wide, paid up, royalty-free, nonexclusive right and license to deal in this software and documentation files (the "Software"), including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons who receive copies from any such party to do so, with the only requirement being that this copyright notice remain intact. """ NCYCLES = None # Number of learning cycles NETSIZE = None # Number of colours used SPECIALS = None # Number of reserved colours used BGCOLOR = None # Reserved background colour CUTNETSIZE = None MAXNETPOS = None INITRAD = None # For 256 colours, radius starts at 32 RADIUSBIASSHIFT = None RADIUSBIAS = None INITBIASRADIUS = None RADIUSDEC = None # Factor of 1/30 each cycle ALPHABIASSHIFT = None INITALPHA = None # biased by 10 bits GAMMA = None BETA = None BETAGAMMA = None network = None # The network itself colormap = None # The network itself netindex = None # For network lookup - really 256 bias = None # Bias and freq arrays for learning freq = None pimage = None # Four primes near 500 - assume no image has a length so large # that it is divisible by all four primes PRIME1 = 499 PRIME2 = 491 PRIME3 = 487 PRIME4 = 503 MAXPRIME = PRIME4 pixels = None samplefac = None a_s = None def setconstants(self, samplefac, colors): self.NCYCLES = 100 # Number of learning cycles self.NETSIZE = colors # Number of colours used self.SPECIALS = 3 # Number of reserved colours used self.BGCOLOR = self.SPECIALS-1 # Reserved background colour self.CUTNETSIZE = self.NETSIZE - self.SPECIALS self.MAXNETPOS = self.NETSIZE - 1 self.INITRAD = self.NETSIZE/8 # For 256 colours, radius starts at 32 self.RADIUSBIASSHIFT = 6 self.RADIUSBIAS = 1 << self.RADIUSBIASSHIFT self.INITBIASRADIUS = self.INITRAD * self.RADIUSBIAS self.RADIUSDEC = 30 # Factor of 1/30 each cycle self.ALPHABIASSHIFT = 10 # Alpha starts at 1 self.INITALPHA = 1 << self.ALPHABIASSHIFT # biased by 10 bits self.GAMMA = 1024.0 self.BETA = 1.0/1024.0 self.BETAGAMMA = self.BETA * self.GAMMA self.network = np.empty((self.NETSIZE, 3), dtype='float64') # The network itself self.colormap = np.empty((self.NETSIZE, 4), dtype='int32') # The network itself self.netindex = np.empty(256, dtype='int32') # For network lookup - really 256 self.bias = np.empty(self.NETSIZE, dtype='float64') # Bias and freq arrays for learning self.freq = np.empty(self.NETSIZE, dtype='float64') self.pixels = None self.samplefac = samplefac self.a_s = {} def __init__(self, image, samplefac=10, colors=256): # Check Numpy if np is None: raise RuntimeError("Need Numpy for the NeuQuant algorithm.") # Check image if image.size[0] * image.size[1] < NeuQuant.MAXPRIME: raise IOError("Image is too small") if image.mode != "RGBA": raise IOError("Image mode should be RGBA.") # Initialize self.setconstants(samplefac, colors) self.pixels = np.fromstring(image.tostring(), np.uint32) self.setUpArrays() self.learn() self.fix() self.inxbuild() def writeColourMap(self, rgb, outstream): for i in range(self.NETSIZE): bb = self.colormap[i,0]; gg = self.colormap[i,1]; rr = self.colormap[i,2]; outstream.write(rr if rgb else bb) outstream.write(gg) outstream.write(bb if rgb else rr) return self.NETSIZE def setUpArrays(self): self.network[0,0] = 0.0 # Black self.network[0,1] = 0.0 self.network[0,2] = 0.0 self.network[1,0] = 255.0 # White self.network[1,1] = 255.0 self.network[1,2] = 255.0 # RESERVED self.BGCOLOR # Background for i in range(self.SPECIALS): self.freq[i] = 1.0 / self.NETSIZE self.bias[i] = 0.0 for i in range(self.SPECIALS, self.NETSIZE): p = self.network[i] p[:] = (255.0 * (i-self.SPECIALS)) / self.CUTNETSIZE self.freq[i] = 1.0 / self.NETSIZE self.bias[i] = 0.0 # Omitted: setPixels def altersingle(self, alpha, i, b, g, r): """Move neuron i towards biased (b,g,r) by factor alpha""" n = self.network[i] # Alter hit neuron n[0] -= (alpha*(n[0] - b)) n[1] -= (alpha*(n[1] - g)) n[2] -= (alpha*(n[2] - r)) def geta(self, alpha, rad): try: return self.a_s[(alpha, rad)] except KeyError: length = rad*2-1 mid = int(length//2) q = np.array(list(range(mid-1,-1,-1))+list(range(-1,mid))) a = alpha*(rad*rad - q*q)/(rad*rad) a[mid] = 0 self.a_s[(alpha, rad)] = a return a def alterneigh(self, alpha, rad, i, b, g, r): if i-rad >= self.SPECIALS-1: lo = i-rad start = 0 else: lo = self.SPECIALS-1 start = (self.SPECIALS-1 - (i-rad)) if i+rad <= self.NETSIZE: hi = i+rad end = rad*2-1 else: hi = self.NETSIZE end = (self.NETSIZE - (i+rad)) a = self.geta(alpha, rad)[start:end] p = self.network[lo+1:hi] p -= np.transpose(np.transpose(p - np.array([b, g, r])) * a) #def contest(self, b, g, r): # """ Search for biased BGR values # Finds closest neuron (min dist) and updates self.freq # finds best neuron (min dist-self.bias) and returns position # for frequently chosen neurons, self.freq[i] is high and self.bias[i] is negative # self.bias[i] = self.GAMMA*((1/self.NETSIZE)-self.freq[i])""" # # i, j = self.SPECIALS, self.NETSIZE # dists = abs(self.network[i:j] - np.array([b,g,r])).sum(1) # bestpos = i + np.argmin(dists) # biasdists = dists - self.bias[i:j] # bestbiaspos = i + np.argmin(biasdists) # self.freq[i:j] -= self.BETA * self.freq[i:j] # self.bias[i:j] += self.BETAGAMMA * self.freq[i:j] # self.freq[bestpos] += self.BETA # self.bias[bestpos] -= self.BETAGAMMA # return bestbiaspos def contest(self, b, g, r): """ Search for biased BGR values Finds closest neuron (min dist) and updates self.freq finds best neuron (min dist-self.bias) and returns position for frequently chosen neurons, self.freq[i] is high and self.bias[i] is negative self.bias[i] = self.GAMMA*((1/self.NETSIZE)-self.freq[i])""" i, j = self.SPECIALS, self.NETSIZE dists = abs(self.network[i:j] - np.array([b,g,r])).sum(1) bestpos = i + np.argmin(dists) biasdists = dists - self.bias[i:j] bestbiaspos = i + np.argmin(biasdists) self.freq[i:j] *= (1-self.BETA) self.bias[i:j] += self.BETAGAMMA * self.freq[i:j] self.freq[bestpos] += self.BETA self.bias[bestpos] -= self.BETAGAMMA return bestbiaspos def specialFind(self, b, g, r): for i in range(self.SPECIALS): n = self.network[i] if n[0] == b and n[1] == g and n[2] == r: return i return -1 def learn(self): biasRadius = self.INITBIASRADIUS alphadec = 30 + ((self.samplefac-1)/3) lengthcount = self.pixels.size samplepixels = lengthcount / self.samplefac delta = samplepixels / self.NCYCLES alpha = self.INITALPHA i = 0; rad = biasRadius * 2**self.RADIUSBIASSHIFT if rad <= 1: rad = 0 print("Beginning 1D learning: samplepixels = %1.2f rad = %i" % (samplepixels, rad) ) step = 0 pos = 0 if lengthcount%NeuQuant.PRIME1 != 0: step = NeuQuant.PRIME1 elif lengthcount%NeuQuant.PRIME2 != 0: step = NeuQuant.PRIME2 elif lengthcount%NeuQuant.PRIME3 != 0: step = NeuQuant.PRIME3 else: step = NeuQuant.PRIME4 i = 0 printed_string = '' while i < samplepixels: if i%100 == 99: tmp = '\b'*len(printed_string) printed_string = str((i+1)*100/samplepixels)+"%\n" print(tmp + printed_string) p = self.pixels[pos] r = (p >> 16) & 0xff g = (p >> 8) & 0xff b = (p ) & 0xff if i == 0: # Remember background colour self.network[self.BGCOLOR] = [b, g, r] j = self.specialFind(b, g, r) if j < 0: j = self.contest(b, g, r) if j >= self.SPECIALS: # Don't learn for specials a = (1.0 * alpha) / self.INITALPHA self.altersingle(a, j, b, g, r) if rad > 0: self.alterneigh(a, rad, j, b, g, r) pos = (pos+step)%lengthcount i += 1 if i%delta == 0: alpha -= alpha / alphadec biasRadius -= biasRadius / self.RADIUSDEC rad = biasRadius * 2**self.RADIUSBIASSHIFT if rad <= 1: rad = 0 finalAlpha = (1.0*alpha)/self.INITALPHA print("Finished 1D learning: final alpha = %1.2f!" % finalAlpha) def fix(self): for i in range(self.NETSIZE): for j in range(3): x = int(0.5 + self.network[i,j]) x = max(0, x) x = min(255, x) self.colormap[i,j] = x self.colormap[i,3] = i def inxbuild(self): previouscol = 0 startpos = 0 for i in range(self.NETSIZE): p = self.colormap[i] q = None smallpos = i smallval = p[1] # Index on g # Find smallest in i..self.NETSIZE-1 for j in range(i+1, self.NETSIZE): q = self.colormap[j] if q[1] < smallval: # Index on g smallpos = j smallval = q[1] # Index on g q = self.colormap[smallpos] # Swap p (i) and q (smallpos) entries if i != smallpos: p[:],q[:] = q, p.copy() # smallval entry is now in position i if smallval != previouscol: self.netindex[previouscol] = (startpos+i) >> 1 for j in range(previouscol+1, smallval): self.netindex[j] = i previouscol = smallval startpos = i self.netindex[previouscol] = (startpos+self.MAXNETPOS) >> 1 for j in range(previouscol+1, 256): # Really 256 self.netindex[j] = self.MAXNETPOS def paletteImage(self): """ PIL weird interface for making a paletted image: create an image which already has the palette, and use that in Image.quantize. This function returns this palette image. """ if self.pimage is None: palette = [] for i in range(self.NETSIZE): palette.extend(self.colormap[i][:3]) palette.extend([0]*(256-self.NETSIZE)*3) # a palette image to use for quant self.pimage = Image.new("P", (1, 1), 0) self.pimage.putpalette(palette) return self.pimage def quantize(self, image): """ Use a kdtree to quickly find the closest palette colors for the pixels """ if get_cKDTree(): return self.quantize_with_scipy(image) else: print('Scipy not available, falling back to slower version.') return self.quantize_without_scipy(image) def quantize_with_scipy(self, image): w,h = image.size px = np.asarray(image).copy() px2 = px[:,:,:3].reshape((w*h,3)) cKDTree = get_cKDTree() kdtree = cKDTree(self.colormap[:,:3],leafsize=10) result = kdtree.query(px2) colorindex = result[1] print("Distance: %1.2f" % (result[0].sum()/(w*h)) ) px2[:] = self.colormap[colorindex,:3] return Image.fromarray(px).convert("RGB").quantize(palette=self.paletteImage()) def quantize_without_scipy(self, image): """" This function can be used if no scipy is availabe. It's 7 times slower though. """ w,h = image.size px = np.asarray(image).copy() memo = {} for j in range(w): for i in range(h): key = (px[i,j,0],px[i,j,1],px[i,j,2]) try: val = memo[key] except KeyError: val = self.convert(*key) memo[key] = val px[i,j,0],px[i,j,1],px[i,j,2] = val return Image.fromarray(px).convert("RGB").quantize(palette=self.paletteImage()) def convert(self, *color): i = self.inxsearch(*color) return self.colormap[i,:3] def inxsearch(self, r, g, b): """Search for BGR values 0..255 and return colour index""" dists = (self.colormap[:,:3] - np.array([r,g,b])) a= np.argmin((dists*dists).sum(1)) return a if __name__ == '__main__': im = np.zeros((200,200), dtype=np.uint8) im[10:30,:] = 100 im[:,80:120] = 255 im[-50:-40,:] = 50 images = [im*1.0, im*0.8, im*0.6, im*0.4, im*0] writeGif('lala3.gif',images, duration=0.5, dither=0)
jamesrobb/remo-2016-mongooses
rush_hour/gif/images2gif.py
Python
mit
36,120
[ "NEURON" ]
e865ab661431dda627da0141c5ec0ea28c0a7f65c8ad6362855521138c22257d
############################################################################### ## ## Copyright (C) 2006-2011, University of Utah. ## All rights reserved. ## Contact: contact@vistrails.org ## ## This file is part of VisTrails. ## ## "Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are met: ## ## - Redistributions of source code must retain the above copyright notice, ## this list of conditions and the following disclaimer. ## - Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### import copy from db.versions.v0_7_0.domain import DBVistrail, DBAction, DBTag, DBModule, \ DBConnection, DBPortSpec, DBFunction, DBParameter, DBLocation, DBAdd, \ DBChange, DBDelete, DBAnnotation, DBPort def translateVistrail(_vistrail): vistrail = DBVistrail() for _action in _vistrail.db_actions.itervalues(): ops = [] for op in _action.db_operations: if op.vtType == 'add': data = convert_data(op.db_data, op.db_parentObjType, op.db_parentObjId) ops.append(DBAdd(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'change': data = convert_data(op.db_data, op.db_parentObjType, op.db_parentObjId) ops.append(DBChange(id=op.db_id, what=op.db_what, oldObjId=op.db_oldObjId, newObjId=op.db_newObjId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'delete': ops.append(DBDelete(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType)) action = DBAction(id=_action.db_id, prevId=_action.db_prevId, date=_action.db_date, user=_action.db_user, operations=ops, annotations=_action.db_annotations.values()) vistrail.db_add_action(action) for _tag in _vistrail.db_tags.itervalues(): tag = DBTag(id=_tag.db_id, name=_tag.db_name) vistrail.db_add_tag(tag) vistrail.db_version = '0.7.0' return vistrail module_map = {} translate_ports = {'SetInputConnection': {None: 'SetInputConnection0'}, 'GetOutputPort': {None: 'GetOutputPort0'}, 'SetRenderWindow': {None: 'SetVTKCell'}, 'SetInteractorStyle': {None: 'InteractorStyle'}, 'ResetCamera': {None: 'ResetCamera'}, 'AddPoint': {None: 'AddPoint_1'}, 'AddRGBPoint': {None: 'AddRGBPoint_1'}, 'AddHSVPoint': {None: 'AddHSVPoint_1'}, 'AddInput': {None: 'AddInput', 'vtkXYPlotActor': 'AddInput_2'}, 'SetInput': {None: 'SetInput', 'vtkPolyDataNormals': 'SetInput_1', 'vtkGlyph3D': 'SetInput_1', 'vtkDelaunay2D': 'SetInput_1', 'vtkDelaunay3D': 'SetInput_1', 'vtkWarpVector': 'SetInput_1', 'vtkContourFilter': 'SetInput_1', 'vtkTubeFilter': 'SetInput_1', 'vtkThresholdPoints': 'SetInput_1', 'vtkProbeFilter': 'SetInput_1', 'vtkTriangleFilter': 'SetInput_1', 'vtkBandedPolyDataContourFilter': \ 'SetInput_1', 'vtkWarpScalar': 'SetInput_1'}, 'SetSourceConnection': {None: 'SetSourceConnection', 'vtkGlyph3D': \ 'SetSourceConnection_2'}, 'AddFunction': {None: 'AddFunction', ('vtkImplicitSum', 'vtkPlane'): \ 'AddFunction_2', ('vtkImplicitSum', 'Tuple'): \ 'AddFunction_1'}, 'SetColor': {None: 'SetColor', ('vtkVolumeProperty', 'vtkColorTransferFunction'): \ 'SetColor_4', ('vtkVolumeProperty', 'vtkPiecewiseFunction'): \ 'SetColor_2'}, 'SetScalarOpacity': {None: 'SetScalarOpacity', 'vtkVolumeProperty': \ 'SetScalarOpacity_2'}, 'SetGradientOpacity': {None: 'SetGradientOpacity', 'vtkVolumeProperty': 'SetGradientOpacity_2'}, 'SetSource': {None: 'SetSource', 'vtkGlyph3D': 'SetSource_1'}, } def translate_vtk(module_id, port_name, specs=None): global module_map if port_name in translate_ports: if module_id in module_map: (module_name, module_pkg) = module_map[module_id] if module_pkg != 'edu.utah.sci.vistrails.vtk': return port_name if module_name in translate_ports[port_name]: port_name = translate_ports[port_name][module_name] elif (module_name, specs) in translate_ports[port_name]: port_name = translate_ports[port_name][(module_name, specs)] else: port_name = translate_ports[port_name][None] return port_name def convert_data(child, parent_type, parent_id): from core.vistrail.port_spec import PortSpec from core.modules.module_registry import get_module_registry global module_map, translate_ports registry = get_module_registry() if child.vtType == 'module': descriptor = registry.get_descriptor_from_name_only(child.db_name) package = descriptor.identifier module_map[child.db_id] = (child.db_name, package) return DBModule(id=child.db_id, cache=child.db_cache, abstraction=0, name=child.db_name, package=package) elif child.vtType == 'connection': return DBConnection(id=child.db_id) elif child.vtType == 'portSpec': return DBPortSpec(id=child.db_id, name=child.db_name, type=child.db_type, spec=child.db_spec) elif child.vtType == 'function': if parent_type == 'module': name = translate_vtk(parent_id, child.db_name) else: name = child.db_name return DBFunction(id=child.db_id, pos=child.db_pos, name=name) elif child.vtType == 'parameter': return DBParameter(id=child.db_id, pos=child.db_pos, name=child.db_name, type=child.db_type, val=child.db_val, alias=child.db_alias) elif child.vtType == 'location': return DBLocation(id=child.db_id, x=child.db_x, y=child.db_y) elif child.vtType == 'annotation': return DBAnnotation(id=child.db_id, key=child.db_key, value=child.db_value) elif child.vtType == 'port': sig = child.db_sig if '(' in sig and ')' in sig: name = sig[:sig.find('(')] specs = sig[sig.find('(')+1:sig.find(')')] name = translate_vtk(child.db_moduleId, name, specs) new_specs = [] for spec_name in specs.split(','): descriptor = registry.get_descriptor_from_name_only(spec_name) spec_str = descriptor.identifier + ':' + spec_name new_specs.append(spec_str) spec = '(' + ','.join(new_specs) + ')' else: name = sig spec = '' return DBPort(id=child.db_id, type=child.db_type, moduleId=child.db_moduleId, moduleName=child.db_moduleName, name=name, spec=spec)
CMUSV-VisTrails/WorkflowRecommendation
vistrails/db/versions/v0_7_0/translate/v0_6_0.py
Python
bsd-3-clause
10,591
[ "VTK" ]
d2d358bd63bc6dbf21b3571399deed39de261481ce3ff80cd146b2b0458527f1
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class RScater(RPackage): """Single-Cell Analysis Toolkit for Gene Expression Data in R. A collection of tools for doing various analyses of single-cell RNA-seq gene expression data, with a focus on quality control and visualization.""" homepage = "https://bioconductor.org/packages/scater" git = "https://git.bioconductor.org/packages/scater.git" version('1.12.2', commit='1518dc27a87c79181c34107d639e95fe55e55092') version('1.10.1', commit='2e6694af2929092f263c2b0830d48b3f9632e70c') version('1.8.4', commit='d560a9a378541d53d17990d2aa2cd28874df3dcd') version('1.6.3', commit='964effb4e883102d7c8cae627dbac4ba5d216a75') version('1.4.0', commit='90a2eab66ff82ba6dd7fbb33e41cd0ded20fa218') depends_on('r@3.3:', when='@1.4.0', type=('build', 'run')) depends_on('r-biobase', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-ggplot2', type=('build', 'run')) depends_on('r-biomart', when='@1.4.0:1.6.3', type=('build', 'run')) depends_on('r-biocgenerics', type=('build', 'run')) depends_on('r-data-table', when='@1.4.0:1.6.3', type=('build', 'run')) depends_on('r-dplyr', when='@1.4.0:1.12.2', type=('build', 'run')) depends_on('r-edger', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-ggbeeswarm', type=('build', 'run')) depends_on('r-limma', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-matrix', type=('build', 'run')) depends_on('r-matrixstats', when='@1.4.0:1.6.3', type=('build', 'run')) depends_on('r-plyr', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-reshape2', when='@1.4.0:1.10.1', type=('build', 'run')) depends_on('r-rhdf5', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-rjson', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-shiny', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-shinydashboard', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-tximport', when='@1.4.0:1.8.4', type=('build', 'run')) depends_on('r-viridis', type=('build', 'run')) depends_on('r@3.4:', when='@1.6.3', type=('build', 'run')) depends_on('r-singlecellexperiment', when='@1.6.3:', type=('build', 'run')) depends_on('r-summarizedexperiment', when='@1.6.3:', type=('build', 'run')) depends_on('r-s4vectors', when='@1.6.3:', type=('build', 'run')) depends_on('r-rcpp', when='@1.6.3:', type=('build', 'run')) depends_on('r-rhdf5lib', when='@1.6.3:1.10.1', type=('build', 'run')) depends_on('r-beachmat', when='@1.6.3:', type=('build', 'run')) depends_on('r@3.5:', when='@1.8.4', type=('build', 'run')) depends_on('r-delayedmatrixstats', when='@1.8.4:', type=('build', 'run')) depends_on('r-rcpp@0.12.14:', when='@1.8.4:', type=('build', 'run')) depends_on('r-delayedarray', when='@1.8.4:', type=('build', 'run')) depends_on('r-biocparallel', when='@1.10.1:', type=('build', 'run')) depends_on('r@3.6:', when='@1.12.2', type=('build', 'run')) depends_on('r-biocneighbors', when='@1.12.2:', type=('build', 'run')) depends_on('r-biocsingular', when='@1.12.2:', type=('build', 'run'))
rspavel/spack
var/spack/repos/builtin/packages/r-scater/package.py
Python
lgpl-2.1
3,379
[ "Bioconductor" ]
39981e8bf6aa693dd6798ab558abdaedee8fea10bcd5e4d1ac1a6e7273857bf7
#!/usr/bin/env python # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from __future__ import print_function import re import scm import subprocess2 import sys try: import urlparse except ImportError: # For Py3 compatibility import urllib.parse as urlparse # Current version of metrics recording. # When we add new metrics, the version number will be increased, we display the # user what has changed, and ask the user to agree again. CURRENT_VERSION = 1 APP_URL = 'https://cit-cli-metrics.appspot.com' def get_notice_countdown_header(countdown): if countdown == 0: yield ' METRICS COLLECTION IS TAKING PLACE' else: yield ' METRICS COLLECTION WILL START IN %d EXECUTIONS' % countdown def get_notice_version_change_header(): yield ' WE ARE COLLECTING ADDITIONAL METRICS' yield '' yield ' Please review the changes and opt-in again.' def get_notice_footer(): yield 'To suppress this message opt in or out using:' yield '$ gclient metrics [--opt-in] [--opt-out]' yield 'For more information please see metrics.README.md' yield 'in your depot_tools checkout or visit' yield 'https://goo.gl/yNpRDV.' def get_change_notice(version): if version == 0: pass # No changes for version 0 elif version == 1: yield 'We want to collect the Git version.' yield 'We want to collect information about the HTTP' yield 'requests that depot_tools makes, and the git and' yield 'cipd commands it executes.' yield '' yield 'We only collect known strings to make sure we' yield 'don\'t record PII.' KNOWN_PROJECT_URLS = { 'https://chrome-internal.googlesource.com/chrome/ios_internal', 'https://chrome-internal.googlesource.com/infra/infra_internal', 'https://chromium.googlesource.com/breakpad/breakpad', 'https://chromium.googlesource.com/chromium/src', 'https://chromium.googlesource.com/chromium/tools/depot_tools', 'https://chromium.googlesource.com/crashpad/crashpad', 'https://chromium.googlesource.com/external/gyp', 'https://chromium.googlesource.com/external/naclports', 'https://chromium.googlesource.com/infra/goma/client', 'https://chromium.googlesource.com/infra/infra', 'https://chromium.googlesource.com/native_client/', 'https://chromium.googlesource.com/syzygy', 'https://chromium.googlesource.com/v8/v8', 'https://dart.googlesource.com/sdk', 'https://pdfium.googlesource.com/pdfium', 'https://skia.googlesource.com/buildbot', 'https://skia.googlesource.com/skia', 'https://webrtc.googlesource.com/src', } KNOWN_HTTP_HOSTS = { 'chrome-internal-review.googlesource.com', 'chromium-review.googlesource.com', 'dart-review.googlesource.com', 'eu1-mirror-chromium-review.googlesource.com', 'pdfium-review.googlesource.com', 'skia-review.googlesource.com', 'us1-mirror-chromium-review.googlesource.com', 'us2-mirror-chromium-review.googlesource.com', 'us3-mirror-chromium-review.googlesource.com', 'webrtc-review.googlesource.com', } KNOWN_HTTP_METHODS = { 'DELETE', 'GET', 'PATCH', 'POST', 'PUT', } KNOWN_HTTP_PATHS = { 'accounts': re.compile(r'(/a)?/accounts/.*'), 'changes': re.compile(r'(/a)?/changes/([^/]+)?$'), 'changes/abandon': re.compile(r'(/a)?/changes/.*/abandon'), 'changes/comments': re.compile(r'(/a)?/changes/.*/comments'), 'changes/detail': re.compile(r'(/a)?/changes/.*/detail'), 'changes/edit': re.compile(r'(/a)?/changes/.*/edit'), 'changes/message': re.compile(r'(/a)?/changes/.*/message'), 'changes/restore': re.compile(r'(/a)?/changes/.*/restore'), 'changes/reviewers': re.compile(r'(/a)?/changes/.*/reviewers/.*'), 'changes/revisions/commit': re.compile(r'(/a)?/changes/.*/revisions/.*/commit'), 'changes/revisions/review': re.compile(r'(/a)?/changes/.*/revisions/.*/review'), 'changes/submit': re.compile(r'(/a)?/changes/.*/submit'), 'projects/branches': re.compile(r'(/a)?/projects/.*/branches/.*'), } KNOWN_HTTP_ARGS = { 'ALL_REVISIONS', 'CURRENT_COMMIT', 'CURRENT_REVISION', 'DETAILED_ACCOUNTS', 'LABELS', } GIT_VERSION_RE = re.compile( r'git version (\d)\.(\d{0,2})\.(\d{0,2})' ) KNOWN_SUBCOMMAND_ARGS = { 'cc', 'hashtag', 'l=Auto-Submit+1', 'l=Code-Review+1', 'l=Code-Review+2', 'l=Commit-Queue+1', 'l=Commit-Queue+2', 'label', 'm', 'notify=ALL', 'notify=NONE', 'private', 'r', 'ready', 'topic', 'wip' } def get_python_version(): """Return the python version in the major.minor.micro format.""" return '{v.major}.{v.minor}.{v.micro}'.format(v=sys.version_info) def get_git_version(): """Return the Git version in the major.minor.micro format.""" p = subprocess2.Popen( ['git', '--version'], stdout=subprocess2.PIPE, stderr=subprocess2.PIPE) stdout, _ = p.communicate() match = GIT_VERSION_RE.match(stdout.decode('utf-8')) if not match: return None return '%s.%s.%s' % match.groups() def return_code_from_exception(exception): """Returns the exit code that would result of raising the exception.""" if exception is None: return 0 if isinstance(exception[1], SystemExit): return exception[1].code return 1 def extract_known_subcommand_args(args): """Extract the known arguments from the passed list of args.""" known_args = [] for arg in args: if arg in KNOWN_SUBCOMMAND_ARGS: known_args.append(arg) else: arg = arg.split('=')[0] if arg in KNOWN_SUBCOMMAND_ARGS: known_args.append(arg) return sorted(known_args) def extract_http_metrics(request_uri, method, status, response_time): """Extract metrics from the request URI. Extracts the host, path, and arguments from the request URI, and returns them along with the method, status and response time. The host, method, path and arguments must be in the KNOWN_HTTP_* constants defined above. Arguments are the values of the o= url parameter. In Gerrit, additional fields can be obtained by adding o parameters, each option requires more database lookups and slows down the query response time to the client, so we make an effort to collect them. The regex defined in KNOWN_HTTP_PATH_RES are checked against the path, and those that match will be returned. """ http_metrics = { 'status': status, 'response_time': response_time, } if method in KNOWN_HTTP_METHODS: http_metrics['method'] = method parsed_url = urlparse.urlparse(request_uri) if parsed_url.netloc in KNOWN_HTTP_HOSTS: http_metrics['host'] = parsed_url.netloc for name, path_re in KNOWN_HTTP_PATHS.items(): if path_re.match(parsed_url.path): http_metrics['path'] = name break parsed_query = urlparse.parse_qs(parsed_url.query) # Collect o-parameters from the request. args = [ arg for arg in parsed_query.get('o', []) if arg in KNOWN_HTTP_ARGS ] if args: http_metrics['arguments'] = args return http_metrics def get_repo_timestamp(path_to_repo): """Get an approximate timestamp for the upstream of |path_to_repo|. Returns the top two bits of the timestamp of the HEAD for the upstream of the branch path_to_repo is checked out at. """ # Get the upstream for the current branch. If we're not in a branch, fallback # to HEAD. try: upstream = scm.GIT.GetUpstreamBranch(path_to_repo) or 'HEAD' except subprocess2.CalledProcessError: upstream = 'HEAD' # Get the timestamp of the HEAD for the upstream of the current branch. p = subprocess2.Popen( ['git', '-C', path_to_repo, 'log', '-n1', upstream, '--format=%at'], stdout=subprocess2.PIPE, stderr=subprocess2.PIPE) stdout, _ = p.communicate() # If there was an error, give up. if p.returncode != 0: return None return stdout.strip() def print_boxed_text(out, min_width, lines): [EW, NS, SE, SW, NE, NW] = list('=|++++') width = max(min_width, max(len(line) for line in lines)) out(SE + EW * (width + 2) + SW + '\n') for line in lines: out('%s %-*s %s\n' % (NS, width, line, NS)) out(NE + EW * (width + 2) + NW + '\n') def print_notice(countdown): """Print a notice to let the user know the status of metrics collection.""" lines = list(get_notice_countdown_header(countdown)) lines.append('') lines += list(get_notice_footer()) print_boxed_text(sys.stderr.write, 49, lines) def print_version_change(config_version): """Print a notice to let the user know we are collecting more metrics.""" lines = list(get_notice_version_change_header()) for version in range(config_version + 1, CURRENT_VERSION + 1): lines.append('') lines += list(get_change_notice(version)) print_boxed_text(sys.stderr.write, 49, lines)
endlessm/chromium-browser
third_party/depot_tools/metrics_utils.py
Python
bsd-3-clause
8,811
[ "VisIt" ]
530f7574c5010dcdb1dacd0c1e32cc1a0c0223d0242ab1b97545b820f62cb9bd
#!usr/bin/env python import sys from Bio import SeqIO import networkx as nx from collections import Counter import os from commands import getoutput # do the core gene find def manual_print(): print 'This script used reciprocal best hits to identify orthologs between species and a given species, then extract sequences of these orthologs and do a msa, finally, concatenate all the msa.' print 'Usage:' print ' python this.py -i foo.m8 -f foo.fsa [-r taxon]\n' print 'Parameters:' print ' -i: blast -m8 or fastclust sc format:\n xxxx|yyyy\tXXXX|YYYY\t...: xxxx/XXXX is taxon name and yyyy/YYYY is unique identifier in that taxon' print ' -f: protein/gene fasta file. The header should be like xxxx|yyyy: xxxx is taxon name and yyyy is unqiue identifier in that taxon' print ' -r: taxonomy name used as reference [optional]' argv = sys.argv # recommand parameter: args = {'-i': '', '-f': '', '-r': ''} N = len(argv) for i in xrange(1, N): k = argv[i] if k in args: try: v = argv[i + 1] except: break args[k] = v elif k[:2] in args and len(k) > 2: args[k[:2]] = k[2:] else: continue if args['-i'] == '' or args['-f'] == '': manual_print() raise SystemExit() try: orth, fas, taxon = args['-i'], args['-f'], args['-r'] except: manual_print() raise SystemExit() # check reference taxon taxon_ct = Counter() f = open(fas, 'r') for i in f: if i.startswith('>'): j = i[1:-1].split('|')[0] taxon_ct[j] += 1 f.close() # if taxon not specified, then choose the taxon with most genes taxon_hf = taxon_ct.items() taxon_hf.sort(key=lambda x: x[1], reverse=True) taxon_N = len(taxon_hf) taxon_max = taxon_hf[0] taxon = taxon == '' and taxon_max[0] or taxon #taxon_idx = {b: a for a, b in enumerate(taxon_ct.keys())} taxon_idx = {b: a for a, b in enumerate([elem[0] for elem in taxon_hf])} # get the ortholog # find ortholog in all tax def m8parse(f): flag = None out = [] for i in f: j = i[:-1].split('\t') qid = j[0] if flag != qid: if out: out.sort(key=lambda x: -float(x[11])) yield out flag = qid out = [j] else: out.append(j) if out: out.sort(key=lambda x: -float(x[11])) yield out Orth = orth #os.system('mkdir -p ./alns_tmp/') os.system('mkdir -p %s_alns_tmp/'%Orth) f = open(orth, 'r') ortholog = {} for i in m8parse(f): Os = {} for j in i: qid, sid = j[:2] qtx, stx = qid.split('|')[0], sid.split('|')[0] key = (qtx, stx) if qtx == taxon and stx != taxon: if key not in Os: Os[key] = [qid, sid] else: continue for qid, sid in Os.itervalues(): qtx, stx = qid.split('|')[0], sid.split('|')[0] if qid not in ortholog: ortholog[qid] = [-1] * taxon_N * 2 ortholog[qid][:2] = qid, 1 sidx = taxon_idx[stx] * 2 ortholog[qid][sidx] = sid #ortholog[qid][sidx + 1] = 1 #print 'ortho', ortholog[qid] f.close() f = open(orth, 'r') for i in m8parse(f): Os = {} for j in i: qid, sid = j[:2] qtx, stx = qid.split('|')[0], sid.split('|')[0] key = (qtx, stx) if qtx != taxon and stx == taxon: if key not in Os: Os[key] = [sid, qid] else: continue #if Os: # print 'yes', Os.values(), len(ortholog) for qid, sid in Os.itervalues(): if qid not in ortholog: #print 'no found', qid continue qtx, stx = qid.split('|')[0], sid.split('|')[0] sidx = taxon_idx[stx] * 2 if ortholog[qid][sidx] == sid: ortholog[qid][sidx + 1] = 1 #print 'yes match', ortholog[qid][sidx], sid #else: # print 'not match', ortholog[qid][sidx], sid #print 'ortho', ortholog[qid] f.close() #print 'taxon N is', taxon_N # print ortholog orths = [] orths_set = set() # for i in ortholog.keys(): for j in ortholog.values(): # j = ortholog[i] orth = [a for a, b in zip(j[::2], j[1::2]) if b == 1] # print orth, taxon, j rate = len(orth) * 1. / taxon_N if rate >= .9: orths.append(orth) orths_set.update(orth) else: continue #print rate, len(orth), taxon_N seqs_dict = {} for i in SeqIO.parse(fas, 'fasta'): if i.id in orths_set: seqs_dict[i.id] = i # print len(seqs) # raise SystemExit() # write the seq to file orths_N = len(orths) for i in xrange(orths_N): j = orths[i] seqs = [seqs_dict[elem] for elem in j] #_o = open('./alns_tmp/%d.fsa' % i, 'w') _o = open('%s_alns_tmp/%d.fsa' % (Orth, i), 'w') #_o.write('>%s|%s\n%s\n' % (tax, qid, sq)) SeqIO.write(seqs, _o, 'fasta') _o.close() # raise SystemExit() # use the muscle to aln if not getoutput('type famsa').endswith('not found'): #cmd = 'famsa -t 0 %s_alns_tmp/%d.fsa %s_alns_tmp/%d.fsa.aln' % (Orth, i, Orth, i) cmd = 'famsa -t 4 %s_alns_tmp/%d.fsa %s_alns_tmp/%d.fsa.aln' elif not getoutput('type mafft').endswith('not found'): #cmd = 'mafft --quiet --auto %s_alns_tmp/%d.fsa > %s_alns_tmp/%d.fsa.aln' % (Orth, i, Orth, i) cmd = 'mafft --quiet --auto %s_alns_tmp/%d.fsa > %s_alns_tmp/%d.fsa.aln' elif not getoutput('type muscle').endswith('not found'): #cmd = 'muscle -in %s_alns_tmp/%d.fsa -out %s_alns_tmp/%d.fsa.aln -fasta -quiet' % (Orth, i, Orth, i) cmd = 'muscle -in %s_alns_tmp/%d.fsa -out %s_alns_tmp/%d.fsa.aln -fasta -quiet' else: print 'only support famsa|mafft|muscle' raise SystemExit() for i in xrange(orths_N): # break #os.system('muscle -in %s_alns_tmp/%d.fsa -out %s_alns_tmp/%d.fsa.aln -fasta -quiet' % (Orth, i, Orth, i)) os.system(cmd%(Orth, i, Orth, i)) # os.system('/home/zhans/tools/tree_tools/trimal/source/trimal -in ./alns_tmp/%d.fsa.aln -out ./alns_tmp/%d.fsa.aln.trim -automated1' % (i, i)) # N = len([elem for elem in os.listdir('./tmpdir') if elem.endswith('.trim')]) # print 'total N', N taxon_set = set(taxon_ct.keys()) tree = {} for i in xrange(orths_N): # seqs = SeqIO.parse('./alns_tmp/%d.fsa.aln.trim' % i, 'fasta') #seqs = SeqIO.parse('./alns_tmp/%d.fsa.aln' % i, 'fasta') seqs = SeqIO.parse('%s_alns_tmp/%d.fsa.aln' % (Orth, i), 'fasta') visit = set() for j in seqs: taxon = j.id.split('|', 2)[0] try: tree[taxon].append(str(j.seq)) except: tree[taxon] = [str(j.seq)] empty = '-' * len(j.seq) visit.add(taxon) for taxon in (taxon_set - visit): try: tree[taxon].append(empty) except: tree[taxon] = [empty] # print 'tree is', tree # flag = 0 N = len(tree) L = len(''.join(tree.values()[0])) # print ' %d %d' % (N, L) for i in tree: hd = '>' + i # hd = i sq = ''.join(tree[i]) # print hd, sq print hd print sq #os.system('rm -rf %s_alns_tmp'%Orth)
Rinoahu/fastclust
deprecate/py27/scripts/rbh2phy.py
Python
gpl-3.0
7,356
[ "BLAST", "VisIt" ]
4fb657cb137d58ed45759cd718921c41210b0c74b47c772080d254a8b7355b4b
# pymol -c generate2.py from chempy import io from glob import glob from copy import deepcopy # backbone-independent rotamers lines = io.lst.fromFile("bbind02.May.lib") # skip to the data section while lines[0][0:3]!='Res': lines.pop(0) lines.pop(0) chi = { 'CYS' : { '1': ('N' , 'CA' , 'CB' , 'SG' ) }, 'ASP' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'OD1'), }, 'GLU' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD' ), '3': ('CB' , 'CG' , 'CD' , 'OE1'), }, 'PHE' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD1'), }, 'HIS' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'ND1'), }, 'ILE' : { '1': ('N' , 'CA' , 'CB' , 'CG1'), '2': ('CA' , 'CB' , 'CG1', 'CD1+CD'), }, 'LYS' : { '1': ('N' , 'CA' , 'CB' ,'CG' ), '2': ('CA' , 'CB' , 'CG' ,'CD' ), '3': ('CB' , 'CG' , 'CD' ,'CE' ), '4': ('CG' , 'CD' , 'CE' ,'NZ' ), }, 'LEU' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD1'), }, 'MET' : { '1': ('N' , 'CA' , 'CB' ,'CG' ), '2': ('CA' , 'CB' , 'CG' ,'SD' ), '3': ('CB' , 'CG' , 'SD' ,'CE' ), }, 'ASN' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'OD1'), }, 'PRO' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD' ), }, 'GLN' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD' ), '3': ('CB' , 'CG' , 'CD' , 'OE1'), }, 'ARG' : { '1': ('N' , 'CA' , 'CB' ,'CG' ), '2': ('CA' , 'CB' , 'CG' ,'CD' ), '3': ('CB' , 'CG' , 'CD' ,'NE' ), '4': ('CG' , 'CD' , 'NE' ,'CZ' ), }, 'SER' : { '1': ('N' , 'CA' , 'CB' , 'OG' ), }, 'THR' : { '1': ('N' , 'CA' , 'CB' , 'OG1'), }, 'VAL' : { '1': ('N' , 'CA' , 'CB' , 'CG1'), }, 'TRP' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD1'), }, 'TYR' : { '1': ('N' , 'CA' , 'CB' , 'CG' ), '2': ('CA' , 'CB' , 'CG' , 'CD1'), }, } total = {} output = {} # first, total the number of rotamers for each residue for line in lines: field = line.split() if len(field)>6: resn = field[0] total[resn] = total.get(resn,0) + int(field[6]) # now build library, including frequency value for line in lines: field = line.split() len_field = len(field) if len_field>11: resn = field[0] list = output.get(resn,[]) count = float(field[6]) dict = {} freq = count/total[resn] dict['FREQ'] = freq if len_field>11: chi1 = float(field[11]) dict[chi[resn]['1']] = chi1 if len_field>13: chi2 = float(field[13]) dict[chi[resn]['2']] = chi2 if len_field>15: chi3 = float(field[15]) dict[chi[resn]['3']] = chi3 if len_field>17: chi4 = float(field[17]) dict[chi[resn]['4']] = chi4 list.append((freq,dict)) output[resn] = list # sort by priority for resn in output: list = output[resn] list.sort() list.reverse() output[resn] = map(lambda x:x[1],list) # common aliases #output['HIE'] = output['HIS'] #output['HID'] = output['HIS'] #output['HIP'] = output['HIS'] #output['CYX'] = output['CYS'] io.pkl.toFile(output,"sc_bb_ind.pkl")
gratefulfrog/lib
python/pymol/pymol_path/data/chempy/sidechains/sc_bb_ind.py
Python
gpl-2.0
3,747
[ "ChemPy", "PyMOL" ]
9ea4958b32980590b486775001125c79b97c2bfb4678345a5365034d0e83cd15
import hashlib import os import pytest from Bootstrapper import BootstrapperPlugin from Bootstrapper.BootstrapperDb import BootstrapperDb from Peer import Peer from Crypt import CryptRsa from util import helper @pytest.fixture() def bootstrapper_db(request): BootstrapperPlugin.db.close() BootstrapperPlugin.db = BootstrapperDb() BootstrapperPlugin.db.createTables() # Reset db BootstrapperPlugin.db.cur.logging = True def cleanup(): BootstrapperPlugin.db.close() os.unlink(BootstrapperPlugin.db.db_path) request.addfinalizer(cleanup) return BootstrapperPlugin.db @pytest.mark.usefixtures("resetSettings") class TestBootstrapper: def testBootstrapperDb(self, file_server, bootstrapper_db): ip_type = helper.getIpType(file_server.ip) peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256("site1").digest() hash2 = hashlib.sha256("site2").digest() hash3 = hashlib.sha256("site3").digest() # Verify empty result res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 0 # Empty result # Verify added peer on previous request bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1, hash2], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 1 # hash2 deleted from 1.2.3.4 bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 0 # Announce 3 hash again bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1, hash2, hash3], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 1 assert len(res["peers"][2][ip_type]) == 1 # Single hash announce res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 # Test DB cleanup assert map(lambda row: row[0], bootstrapper_db.execute("SELECT address FROM peer").fetchall()) == [file_server.ip_external] # 127.0.0.1 never get added to db # Delete peers bootstrapper_db.execute("DELETE FROM peer WHERE address = ?", [file_server.ip_external]) assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM peer_to_hash").fetchone()["num"] == 0 assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM hash").fetchone()["num"] == 3 # 3 sites assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM peer").fetchone()["num"] == 0 # 0 peer def testPassive(self, file_server, bootstrapper_db): peer = Peer(file_server.ip, 1544, connection_server=file_server) ip_type = helper.getIpType(file_server.ip) hash1 = hashlib.sha256("hash1").digest() bootstrapper_db.peerAnnounce(ip_type, address=None, port=15441, hashes=[hash1]) res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ipv4"]) == 0 # Empty result def testAddOnion(self, file_server, site, bootstrapper_db, tor_manager): onion1 = tor_manager.addOnion() onion2 = tor_manager.addOnion() peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256("site1").digest() hash2 = hashlib.sha256("site2").digest() hash3 = hashlib.sha256("site3").digest() bootstrapper_db.peerAnnounce(ip_type="ipv4", address="1.2.3.4", port=1234, hashes=[hash1, hash2, hash3]) res = peer.request("announce", { "onions": [onion1, onion1, onion2], "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert len(res["peers"][0]["ipv4"]) == 1 # Onion address not added yet site_peers = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers["onion"]) == 0 assert "onion_sign_this" in res # Sign the nonces sign1 = CryptRsa.sign(res["onion_sign_this"], tor_manager.getPrivatekey(onion1)) sign2 = CryptRsa.sign(res["onion_sign_this"], tor_manager.getPrivatekey(onion2)) # Bad sign (different address) res = peer.request("announce", { "onions": [onion1], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion2): sign2}, "hashes": [hash1], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" in res site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 0 # Not added # Bad sign (missing one) res = peer.request("announce", { "onions": [onion1, onion1, onion2], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion1): sign1}, "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" in res site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 0 # Not added # Good sign res = peer.request("announce", { "onions": [onion1, onion1, onion2], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion1): sign1, tor_manager.getPublickey(onion2): sign2}, "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" not in res # Onion addresses added site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 1 site_peers2 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash2) assert len(site_peers2["onion"]) == 1 site_peers3 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash3) assert len(site_peers3["onion"]) == 1 assert site_peers1["onion"][0] == site_peers2["onion"][0] assert site_peers2["onion"][0] != site_peers3["onion"][0] assert helper.unpackOnionAddress(site_peers1["onion"][0])[0] == onion1 + ".onion" assert helper.unpackOnionAddress(site_peers2["onion"][0])[0] == onion1 + ".onion" assert helper.unpackOnionAddress(site_peers3["onion"][0])[0] == onion2 + ".onion" tor_manager.delOnion(onion1) tor_manager.delOnion(onion2) def testRequestPeers(self, file_server, site, bootstrapper_db, tor_manager): site.connection_server = file_server file_server.tor_manager = tor_manager hash = hashlib.sha256(site.address).digest() # Request peers from tracker assert len(site.peers) == 0 bootstrapper_db.peerAnnounce(ip_type="ipv4", address="1.2.3.4", port=1234, hashes=[hash]) site.announcer.announceTracker("zero://%s:%s" % (file_server.ip, file_server.port)) assert len(site.peers) == 1 # Test onion address store bootstrapper_db.peerAnnounce(ip_type="onion", address="bka4ht2bzxchy44r", port=1234, hashes=[hash], onion_signed=True) site.announcer.announceTracker("zero://%s:%s" % (file_server.ip, file_server.port)) assert len(site.peers) == 2 assert "bka4ht2bzxchy44r.onion:1234" in site.peers @pytest.mark.slow def testAnnounce(self, file_server, tor_manager): file_server.tor_manager = tor_manager hash1 = hashlib.sha256("1Nekos4fiBqfcazyG1bAxdBT5oBvA76Z").digest() hash2 = hashlib.sha256("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr").digest() peer = Peer("zero.booth.moe", 443, connection_server=file_server) assert peer.request("ping") peer = Peer("boot3rdez4rzn36x.onion", 15441, connection_server=file_server) assert peer.request("ping") res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": ["ip4", "onion"], "need_num": 100, "add": [""] }) assert res def testBackwardCompatibility(self, file_server, bootstrapper_db): peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256("site1").digest() bootstrapper_db.peerAnnounce("ipv4", file_server.ip_external, port=15441, hashes=[hash1], delete_missing_hashes=True) # Test with ipv4 need type res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": ["ipv4"], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ipv4"]) == 1 # Test with ip4 need type res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": ["ip4"], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ip4"]) == 1
OliverCole/ZeroNet
plugins/disabled-Bootstrapper/Test/TestBootstrapper.py
Python
gpl-2.0
10,142
[ "MOE" ]
25462b20aed278957d189de0bf5c67fc0b33cbe87a10c61b33578890298324d1
# Copyright 2001 by Jeffrey Chang. All rights reserved. # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """ This module provides code to work the NCBI's XML format for Medline. Functions: choose_format Pick the right data format to use to index an XML file. index Index a Medline XML file. index_many Index multiple Medline XML files. """ import warnings warnings.warn("Bio.Medline.NLMMedlineXML was deprecated, as it does not seem to be able to parse recent Medline XML files. If you want to continue to use this module, please get in contact with the Biopython developers at biopython-dev@biopython.org to avoid permanent removal of this module from Biopython", DeprecationWarning) # To Do: # - Implement CitationParser import os import types from xml.sax import handler from Bio.ParserSupport import * from Bio import MultiProc import Martel def choose_format(data): """choose_format(data) -> module Look at some data and choose the right format to parse it. data should be the first 1000 characters or so of the file. The module will contain 2 attributes: citation_format and format. citation_format is a Martel format to parse one citation. format will parse the whole file. """ formats = [ ("nlmmedline_001211", "nlmmedline_001211_format"), ("nlmmedline_010319", "nlmmedline_010319_format"), ("nlmmedline_011101", "nlmmedline_011101_format"), ("nlmmedline_031101", "nlmmedline_031101_format"), ] for identifier, format_module in formats: if data.find(identifier) >= 0: break else: raise AssertionError, "I could not identify that format." package = '.'.join(["Bio", "Medline", format_module]) return __import__(package, {}, {}, ["*"]) class Citation: """Holds information about a Medline citation. Members: medline_id Medline ID. pmid Pubmed ID. date_created Tuple of (year, month, day, season, medline date). date_completed Tuple of (year, month, day, season, medline date). date_revised Tuple of (year, month, day, season, medline date). abstract Tuple of (text, copyright info). journal Tuple of (ISSN, volume, issue, date). article_title Title of article. pagination Tuple of (start, end, medline pagination). accession_numbers List of accession numbers. affiliation Affiliation. author_list List of authors. languages List of languages databank_list List of tuples (name, accession numbers). grant_list List of tuples (grant id, acronym, agency) publication_type_list List of publication types. vernacular_title Vernacular title. medline_journal_info Tuple of (country, medline ta, medline code, nlm id) chemical_list List of (CAS registry number, name). citation_subsets List of citation subsets. comments_corrections XXX not implemented gene_symbol_list List of gene symbols. mesh_heading_list List of (descriptor, subheadings). number_of_references Number of references (int). personal_name_subject_list List of personal names. """ pass class CitationParser(AbstractParser): """Parses a citation into a Record object. """ def __init__(self): raise NotImplementedError class _IndexerHandler(handler.ContentHandler): """Handles the results from the nlmmedline_format. Saves the begin and end of each record as an offset from the beginning of the parse. """ def __init__(self, found_citation_fn): """_IndexerHandler(found_citation_fn) found_citation_fn is called with the PMID, MedlineID, start, end where start and end are offsets from the beginning of the parse, with slice semantics. """ self._citation_fn = found_citation_fn self._elements = [] # Open element tags. self._offset = 0 # Current file offset. self._start = None # Offset of the start of the record. self._pmid = '' self._medline_id = '' def startElement(self, name, attrs): self._elements.append(name) if name == 'MedlineCitation': if self._start is not None: raise ValueError, "Found MedlineCitation, but already in one." self._start = self._offset def endElement(self, name): if not self._elements or self._elements[-1] != name: raise ValueError, "Elements not nested: %s" % name self._elements.pop() if name == 'MedlineCitation': if not self._pmid or not self._medline_id: # didn't find an ID: raise ValueError, "I couldn't find an id: %s %s" % ( self._pmid, self._medline_id) self._citation_fn( self._pmid, self._medline_id, self._start, self._offset) self._start = None self._pmid = self._medline_id = '' def characters(self, content): self._offset += len(content) # Examine the tags directly under <MedlineCitation>. if len(self._elements)>=2 and self._elements[-2] == "MedlineCitation": if self._elements[-1] == "PMID": self._pmid = content elif self._elements[-1] == "MedlineID": self._medline_id = content class _SavedDataHandle: def __init__(self, handle, saved): self.saved = saved self.handle = handle def read(self, length=None): if length is None: data = self.saved + self.handle.read() self.saved = '' else: data = self.saved[:length] data += self.handle.read(length-len(data)) self.saved = self.saved[length:] return data def index(handle, index_fn=None): """index(handle[, index_fn]) -> list of (PMID, MedlineID, start, end) Index a Medline XML file. Returns where the records are, as offsets from the beginning of the handle. index_fn is a callback function with parameters (PMID, MedlineID, start, end) and is called as soon as each record is indexes. """ # Find the correct format to parse the data. data = handle.read(1000) format_module = choose_format(data) handle = _SavedDataHandle(handle, data) format = format_module.format wanted = ["MedlineCitation", "PMID", "MedlineID"] format = Martel.select_names(format, wanted) # Create an indexer that will save all the index information and # call index_fn if appropriate. indexes = [] def citation_fn(pmid, medline_id, start, end, indexes=indexes, index_fn=index_fn): if index_fn is not None: index_fn(pmid, medline_id, start, end) indexes.append((pmid, medline_id, start, end)) indexer = _IndexerHandler(citation_fn) # Create the parser and parse the results. parser = format.make_parser(debug_level=0) parser.setContentHandler(indexer) parser.setErrorHandler(handler.ErrorHandler()) parser.parseFile(handle) return indexes def index_many(files_or_paths, index_fn, nprocs=1): """index_many(files_or_paths, index_fn[, nprocs]) Index multiple Medline XML files. files_or_paths can be a single file, a path, a list of files, or a list of paths. index_fn is a callback function that should take the following parameters: index_fn(file, event, data) where file is the file being indexed, event is one of "START", "RECORD", "END", and data is extra data dependent upon the event. "START" and "END" events are passed to indicate when a file is being indexed. "RECORD" is passed whenever a new record has been indexed. When a "RECORD" event is passed, then data is set to a tuple of (pmid, medline_id, start, end). Otherwise it is None. start and end indicate the location of the record as offsets from the beginning of the file. """ # This isn't a very good solution because it only allows 2 types # of sequences. It's possible to use operator.isSequenceType, but # then we have to figure out how to exclude String types. if type(files_or_paths) not in [types.ListType, types.TupleType]: files_or_paths = [files_or_paths] files = [] for f in files_or_paths: if os.path.isfile(f): files.append(f) elif os.path.isdir(f): names = os.listdir(f) for name in names: files.append(os.path.join(f, name)) else: raise ValueError, "I can't find %s" % f def do_some(start, skip, files, index_fn): for i in range(start, len(files), skip): infile = files[i] index_fn(infile, "START", None) # index takes an optional index_fn with a different # interface than the callback for this function. Thus, I # have to make an adapter to change the interface to one # that my client expects. def index_fn_adapter(pmid, medline_id, start, end, infile=infile, index_fn=index_fn): index_fn(infile, "RECORD", (pmid, medline_id, start, end)) index(open(infile), index_fn_adapter) index_fn(infile, "END", None) MultiProc.run(nprocs, do_some, fn_args=(files, index_fn))
dbmi-pitt/DIKB-Micropublication
scripts/mp-scripts/Bio/Medline/NLMMedlineXML.py
Python
apache-2.0
9,614
[ "Biopython" ]
994b6600ad96fec619fa8359082ba1e0ed16cf5cf3f4ab56aef89a87aa6c724c
#!/usr/bin/env python import sys import os import cPickle as pickle import gzip import pysam def remove_rRNA(fileInNameBam, fileInNamePickle, fileOutName): if os.path.exists(fileOutName): print '%s already exists!' % fileOutName return if os.path.exists(fileInNamePickle): FileIn = gzip.GzipFile(fileInNamePickle, 'rb') readIDs = pickle.load(FileIn) FileIn.close() bamFile = pysam.Samfile(fileInNameBam, 'rb') FileOut = pysam.Samfile(fileOutName, 'wb', template=bamFile) for eachRead in bamFile: if not eachRead.qname in readIDs: FileOut.write(eachRead) FileOut.close() bamFile.close() print 'Remove rRNA, %s: Done.' % fileOutName else: print '%s does not exist!' % fileInNamePickle return if __name__ == '__main__': originalBAM = sys.argv[1] pickleFile = sys.argv[2] fileOutName = originalBAM.replace('.bam', '.NOrRNA.bam') remove_rRNA(originalBAM, pickleFile, fileOutName)
ratschlab/RiboDiff
tools/pipeline/filter_reads/filtering_RNA.py
Python
gpl-3.0
1,045
[ "pysam" ]
e8dca9f0f48485d92a37ef24b7d72fbfed964975e319395722edc5dc9f50b1c6
# coding: utf-8 from __future__ import division, unicode_literals """ Module which defines basic entries for each ion and oxide to compute a Pourbaix diagram """ __author__ = "Sai Jayaraman" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "0.0" __maintainer__ = "Sai Jayaraman" __email__ = "sjayaram@mit.edu" __status__ = "Development" __date__ = "December 10, 2012" import re import math import csv from six.moves import map, zip from monty.string import unicode2str from pymatgen.core.periodic_table import Element from pymatgen.core.structure import Composition from pymatgen.serializers.json_coders import PMGSONable from pymatgen.core.ion import Ion from pymatgen.phasediagram.entries import PDEntry PREFAC = 0.0591 class PourbaixEntry(PMGSONable): """ An object encompassing all data relevant to an ion in a pourbaix diagram. Each bulk solid/ion has a free energy g of the form: g = g0_ref + 0.0591 log10(conc) - nO mu_H2O + (nH - 2nO) pH + phi (-nH + 2nO + q) Args: entry (ComputedEntry/ComputedStructureEntry/PDEntry/IonEntry): An entry object energy: Energy of entry """ def __init__(self, entry, correction=0.0, entry_id=None): if isinstance(entry, IonEntry): self.entry = entry self.conc = 1.0e-6 self.phase_type = "Ion" self.charge = entry.composition.charge else: self.entry = entry self.conc = 1.0 self.phase_type = "Solid" self.charge = 0.0 self.uncorrected_energy = entry.energy self.correction = correction nH = 0 nO = 0 nM = 0 for elt in self.entry.composition.elements: if elt == Element("H"): nH = self.entry.composition[elt] elif elt == Element("O"): nO = self.entry.composition[elt] else: nM += self.entry.composition[elt] self.nM = nM self.npH = (nH - 2 * nO) self.nH2O = nO self.nPhi = (nH - 2 * nO - self.charge) self.name = self.entry.composition.reduced_formula if self.phase_type == "Solid": self.name += "(s)" try: self.entry_id = entry.entry_id except AttributeError: self.entry_id = entry_id @property def energy(self): return self.uncorrected_energy + self.correction @property def g0(self): """ Return g0 for the entry. Legacy function. """ return self.energy @property def conc_term(self): """ Returns the concentration contribution to the free energy. """ return self.normalization_factor * PREFAC * math.log10(self.conc) def g0_add(self, term): """ Add a correction term to g0. Args: term: Correction term to add to g0 """ self.correction += term def g0_replace(self, term): """ Replace g0 by a different value. Args: term: New value for g0 """ self.uncorrected_energy = term self.correction = 0.0 def as_dict(self): """ Returns dict which contains Pourbaix Entry data. Note that the pH, voltage, H2O factors are always calculated when constructing a PourbaixEntry object. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__} if isinstance(self.entry, IonEntry): d["entry type"] = "Ion" else: d["entry type"] = "Solid" d["entry"] = self.entry.as_dict() d["pH factor"] = self.npH d["voltage factor"] = self.nPhi d["concentration"] = self.conc d["H2O factor"] = self.nH2O d["energy"] = self.energy d["correction"] = self.correction d["entry_id"] = self.entry_id return d @classmethod def from_dict(cls, d): """ Returns a PourbaixEntry by reading in an Ion """ entry_type = d["entry type"] if entry_type == "Ion": entry = IonEntry.from_dict(d["entry"]) else: entry = PDEntry.from_dict(d["entry"]) correction = d["correction"] entry_id = d["entry_id"] return PourbaixEntry(entry, correction, entry_id) @property def normalization_factor(self): """ Normalize each entry by nM """ fact = 1.0 / self.nM return fact def scale(self, factor): """ Normalize all entries by normalization factor. Args: factor: Normalization factor """ self.npH *= factor self.nPhi *= factor self.nH2O *= factor self.uncorrected_energy *= factor self.correction *= factor def normalize(self, factor): self.scale(factor) @property def composition(self): """ Returns composition """ return self.entry.composition def reduced_entry(self): """ Calculate reduction factor for composition, and reduce parameters by this factor. """ reduction_factor = self.entry.composition.\ get_reduced_composition_and_factor()[1] self.nM /= reduction_factor self.scale(1.0 / reduction_factor) @property def num_atoms(self): """ Return number of atoms in current formula. Useful for normalization """ return self.entry.composition.num_atoms\ / self.entry.composition.get_reduced_composition_and_factor()[1] def __repr__(self): return "Pourbaix Entry : {} with energy = {:.4f}, npH = {}, nPhi = {},\ nH2O = {}".format(self.entry.composition, self.g0, self.npH, self.nPhi, self.nH2O) def __str__(self): return self.__repr__() class MultiEntry(PourbaixEntry): """ PourbaixEntry-like object for constructing multi-elemental Pourbaix diagrams. """ def __init__(self, entry_list, weights=None): """ Initializes a MultiEntry. Args: entry_list: List of component PourbaixEntries weights: Weights associated with each entry. Default is None """ if weights is None: self.weights = [1.0] * len(entry_list) else: self.weights = weights self.entrylist = entry_list self.correction = 0.0 self.uncorrected_energy = 0.0 self.npH = 0.0 self.nPhi = 0.0 self.nH2O = 0.0 self.nM = 0.0 self.name = "" self.entry_id = list() for w, e in zip(self.weights, entry_list): self.uncorrected_energy += w * \ e.uncorrected_energy self.correction += w * e.correction self.npH += w * e.npH self.nPhi += w * e.nPhi self.nH2O += w * e.nH2O self.nM += w * e.nM self.name += e.name + " + " self.entry_id.append(e.entry_id) self.name = self.name[:-3] @property def normalization_factor(self): """ Normalize each entry by nM """ norm_fac = 0.0 for w, e in zip(self.weights, self.entrylist): for el in e.composition.elements: if (el == Element("O")) | (el == Element("H")): continue if e.phase_type == 'Solid': red_fac = e.composition.\ get_reduced_composition_and_factor()[1] else: red_fac = 1.0 norm_fac += w * e.composition[el] / red_fac fact = 1.0 / norm_fac return fact def __repr__(self): str = "Multiple Pourbaix Entry : with energy = {:.4f}, npH = {}, "\ "nPhi = {}, nH2O = {}".format( self.g0, self.npH, self.nPhi, self.nH2O) str += ", species: " for entry in self.entrylist: str += entry.name + " + " return str[:-3] def __str__(self): return self.__repr__() @property def conc_term(self): sum_conc = 0.0 for w, e in zip(self.weights, self.entrylist): sum_conc += w * PREFAC * math.log10(e.conc) return sum_conc * self.normalization_factor class IonEntry(PDEntry): """ Object similar to PDEntry, but contains an Ion object instead of a Composition object. Args: comp: Ion object energy: Energy for composition. name: Optional parameter to name the entry. Defaults to the chemical formula. .. attribute:: name A name for the entry. This is the string shown in the phase diagrams. By default, this is the reduced formula for the composition, but can be set to some other string for display purposes. """ def __init__(self, ion, energy, name=None): self.energy = energy self.composition = ion self.name = name if name else self.composition.reduced_formula @classmethod def from_dict(cls, d): """ Returns an IonEntry object from a dict. """ return IonEntry(Ion.from_dict(d["composition"]), d["energy"]) def as_dict(self): """ Creates a dict of composition, energy, and ion name """ d = {"composition": self.composition.as_dict(), "energy": self.energy} return d @property def energy_per_atom(self): """ Return final energy per atom """ return self.energy / self.composition.num_atoms def __repr__(self): return "IonEntry : {} with energy = {:.4f}".format(self.composition, self.energy) def __str__(self): return self.__repr__() class PourbaixEntryIO(object): """ Class to import and export Pourbaix entries from a csv file """ @staticmethod def to_csv(filename, entries, latexify_names=False): """ Exports Pourbaix entries to a csv Args: filename: Filename to write to. entries: Entries to export. latexify_names: Format entry names to be LaTex compatible, e.g., Li_{2}O """ elements = set() #TODO: oh god please fix this next line list(map(elements.update, [entry.entry.composition.elements for entry in entries])) elements = sorted(list(elements), key=lambda a: a.X) with open(filename, "w") as f: writer = csv.writer(f, delimiter=unicode2str(","), quotechar=unicode2str("\""), quoting=csv.QUOTE_MINIMAL) writer.writerow(["Name"] + elements + ["Energy"] + ["Entry Type"] + ["Charge"] + ["Concentration"]) for entry in entries: row = [entry.name if not latexify_names else re.sub(r"([0-9]+)", r"_{\1}", entry.name)] if entry.phase_type == "Solid": reduction_fac = entry.entry.composition.\ get_reduced_composition_and_factor()[1] else: reduction_fac = 1.0 row.extend([entry.entry.composition[el] / reduction_fac for el in elements]) if entry.phase_type == "Solid": reduction_fac = 1.0 row.append(entry.g0 / reduction_fac) row.append(entry.phase_type) row.append(entry.charge / reduction_fac) row.append(entry.conc) writer.writerow(row) @staticmethod def from_csv(filename): """ Imports PourbaixEntries from a csv. Args: filename: Filename to import from. Returns: List of Entries """ with open(filename, "r") as f: reader = csv.reader(f, delimiter=unicode2str(","), quotechar=unicode2str("\""), quoting=csv.QUOTE_MINIMAL) entries = list() header_read = False for row in reader: if not header_read: elements = row[1:(len(row) - 4)] header_read = True else: name = row[0] energy = float(row[-4]) conc = float(row[-1]) comp = dict() for ind in range(1, len(row) - 4): if float(row[ind]) > 0: comp[Element(elements[ind - 1])] = float(row[ind]) phase_type = row[-3] if phase_type == "Ion": PoE = PourbaixEntry(IonEntry(Ion.from_formula(name), energy)) PoE.conc = conc PoE.name = name entries.append(PoE) else: entries.append(PourbaixEntry(PDEntry(Composition(comp), energy))) elements = [Element(el) for el in elements] return elements, entries def ion_or_solid_comp_object(formula): """ Returns either an ion object or composition object given a formula. Args: formula: String formula. Eg. of ion: NaOH(aq), Na[+]; Eg. of solid: Fe2O3(s), Fe(s), Na2O Returns: Composition/Ion object """ m = re.search(r"\[([^\[\]]+)\]|\(aq\)", formula) if m: comp_obj = Ion.from_formula(formula) elif re.search(r"\(s\)", formula): comp_obj = Composition(formula[:-3]) else: comp_obj = Composition(formula) return comp_obj
rousseab/pymatgen
pymatgen/analysis/pourbaix/entry.py
Python
mit
14,048
[ "pymatgen" ]
ef3710af96bb4f2bf287ebbe5c8b9f4ed958ab94a10ea86e4420f341b0f58d2b
#!/usr/bin/env python # GPL HEADER START # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 only, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License version 2 for more details (a copy is included # in the LICENSE file that accompanied this code). # # You should have received a copy of the GNU General Public License # version 2 along with this program; If not, see # http://www.sun.com/software/products/lustre/docs/GPLv2.pdf # copy of GPLv2]. # # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, # CA 95054 USA or visit www.sun.com if you need additional information or # have any questions. # # GPL HEADER END # # # Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. # Use is subject to license terms. # # # This file is part of Lustre, http://www.lustre.org/ # Lustre is a trademark of Sun Microsystems, Inc. # # Author: Robert Read <rread@clusterfs.com> # # Standard the comand line handling for all the python tools. import sys, getopt, types import string import error class Options: FLAG = 1 PARAM = 2 INTPARAM = 3 PARAMLIST = 4 def __init__(self, cmd, remain_help, options): self.options = options shorts = "" longs = [] options.append(('help,h', "Print this help")) for opt in options: long = self.long(opt) short = self.short(opt) if self.type(opt) in (Options.PARAM, Options.INTPARAM, Options.PARAMLIST): if short: short = short + ':' if long: long = long + '=' if string.find(long, '_') >= 0: longs.append(string.replace(long, '_', '-')) shorts = shorts + short longs.append(long) self.short_opts = shorts self.long_opts = longs self.cmd = cmd self.remain_help = remain_help def init_values(self): values = {} for opt in self.options: values[self.key(opt)] = self.default(opt) return values def long(self, option): n = string.find(option[0], ',') if n < 0: return option[0] else: return option[0][0:n] def key(self, option): key = self.long(option) return string.replace(key, '-', '_') def short(self, option): n = string.find(option[0], ',') if n < 0: return '' else: return option[0][n+1:] def help(self, option): return option[1] def type(self, option): if len(option) >= 3: return option[2] return Options.FLAG def default(self, option): if len(option) >= 4: return option[3] if self.type(option) == Options.PARAMLIST: return [] return None def lookup_option(self, key, key_func): for opt in self.options: if key_func(opt) == key: return opt def lookup_short(self, key): return self.lookup_option(key, self.short) def lookup_long(self, key): key = string.replace(key, '-', '_') return self.lookup_option(key, self.long) def handle_opts(self, opts): values = self.init_values() for o, a in opts: if o[0:2] != '--': option = self.lookup_short(o[1:]) else: option = self.lookup_long(o[2:]) if self.type(option) == Options.PARAM: val = a elif self.type(option) == Options.INTPARAM: try: val = int(a) except ValueError, e: raise error.OptionError("option: '%s' expects integer value, got '%s' " % (o,a)) elif self.type(option) == Options.PARAMLIST: val = values[self.key(option)]; val.append(a) else: val = 1 values[self.key(option)] = val return values class option_wrapper: def __init__(self, values): self.__dict__['values'] = values def __getattr__(self, name): if self.values.has_key(name): return self.values[name] else: raise error.OptionError("bad option name: " + name) def __getitem__(self, name): if self.values.has_key(name): return self.values[name] else: raise error.OptionError("bad option name: " + name) def __setattr__(self, name, value): self.values[name] = value def parse(self, argv): try: opts, args = getopt.getopt(argv, self.short_opts, self.long_opts) values = self.handle_opts(opts) if values["help"]: self.usage() sys.exit(0) return self.option_wrapper(values), args except getopt.error, e: raise error.OptionError(str(e)) def usage(self): ret = 'usage: %s [options] %s\n' % (self.cmd, self.remain_help) for opt in self.options: s = self.short(opt) if s: str = "-%s|--%s" % (s,self.long(opt)) else: str = "--%s" % (self.long(opt),) if self.type(opt) in (Options.PARAM, Options.INTPARAM): str = "%s <arg>" % (str,) help = self.help(opt) n = string.find(help, '\n') if self.default(opt) != None: if n < 0: str = "%-15s %s (default=%s)" %(str, help, self.default(opt)) else: str = "%-15s %s (default=%s)%s" %(str, help[0:n], self.default(opt), help[n:]) else: str = "%-15s %s" %(str, help) ret = ret + str + "\n" print ret # Test driver if __name__ == "__main__": cl = Options("test", "xml_file", [ ('verbose,v', "verbose ", Options.FLAG, 0), ('cleanup,d', "shutdown"), ('gdb', "Display gdb module file ", Options.FLAG, 0), ('device', "device path ", Options.PARAM), ('ldapurl', "LDAP server URL ", Options.PARAM), ('lustre', "Lustre source dir ", Options.PARAM), ('portals', "Portals source dir ", Options.PARAM), ('maxlevel', """Specify the maximum level Levels are aproximatly like: 70 - mountpoint, echo_client, osc, mdc, lov""", Options.INTPARAM, 100), ]) conf, args = cl.parse(sys.argv[1:]) for key in conf.values.keys(): print "%-10s = %s" % (key, conf.values[key])
chaos/lustre-kdmu
lustre/utils/Lustre/cmdline.py
Python
gpl-2.0
7,282
[ "VisIt" ]
5967a19601686be9da22051e48fbf1e66d6e728fbde819c6b833d07de3093137
import pytest import numpy as np import xarray as xr from glotaran import ParameterGroup from glotaran.builtin.models.doas import DOASModel from glotaran.builtin.models.doas.doas_matrix import calculate_doas_matrix class OneOscillation(): sim_model = DOASModel.from_dict({ 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': {'oscillation': ['osc1']} }, 'shape': { 'sh1': { 'type': "gaussian", 'amplitude': "shape.amps.1", 'location': "shape.locs.1", 'width': "shape.width.1", }, }, 'dataset': { 'dataset1': { 'megacomplex': ['m1'], 'shape': {'osc1': 'sh1'} } } }) model = DOASModel.from_dict({ 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': {'oscillation': ['osc1']} }, 'dataset': { 'dataset1': { 'megacomplex': ['m1'] } } }) wanted_parameter = ParameterGroup.from_dict({ 'osc': [ ['freq', 25.5], ['rate', 0.1], ], 'shape': {'amps': [7], 'locs': [5], 'width': [4]}, }) parameter = ParameterGroup.from_dict({ 'osc': [ ['freq', 20], ['rate', 0.3], ], }) time = np.arange(0, 3, 0.01) spectral = np.arange(0, 10) axis = {'time': time, 'spectral': spectral} wanted_clp = ['osc1_cos', 'osc1_sin'] wanted_shape = (300, 2) class OneOscillationWithIrf(): sim_model = DOASModel.from_dict({ 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': {'oscillation': ['osc1']} }, 'shape': { 'sh1': { 'type': "gaussian", 'amplitude': "shape.amps.1", 'location': "shape.locs.1", 'width': "shape.width.1", }, }, 'irf': { 'irf1': {'type': 'gaussian', 'center': ['irf.center'], 'width': ['irf.width']}, }, 'dataset': { 'dataset1': { 'megacomplex': ['m1'], 'shape': {'osc1': 'sh1'}, 'irf': 'irf1', } } }) model = DOASModel.from_dict({ 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': {'oscillation': ['osc1']} }, 'irf': { 'irf1': {'type': 'gaussian', 'center': ['irf.center'], 'width': ['irf.width']}, }, 'dataset': { 'dataset1': { 'megacomplex': ['m1'], 'irf': 'irf1', } } }) wanted_parameter = ParameterGroup.from_dict({ 'osc': [ ['freq', 25], ['rate', 0.1], ], 'shape': {'amps': [7], 'locs': [5], 'width': [4]}, 'irf': [['center', 0.3], ['width', 0.1]], }) parameter = ParameterGroup.from_dict({ 'osc': [ ['freq', 25], ['rate', 0.1], ], 'irf': [['center', 0.3], ['width', 0.1]], }) time = np.arange(0, 3, 0.01) spectral = np.arange(0, 10) axis = {'time': time, 'spectral': spectral} wanted_clp = ['osc1_cos', 'osc1_sin'] wanted_shape = (300, 2) class OneOscillationWithSequentialModel(): sim_model = DOASModel.from_dict({ 'initial_concentration': { 'j1': { 'compartments': ['s1', 's2'], 'parameters': ['j.1', 'j.0'] }, }, 'k_matrix': { "k1": {'matrix': { ("s2", "s1"): 'kinetic.1', ("s2", "s2"): 'kinetic.2', }} }, 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': { 'k_matrix': ['k1'], 'oscillation': ['osc1'], } }, 'shape': { 'sh1': { 'type': "gaussian", 'amplitude': "shape.amps.1", 'location': "shape.locs.1", 'width': "shape.width.1", }, 'sh2': { 'type': "gaussian", 'amplitude': "shape.amps.2", 'location': "shape.locs.2", 'width': "shape.width.2", }, 'sh3': { 'type': "gaussian", 'amplitude': "shape.amps.3", 'location': "shape.locs.3", 'width': "shape.width.3", }, }, 'irf': { 'irf1': {'type': 'gaussian', 'center': ['irf.center'], 'width': ['irf.width']}, }, 'dataset': { 'dataset1': { 'initial_concentration': 'j1', 'megacomplex': ['m1'], 'shape': { 'osc1': 'sh1', 's1': 'sh2', 's2': 'sh3', }, 'irf': 'irf1', } } }) model = DOASModel.from_dict({ 'initial_concentration': { 'j1': { 'compartments': ['s1', 's2'], 'parameters': ['j.1', 'j.0'] }, }, 'k_matrix': { "k1": {'matrix': { ("s2", "s1"): 'kinetic.1', ("s2", "s2"): 'kinetic.2', }} }, 'oscillation': { 'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'} }, 'megacomplex': { 'm1': { 'k_matrix': ['k1'], 'oscillation': ['osc1'], } }, 'irf': { 'irf1': {'type': 'gaussian', 'center': ['irf.center'], 'width': ['irf.width']}, }, 'dataset': { 'dataset1': { 'initial_concentration': 'j1', 'megacomplex': ['m1'], 'irf': 'irf1', } } }) wanted_parameter = ParameterGroup.from_dict({ 'j': [ ['1', 1, {'vary': False, 'non-negative': False}], ['0', 0, {'vary': False, 'non-negative': False}], ], 'kinetic': [ ["1", 0.2], ["2", 0.01], ], 'osc': [ ['freq', 25], ['rate', 0.1], ], 'shape': {'amps': [0.07, 2, 4], 'locs': [5, 2, 8], 'width': [4, 2, 3]}, 'irf': [['center', 0.3], ['width', 0.1]], }) parameter = ParameterGroup.from_dict({ 'j': [ ['1', 1, {'vary': False, 'non-negative': False}], ['0', 0, {'vary': False, 'non-negative': False}], ], 'kinetic': [ ["1", 0.2], ["2", 0.01], ], 'osc': [ ['freq', 25], ['rate', 0.1], ], 'irf': [['center', 0.3], ['width', 0.1]], }) time = np.arange(-1, 5, 0.01) spectral = np.arange(0, 10) axis = {'time': time, 'spectral': spectral} wanted_clp = ['osc1_cos', 'osc1_sin', 's1', 's2'] wanted_shape = (600, 4) @pytest.mark.parametrize("suite", [ OneOscillation, OneOscillationWithIrf, OneOscillationWithSequentialModel, ]) def test_doas_model(suite): print(suite.sim_model.validate()) assert suite.sim_model.valid() print(suite.model.validate()) assert suite.model.valid() print(suite.sim_model.validate(suite.wanted_parameter)) assert suite.sim_model.valid(suite.wanted_parameter) print(suite.model.validate(suite.parameter)) assert suite.model.valid(suite.parameter) dataset = suite.sim_model.dataset['dataset1'].fill(suite.sim_model, suite.wanted_parameter) data = xr.DataArray(suite.axis['time'], coords=[('time', suite.axis['time'])]) clp, matrix = calculate_doas_matrix(dataset, suite.axis['time'], 0) print(matrix.shape) assert matrix.shape == suite.wanted_shape print(clp) assert clp == suite.wanted_clp dataset = suite.sim_model.simulate('dataset1', suite.wanted_parameter, suite.axis) print(dataset) assert dataset.data.shape == \ (suite.axis['time'].size, suite.axis['spectral'].size) print(suite.parameter) print(suite.wanted_parameter) data = {'dataset1': dataset} result = suite.model.optimize(suite.parameter, data, max_nfev=50) print(result.optimized_parameter) for label, param in result.optimized_parameter.all(): assert np.allclose(param.value, suite.wanted_parameter.get(label).value, rtol=1e-1) resultdata = result.data["dataset1"] assert np.array_equal(dataset['time'], resultdata['time']) assert np.array_equal(dataset['spectral'], resultdata['spectral']) assert dataset.data.shape == resultdata.fitted_data.shape assert np.allclose(dataset.data, resultdata.fitted_data) assert 'dampened_oscillation_cos' in resultdata assert 'dampened_oscillation_sin' in resultdata assert 'dampened_oscillation_associated_spectra' in resultdata assert 'dampened_oscillation_phase' in resultdata
glotaran/glotaran
glotaran/builtin/models/doas/test/test_doas_model.py
Python
gpl-3.0
9,452
[ "Gaussian" ]
289edc53cfcee494c8036c85d0e2cf4aa7fcf08373636c1ac8428981ff934a17
## ## Biskit, a toolkit for the manipulation of macromolecular structures ## Copyright (C) 2004-2018 Raik Gruenberg & Johan Leckner ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 3 of the ## License, or any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You find a copy of the GNU General Public License in the file ## license.txt along with this program; if not, write to the Free ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## ## """ Read binary Amber trajectory files (NetCDF format) using parmed library. .. seealso:: `biskit.md.Trajectory`, `biskit.core.TrajParserFactory`, """ import logging import numpy as N from parmed.amber import NetCDFTraj import biskit as B import biskit.tools as T import biskit.core.trajparser as P from biskit.core.pdbparseFile import PDBParseFile from biskit.core.pdbparseModel import PDBParseModel class TrajParsePDBs(P.TrajParser): """ Generate ``Biskit.md.Trajectory` objects from list of PDB files. The parser attempts to correct for minor atom content missmatches. """ ## short free text description of the supported format description = 'PDB files with trajectory frames' @staticmethod def supports( source ): """ The method is static and can thus be called directly with the parser class rather than with an instance: >>> if TrajParser.supports(['frame_01.pdb', 'frame_02.pdb']): >>> ... The test is looking at the first 10 members of the given list and verifies that each of them can be parsed either as a PDB file or is already a PDBModel instance. Returns: bool: True if the given source is supported by this parser implementation """ ## source is iterable and not empty if not (hasattr(source, '__iter__') and len(source) > 0): return False ## test first 10 items in source only for f in source[:10]: if not (PDBParseFile.supports(f) or PDBParseModel.supports(f)): return False return True def parse2new( self, source, ref=None, traj=None ): """ Create / Replace Trajectory from the source list of PDBModels or PDBs. Args: source (str): list of file names or PDBModel instances ref (str or PDBModel): reference structure instance or file traj (Biskit.md.Trajectory): existing instance to be updated Returns: Biskit.Trajectory: new Trajectory instance """ r = traj if traj is None: import biskit.md r = biskit.md.Trajectory() r.setRef(B.PDBModel(ref or source[0])) n_frames = len(source) if self.rmwat: r.ref = r.ref.compress( N.logical_not(r.ref.maskSolvent()) ) r.resIndex = r.ref.resMap() refNames = r.ref.atomNames() ## cache for atom checking if self.verbose: T.errWrite('reading %i pdbs...' % n_frames ) r.frames = N.zeros((n_frames,r.ref.lenAtoms(),3)) ## target coordinate array r.frameNames = [ '#%i07' % i for i in range(n_frames) ] atomCast = None reportIntervall = 1 if n_frames < 100 else round(n_frames/100) for i, f in enumerate(source): m = B.PDBModel(f) ## compare atom order & content of first frame to reference pdb if self.analyzeEach or i==0: atomCast, castRef = m.compareAtoms( r.ref ) if castRef != list(range(r.ref.lenAtoms())): ## we can remove/reorder atoms from each frame but not from ref raise P.TrajParserError("Reference PDB doesn't match %s." %m.fileName) if N.all(atomCast == list(range( len( m ))) ): atomCast = None ## no casting necessary else: if self.verbose: T.errWrite(' casting ') ## assert that frame fits reference if atomCast: m = m.take( atomCast ) ## additional check on each 100st frame if i % reportIntervall == 0 and m.atomNames() != refNames: raise P.TrajParserError("%s doesn't match reference pdb."%m.fileName ) r.frames[i] = m.xyz if type(f) is str: ## save original file name r.frameNames[i] = T.stripFilename(f) if i % reportIntervall == 0 and self.verbose: T.errWrite('#') if self.verbose: T.errWrite( 'done\n' ) return r ############## # Empty test # ############## import biskit.test as BT class Test(BT.BiskitTest): def test_TrajParsePDBs(self): """TrajParsePDBs test""" import os f = T.testRoot('amber/md_pdbs/') allfiles = os.listdir( f ) pdbs = [] for fn in allfiles: try: if (fn[-4:].upper() == '.PDB'): pdbs += [f + fn] except: pass ref = pdbs[0] self.assertTrue( TrajParsePDBs.supports(pdbs)) p = TrajParsePDBs(verbose=self.local, rmwat=True, analyzeEach=False) t = p.parse2new(pdbs, ref=ref) self.assertEqual(t.lenAtoms(),876) self.assertEqual(len(t),10) self.assertEqual(t.frameNames, [T.stripFilename(f) for f in pdbs]) if __name__ == '__main__': BT.localTest()
graik/biskit
biskit/core/trajparsePDBs.py
Python
gpl-3.0
5,946
[ "Amber", "NetCDF" ]
e4973a415389e07c31f503f8a5907a3317222b3b06748fef5d29a0758abe1085
# Built-in modules # import subprocess, sys # Constants # module_names = { "biopython": "Bio", "ipython": "IPython", "scikit-learn": "sklearn", "scikit-bio": "skbio", "biom-formt": "biom", } ################################################################################ def check_setup_py(mod_name): """Parses the required modules from a setup.py file and checks they are importable (e.g. available in the PYTHONPATH)""" pass ################################################################################ def check_executable(tool_name): """Raises an warning if the executable *tool_name* is not found.""" result = subprocess.call(['which', tool_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result != 0: message = "The executable '%s' cannot be found in your $PATH" % tool_name raise Exception(message) ################################################################################ def check_module(mod_name): """Calls sys.exit() if the module *mod_name* is not found.""" # Special cases # if mod_name in module_name: mod_name = module_name[mod_name] # Use a try except block # try: __import__(mod_name) except ImportError as e: if str(e) != 'No module named %s' % mod_name: raise e print 'You do not seem to have the "%s" package properly installed.' \ ' Either you never installed it or your $PYTHONPATH is not set up correctly.' \ ' For more instructions see the README file. (%s)' % (mod_name, e) sys.exit()
DC23/plumbing
plumbing/dependencies.py
Python
mit
1,590
[ "Biopython", "scikit-bio" ]
25539f93a251f16087ddd5c5c9d6763ee10fe67f8cba96fb220379687915b6ff
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf import settings from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin from django.views.generic import TemplateView from django.views import defaults as default_views from django.views.decorators.csrf import csrf_exempt from base_station.races.schema import schema from graphene.contrib.django.views import GraphQLView urlpatterns = [ url(r'^$', TemplateView.as_view(template_name='root.html'), name="home"), # url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name="home"), url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name="about"), # Django Admin, use {% url 'admin:index' %} url(settings.ADMIN_URL, include(admin.site.urls)), # User management url(r'^users/', include("base_station.users.urls", namespace="users")), url(r'^accounts/', include('allauth.urls')), # API url(r'^api/', include("base_station.api.urls", namespace="api")), # Graphql urls url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema))), url(r'^graphiql', include('django_graphiql.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: # This allows the error pages to be debugged during development, just visit # these url in browser to see how these error pages look like. urlpatterns += [ url(r'^400/$', default_views.bad_request, kwargs={'exception': Exception("Bad Request!")}), url(r'^403/$', default_views.permission_denied, kwargs={'exception': Exception("Permissin Denied")}), url(r'^404/$', default_views.page_not_found, kwargs={'exception': Exception("Page not Found")}), url(r'^500/$', default_views.server_error), ]
RotorWidgets/base-station
config/urls.py
Python
gpl-3.0
1,848
[ "VisIt" ]
cee128320a6a8fba74a2d8e73cb19f4be4f8a41a860bd0ada0e9eaa61b21e9c0
from Bio import PDB, SeqIO, AlignIO,pairwise2 from Bio.Seq import Seq from Bio.SubsMat import MatrixInfo as matlist import os,sys,csv,cPickle import numpy as np import warnings warnings.filterwarnings("ignore") f = open('pdb_ids_all').read().splitlines() pdb_unique_ids = sorted(list(set(f))) file_pref = "../Data/" work_dir = "Folding" os.chdir(work_dir) matrix = matlist.blosum62 gap_open = -2 gap_extend = -0.5 count_less_2 = 0 resultFile_best = open("clusters_rmsd_gc.csv",'wb') #resultFile_best = open("clusters_rmsd_ample.csv",'wb') wr_best = csv.writer(resultFile_best, dialect='excel') pdb_seqlength = [] pdb_stats = [] for pdb_id in pdb_unique_ids: file_fasta = file_pref + pdb_id + ".fasta" file_pdb = file_pref + pdb_id + ".pdb" sequence_fasta = Seq("") num_monomers = 0 for seq_record in SeqIO.parse(file_fasta, "fasta"): sequence_fasta+=seq_record.seq num_monomers+=1 # uncomment the following line to produce gc_stats.pkl #pdb_seqlength.append((pdb_id,len(sequence_fasta)/num_monomers)) # i.e. all residues taken into account, not only ones seen in crystal # comment out calculation of the sequence from the pdb file ppb = PDB.PPBuilder() struct = PDB.PDBParser().get_structure(pdb_id, file_pdb) peptides = ppb.build_peptides(struct) sequence_pdb = Seq("") ref_residues = [] for peptide in peptides: sequence_pdb += peptide.get_sequence() for residue in peptide: ref_residues.append(residue) pdb_seqlength.append((pdb_id,len(ref_residues)/num_monomers)) alignment = pairwise2.align.globalds(sequence_fasta, sequence_pdb, matrix, gap_open, gap_extend, one_alignment_only=True)[0] ind_shift=len(str(alignment[1]))-len(str(alignment[1]).lstrip('-')) ind_first = ref_residues[0].get_id()[1] n_aligned = len(str(alignment[1])) res_ind = 0 seq_res_map = [] for i in range(n_aligned): if alignment[0][i] =='-': if alignment[1][i] !='-': res_ind += 1 continue if alignment[1][i] =='-': seq_res_map.append(-1) continue seq_res_map.append(res_ind) res_ind += 1 clusters_dir = pdb_id+"/results_clusters" #clusters_dir = pdb_id+"/ample/ROSETTA_MR_0/ensembles_1" if not os.path.exists(clusters_dir): continue cluster_files = os.listdir(clusters_dir) if not cluster_files: continue cluster_files.sort() rms_collection = [] cluster_stats = [] for cluster_file in cluster_files: cluster_fname = os.path.join(clusters_dir,cluster_file) structure=PDB.PDBParser().get_structure(cluster_file, cluster_fname) rms_cluster = [] res_ids_cluster = [] for model in structure.child_list: peptides_cl = ppb.build_peptides(model) peptides_model = [] for peptide in peptides_cl: peptides_model = peptides_model + peptide if len(peptides_model) < 18: continue aln_model = [] ref_model = [] res_ids_model = [] for residue in peptides_model: res_ind_model = residue.get_id()[1]-1 res_ind_ref = seq_res_map[res_ind_model] if res_ind_ref == -1: continue try: ref_model.append(ref_residues[res_ind_ref]['CA']) aln_model.append(residue['CA']) except: continue res_ids_model.append(residue.get_id()[1]) superimposer = PDB.Superimposer() try: superimposer.set_atoms(ref_model, aln_model) rms_cluster.append(superimposer.rms) except: continue res_ids_cluster.append(res_ids_model) if rms_cluster: rms_collection.append((pdb_id,cluster_file,len(peptides_model),len(aln_model),np.mean(rms_cluster))) cluster_stats.append((pdb_id,cluster_file,np.mean(rms_cluster),res_ids_cluster[0])) pdb_stats.append(cluster_stats) wr_best.writerows(rms_collection) resultFile_best.flush() resultFile_best.close() #cPickle.dump((pdb_stats,pdb_seqlength), open("ample_stats_existing.pkl", "wb")) cPickle.dump((pdb_stats,pdb_seqlength), open("gc_stats_existing.pkl", "wb"))
biocryst/gc
validation/clusters_rmsd.py
Python
mit
4,413
[ "CRYSTAL" ]
d3af20a921a40f968be9fce0c32923c1d063fc450f1c60cbdfac44eb2c4915c2
# Copyright 2018 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for the LaunchDescription class.""" import collections.abc import logging import os from launch import Action from launch import LaunchDescription from launch import LaunchDescriptionEntity from launch import LaunchDescriptionSource from launch.actions import DeclareLaunchArgument from launch.actions import IncludeLaunchDescription from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource logging.getLogger('launch').setLevel(logging.DEBUG) def test_launch_description_constructors(): """Test the constructors for LaunchDescription class.""" LaunchDescription() LaunchDescription(None) LaunchDescription([]) ld = LaunchDescription([LaunchDescriptionEntity()]) assert len(ld.entities) == 1 def test_launch_description_get_launch_arguments(): """Test the get_launch_arguments() method of the LaunchDescription class.""" ld = LaunchDescription([]) assert len(ld.get_launch_arguments()) == 0 ld = LaunchDescription([DeclareLaunchArgument('foo')]) la = ld.get_launch_arguments() assert len(la) == 1 assert la[0]._conditionally_included is False ld = LaunchDescription([DeclareLaunchArgument('foo', condition=IfCondition('True'))]) la = ld.get_launch_arguments() assert len(la) == 1 assert la[0]._conditionally_included is True ld = LaunchDescription([ IncludeLaunchDescription(LaunchDescriptionSource(LaunchDescription([ DeclareLaunchArgument('foo'), ]))), ]) la = ld.get_launch_arguments() assert len(la) == 1 this_dir = os.path.dirname(os.path.abspath(__file__)) ld = LaunchDescription([ IncludeLaunchDescription(PythonLaunchDescriptionSource( os.path.join(this_dir, 'launch_file_with_argument.launch.py'))), ]) la = ld.get_launch_arguments() assert len(la) == 1 # From issue #144: get_launch_arguments was broken when an entitity had conditional # sub entities class EntityWithConditional(LaunchDescriptionEntity): def describe_conditional_sub_entities(self): return [('String describing condition', [DeclareLaunchArgument('foo')])] ld = LaunchDescription([ EntityWithConditional() ]) la = ld.get_launch_arguments() assert len(la) == 1 def test_launch_description_add_things(): """Test adding things to the LaunchDescription class.""" ld = LaunchDescription() assert len(ld.entities) == 0 ld.add_entity(LaunchDescription()) assert len(ld.entities) == 1 ld.add_action(Action()) assert len(ld.entities) == 2 class MockLaunchContext: def get_locals_as_dict(self): return {} def test_launch_description_visit(): """Test visiting entities in the LaunchDescription class.""" ld = LaunchDescription([LaunchDescriptionEntity()]) ld.add_action(Action()) result = ld.visit(MockLaunchContext()) assert isinstance(result, collections.abc.Iterable) for entity in result: assert isinstance(entity, LaunchDescriptionEntity) def test_launch_description_deprecated(): ld = LaunchDescription(deprecated_reason='DEPRECATED MESSAGE') ld.visit(MockLaunchContext()) assert ld.deprecated is True assert ld.deprecated_reason == 'DEPRECATED MESSAGE'
ros2/launch
launch/test/launch/test_launch_description.py
Python
apache-2.0
3,917
[ "VisIt" ]
bf7457ce9421efd6799c24564672143a80e26ef571dad1406f5af4b276a36bdf
#!/usr/bin/env python ######################################################################## # File : dirac-dms-replicate-lfn # Author : Stuart Paterson ######################################################################## """ Replicate an existing LFN to another Storage Element Example: $ dirac-dms-replicate-lfn /formation/user/v/vhamar/Test.txt DIRAC-USER {'Failed': {}, 'Successful': {'/formation/user/v/vhamar/Test.txt': {'register': 0.50833415985107422, 'replicate': 11.878520965576172}}} """ import DIRAC from DIRAC.Core.Base.Script import Script @Script() def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("LFN: Logical File Name or file containing LFNs") Script.registerArgument("Dest: Valid DIRAC SE") Script.registerArgument("Source: Valid DIRAC SE", default="", mandatory=False) Script.registerArgument("Cache: Local directory to be used as cache", default="", mandatory=False) _, args = Script.parseCommandLine(ignoreErrors=True) if len(args) > 4: Script.showHelp(exitCode=1) lfn, seName, sourceSE, localCache = Script.getPositionalArgs(group=True) from DIRAC.Interfaces.API.Dirac import Dirac dirac = Dirac() exitCode = 0 try: f = open(lfn, "r") lfns = f.read().splitlines() f.close() except Exception: lfns = [lfn] finalResult = {"Failed": [], "Successful": []} for lfn in lfns: result = dirac.replicateFile(lfn, seName, sourceSE, localCache, printOutput=True) if not result["OK"]: finalResult["Failed"].append(lfn) print("ERROR %s" % (result["Message"])) exitCode = 2 else: finalResult["Successful"].append(lfn) if len(lfns) > 1: print(finalResult) DIRAC.exit(exitCode) if __name__ == "__main__": main()
DIRACGrid/DIRAC
src/DIRAC/Interfaces/scripts/dirac_dms_replicate_lfn.py
Python
gpl-3.0
1,980
[ "DIRAC" ]
79945027e26eb907630863434a36b3f32cfe6ed892ff10c2011eb7eb894e32ed
from datetime import datetime import warnings import numpy as np import pandas as pd from pandas import DataFrame import matplotlib.pyplot as plt from statsmodels.stats.diagnostic import acorr_ljungbox from statsmodels.tsa.stattools import adfuller as ADF from statsmodels.graphics.tsaplots import plot_acf, plot_pacf import talib from vnpy.trader.constant import Exchange, Interval from vnpy.trader.database import database_manager warnings.filterwarnings("ignore") class DataAnalysis: def __init__(self): """""" self.symbol = "" self.exchange = None self.interval = None self.start = None self.end = None self.rate = 0.0 self.window_volatility = 20 self.window_index = 20 self.orignal = pd.DataFrame() self.index_1to1 = [] self.index_2to2 = [] self.index_3to1 = [] self.index_2to1 = [] self.index_4to1 = [] self.intervals = [] self.results = {} def load_history( self, symbol: str, exchange: Exchange, interval: Interval, start: datetime, end: datetime, rate: float = 0.0, index_1to1: list = None, index_2to2: list = None, index_3to1: list = None, index_2to1: list = None, index_4to1: list = None, window_index: int = 20, window_volatility: int = 20, ): """""" output("开始加载历史数据") self.window_volatility = window_volatility self.window_index = window_index self.rate = rate self.index_1to1 = index_1to1 self.index_2to2 = index_2to2 self.index_3to1 = index_3to1 self.index_2to1 = index_2to1 self.index_4to1 = index_4to1 # Load history data from database bars = database_manager.load_bar_data( symbol=symbol, exchange=exchange, interval=interval, start=start, end=end, ) output(f"历史数据加载完成,数据量:{len(bars)}") # Generate history data in DataFrame t = [] o = [] h = [] l = [] # noqa c = [] v = [] for bar in bars: time = bar.datetime open_price = bar.open_price high_price = bar.high_price low_price = bar.low_price close_price = bar.close_price volume = bar.volume t.append(time) o.append(open_price) h.append(high_price) l.append(low_price) c.append(close_price) v.append(volume) self.orignal["open"] = o self.orignal["high"] = h self.orignal["low"] = l self.orignal["close"] = c self.orignal["volume"] = v self.orignal.index = t def base_analysis(self, df: DataFrame = None): """""" if df is None: df = self.orignal if df is None: output("数据为空,请输入数据") close_price = df["close"] output("第一步:画出行情图,检查数据断点") close_price.plot(figsize=(20, 8), title="close_price") plt.show() random_test(close_price) stability_test(close_price) autocorrelation_test(close_price) self.relative_volatility_analysis(df) self.growth_analysis(df) self.calculate_index(df) return df def relative_volatility_analysis(self, df: DataFrame = None): """ 相对波动率 """ output("第五步:相对波动率分析") df["volatility"] = talib.ATR( np.array(df["high"]), np.array(df["low"]), np.array(df["close"]), self.window_volatility ) df["fixed_cost"] = df["close"] * self.rate df["relative_vol"] = df["volatility"] - df["fixed_cost"] df["relative_vol"].plot(figsize=(20, 6), title="relative volatility") plt.show() df["relative_vol"].hist(bins=200, figsize=(20, 6), grid=False) plt.show() statitstic_info(df["relative_vol"]) def growth_analysis(self, df: DataFrame = None): """ 百分比K线变化率 """ output("第六步:变化率分析") df["pre_close"] = df["close"].shift(1).fillna(0) df["g%"] = 100 * (df["close"] - df["pre_close"]) / df["close"] df["g%"].plot(figsize=(20, 6), title="growth", ylim=(-5, 5)) plt.show() df["g%"].hist(bins=200, figsize=(20, 6), grid=False) plt.show() statitstic_info(df["g%"]) def calculate_index(self, df: DataFrame = None): """""" output("第七步:计算相关技术指标,返回DataFrame\n") if self.index_1to1: for i in self.index_1to1: func = getattr(talib, i) df[i] = func( np.array(df["close"]), self.window_index ) if self.index_3to1: for i in self.index_3to1: func = getattr(talib, i) df[i] = func( np.array(df["high"]), np.array(df["low"]), np.array(df["close"]), self.window_index ) if self.index_2to2: for i in self.index_2to2: func = getattr(talib, i) result_down, result_up = func( np.array(df["high"]), np.array(df["low"]), self.window_index ) up = i + "_UP" down = i + "_DOWN" df[up] = result_up df[down] = result_down if self.index_2to1: for i in self.index_2to1: func = getattr(talib, i) df[i] = func( np.array(df["high"]), np.array(df["low"]), self.window_index ) if self.index_4to1: for i in self.index_4to1: func = getattr(talib, i) df[i] = func( np.array(df["open"]), np.array(df["high"]), np.array(df["low"]), np.array(df["close"]), ) return df def multi_time_frame_analysis(self, intervals: list = None, df: DataFrame = None): """""" if not intervals: output("请输入K线合成周期") return if df is None: df = self.orignal if df is None: output("请先加载数据") return for interval in intervals: output("------------------------------------------------") output(f"合成{interval}周期K先并开始数据分析") data = pd.DataFrame() data["open"] = df["open"].resample(interval, how="first") data["high"] = df["high"].resample(interval, how="max") data["low"] = df["low"].resample(interval, how="min") data["close"] = df["close"].resample(interval, how="last") data["volume"] = df["volume"].resample(interval, how="sum") result = self.base_analysis(data) self.results[interval] = result def show_chart(self, data, boll_wide): """""" data["boll_up"] = data["SMA"] + data["STDDEV"] * boll_wide data["boll_down"] = data["SMA"] - data["STDDEV"] * boll_wide up_signal = [] down_signal = [] len_data = len(data["close"]) for i in range(1, len_data): if data.iloc[i]["close"] > data.iloc[i]["boll_up"]and data.iloc[i - 1]["close"] < data.iloc[i - 1]["boll_up"]: up_signal.append(i) elif data.iloc[i]["close"] < data.iloc[i]["boll_down"] and data.iloc[i - 1]["close"] > data.iloc[i - 1]["boll_down"]: down_signal.append(i) plt.figure(figsize=(20, 8)) close = data["close"] plt.plot(close, lw=1) plt.plot(close, '^', markersize=5, color='r', label='UP signal', markevery=up_signal) plt.plot(close, 'v', markersize=5, color='g', label='DOWN signal', markevery=down_signal) plt.plot(data["boll_up"], lw=0.5, color="r") plt.plot(data["boll_down"], lw=0.5, color="g") plt.legend() plt.show() data["ATR"].plot(figsize=(20, 3), title="ATR") plt.show() def random_test(close_price): """""" acorr_result = acorr_ljungbox(close_price, lags=1) p_value = acorr_result[1] if p_value < 0.05: output("第二步:随机性检验:非纯随机性") else: output("第二步:随机性检验:纯随机性") output(f"白噪声检验结果:{acorr_result}\n") def stability_test(close_price): """""" statitstic = ADF(close_price) t_s = statitstic[1] t_c = statitstic[4]["10%"] if t_s > t_c: output("第三步:平稳性检验:存在单位根,时间序列不平稳") else: output("第三步:平稳性检验:不存在单位根,时间序列平稳") output(f"ADF检验结果:{statitstic}\n") def autocorrelation_test(close_price): """""" output("第四步:画出自相关性图,观察自相关特性") plot_acf(close_price, lags=60) plt.show() plot_pacf(close_price, lags=60).show() plt.show() def statitstic_info(df): """""" mean = round(df.mean(), 4) median = round(df.median(), 4) output(f"样本平均数:{mean}, 中位数: {median}") skew = round(df.skew(), 4) kurt = round(df.kurt(), 4) if skew == 0: skew_attribute = "对称分布" elif skew > 0: skew_attribute = "分布偏左" else: skew_attribute = "分布偏右" if kurt == 0: kurt_attribute = "正态分布" elif kurt > 0: kurt_attribute = "分布陡峭" else: kurt_attribute = "分布平缓" output(f"偏度为:{skew},属于{skew_attribute};峰度为:{kurt},属于{kurt_attribute}\n") def output(msg): """ Output message of backtesting engine. """ print(f"{datetime.now()}\t{msg}")
bigdig/vnpy
examples/data_analysis/data_analysis.py
Python
mit
10,377
[ "ADF" ]
9b0647fe7ad64019d5b677093721bd082c8bc1c7c15a3bdf9164a0d7da77ebd6
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. # ---------------------------------------------------------------------------- from unittest import TestCase, main import numpy as np import numpy.testing as npt from skbio.diversity.alpha import gini_index from skbio.diversity.alpha._gini import ( _lorenz_curve, _lorenz_curve_integrator) class GiniTests(TestCase): def setUp(self): self.data = np.array([4.5, 6.7, 3.4, 15., 18., 3.5, 6.7, 14.1]) self.lorenz_curve_points = ( np.array([0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0]), np.array([0.047287899860917935, 0.095966620305980521, 0.15855354659248957, 0.2517385257301808, 0.34492350486787204, 0.541029207232267, 0.74965229485396379, 1.0])) def test_gini_index(self): exp = 0.32771210013908214 obs = gini_index(self.data, 'trapezoids') self.assertAlmostEqual(obs, exp) exp = 0.20271210013908214 obs = gini_index(self.data, 'rectangles') self.assertAlmostEqual(obs, exp) # Raises error on negative data. with self.assertRaises(ValueError): gini_index([1.0, -3.1, 4.5]) def test_lorenz_curve(self): npt.assert_array_almost_equal(_lorenz_curve(self.data), self.lorenz_curve_points) def test_lorenz_curve_integrator(self): exp = 0.33614394993045893 obs = _lorenz_curve_integrator(self.lorenz_curve_points, 'trapezoids') self.assertAlmostEqual(obs, exp) exp = 0.39864394993045893 obs = _lorenz_curve_integrator(self.lorenz_curve_points, 'rectangles') self.assertAlmostEqual(obs, exp) # Raises error on invalid method. with self.assertRaises(ValueError): _lorenz_curve_integrator(self.lorenz_curve_points, 'brofist') if __name__ == '__main__': main()
anderspitman/scikit-bio
skbio/diversity/alpha/tests/test_gini.py
Python
bsd-3-clause
2,172
[ "scikit-bio" ]
0edc1a4e6d43266a00c48a402581b0ce61b0bbed7f17ba59ca2842a63d0f3fff
from nose.tools import eq_, ok_, raises import pods import os import re import sys if sys.version_info >= (3, 0): from urllib.error import HTTPError, URLError else: from urllib2 import URLError as HTTPError from urllib2 import URLError # details of a test page test_url = "http://www.bbc.co.uk/" store_directory = "tmp" save_name = "bbc_website.html" title = "<title data-rh=\"true\">BBC - Home</title>" # details of a non existent page fake_url = "http://pandemonium.sinclair.spectrum.absolute.blast.google.gobsmackazedare.co.uk/index.html" bogus_file = "http://www.bbc.co.uk/bogus_file.html" def test_downloard_url(): """util_tests: Test downloading of a URL.""" pods.util.download_url( test_url, save_name=save_name, store_directory=store_directory ) filename = os.path.join(store_directory, save_name) ok_(os.path.isfile(filename), "File does not exist in suggested location.") file = open(filename, "r") found_title = False for line in file: if re.search(title, line): found_title = True ok_( found_title, "Could not find " + title + " in " + filename + " downloaded from " + test_url, ) @raises(URLError, ValueError) def test_graceful_failure_fake_url(): """util_tests: Test graceful failure of a fake url.""" pods.util.download_url(fake_url) @raises(HTTPError, ValueError) def test_graceful_failure_bogus_file(): """util_tests: Test graceful failure of a bogus file.""" pods.util.download_url(bogus_file) import filecmp import unittest class UtilTests(unittest.TestCase): def test_download_url(self): """util_tests: Test the download url""" filename = "util.py" download_name = "tmp.py" # Download the file to current directory pods.util.download_url( "https://raw.githubusercontent.com/sods/ods/master/pods/" + filename, dir_name=".", save_name=download_name, ) # Get path of original module path = os.path.dirname(pods.__file__) # Compare files self.assertTrue(filecmp.cmp(os.path.join(path, filename), download_name))
sods/ods
pods/testing/util_tests.py
Python
bsd-3-clause
2,178
[ "BLAST" ]
42a00f201d6ac8b90454d04a89d2743fb4568ac491321f2d83570672db71a964
############################### # This file is part of PyLaDa. # # Copyright (C) 2013 National Renewable Energy Lab # # PyLaDa is a high throughput computational platform for Physics. It aims to make it easier to submit # large numbers of jobs on supercomputers. It provides a python interface to physical input, such as # crystal structures, as well as to a number of DFT (VASP, CRYSTAL) and atomic potential programs. It # is able to organise and launch computational jobs on PBS and SLURM. # # PyLaDa is free software: you can redistribute it and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation, either version 3 of the License, or (at # your option) any later version. # # PyLaDa is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along with PyLaDa. If not, see # <http://www.gnu.org/licenses/>. ############################### def get_result_size(sys_input, run_input): f0 = run_input.scale_eigenvalues f1 = run_input.scale_partial_charges f2 = run_input.scale_occupations f3 = run_input.scale_pressure size = 0 if f0 > 1e-12: size += len(run_input.k_idx) * len(sys_input.nlep_band_idx) if f1 > 1e-12: size += len(run_input.pc_orbital_idx) * len(sys_input.vasp.species) if f2 > 1e-12: size += len(run_input.k_idx) * len(sys_input.nlep_band_idx) if f3 > 1e-12: size += 1 return size def test_objective(args, sys_input): # eigs, pc, pressure, occs = test_objective(args, sys_input) print("test_objective called: ", args) # eigs = (1.0 + args[0]) * sys_input.gw_in.qp_eigenvalues eigs = sys_input.gw_in.qp_eigenvalues pc = sys_input.dft_in.partial_charges pressure = 0 occs = sys_input.gw_in.occupations return eigs, pc, pressure, occs def wprint(*args): from boost.mpi import world s = "rank " + str(world.rank) for a in args: s = s + " " + str(a) print(s) def array_function_calcs(x, raweigs, rawpc, pressure, rawoccs, sys_input, run_input, special_pc=None, ignore_weights=False): from boost.mpi import world import numpy as np import math from quantities import eV if special_pc != None: wprint("using pc overrides") sys_input_pc = special_pc else: sys_input_pc = sys_input.dft_in.partial_charges k_idx = run_input.k_idx nlep_band_idx = sys_input.nlep_band_idx gw_band_idx = sys_input.gw_band_idx target_eigs = [sys_input.gw_in.qp_eigenvalues[k_idx[j]][gw_band_idx[i]] for j in range(0, len(k_idx)) for i in range(0, len(gw_band_idx))] target_eigs = np.array([v.rescale(eV) for v in target_eigs]) eigs = np.array([raweigs[k_idx[j]][nlep_band_idx[i]] for j in range(0, len(k_idx)) for i in range(0, len(nlep_band_idx))]) pc = np.array([rawpc[sys_input.atom_idx[i]][run_input.pc_orbital_idx[k]] for i in range( 0, len(sys_input.vasp.species)) for k in range(0, len(run_input.pc_orbital_idx))]) target_pc = np.array([sys_input_pc[i][run_input.pc_orbital_idx[k]] for i in range( 0, len(sys_input.vasp.species)) for k in range(0, len(run_input.pc_orbital_idx))]) if (not run_input.floating_vbm): band_shift = raweigs[run_input.gamma_point_idx][sys_input.nlep_valence_band_idx] - \ sys_input.gw_in.qp_eigenvalues[run_input.gamma_point_idx][sys_input.gw_valence_band_idx] band_shift = float(band_shift.rescale(eV)) else: eigdelta = (eigs - target_eigs) if (ignore_weights): band_shift = sum(eigdelta) / float(len(eigdelta)) else: eigdelta = eigdelta * sys_input.eigenvalue_weights.flat normalizer = float(sum(sys_input.eigenvalue_weights.flat)) band_shift = sum(eigdelta) / normalizer # if (sys_input.cation == "Mg"): # print "total Mg hack!" # target_pc[1] -= 6. target_occs = [sys_input.gw_in.occupations[k_idx[j]][gw_band_idx[i]] for j in range(0, len(k_idx)) for i in range(0, len(gw_band_idx))] target_occs = np.array([v.rescale(eV) for v in target_occs]) occs = np.array([rawoccs[k_idx[j]][nlep_band_idx[i]] for j in range(0, len(k_idx)) for i in range(0, len(nlep_band_idx))]) wprint("eigs = ", eigs) wprint("target_eigs = ", target_eigs) wprint("pc = ", pc) wprint("target_pc = ", target_pc) wprint("pressure ", pressure) wprint("occs = ", occs) wprint("target_occs", target_occs) wprint("band_shift = ", band_shift, run_input.floating_vbm) wprint("eigenvalue weights = ", sys_input.eigenvalue_weights) eigs = (eigs - target_eigs) - band_shift if (not ignore_weights): eigs = eigs * sys_input.eigenvalue_weights.flat pc = (pc - target_pc) if (not ignore_weights): pc = pc * sys_input.pc_orbital_weights.flat occs = (occs - target_occs) # note, no bounds checking; we already checked if (ignore_weights): f0 = 1.0 f1 = 1.0 f2 = 0.0 f3 = 1.0 wprint("WARNING: array function calcs ignoring weights") else: f0 = run_input.scale_eigenvalues f1 = run_input.scale_partial_charges f2 = run_input.scale_occupations if (sys_input.scale_pressure == None): f3 = run_input.scale_pressure else: f3 = sys_input.scale_pressure # Note, we need to have at least nparam criteria to use MINPACK, # which is what leastsq is using]: wprint("pressure scaled by ", f3) size = get_result_size(sys_input, run_input) result = np.zeros((size,), dtype="float64") index = 0 if f0 > 1e-12: result[index:len(eigs)] = (eigs * f0).flat index += len(eigs) if f1 > 1e-12: # result[index:pc.size+index] = (pc / math.sqrt(float(pc.size)) * f1).flat # # why sqrt?? result[index:pc.size + index] = (pc * f1).flat index += pc.size if f2 > 1e-12: result[index:occs.size + index] = (occs * f2).flat index += occs.size if f3 > 1e-12: result[index] = pressure * f3 # NOTE: normalization by, e.g. how many eigenvalues are of interest not # longer in code. just relying on hand-specified weights from Stephan L. return result def check_bounds(args, sys_input, run_input, x0=None, ranges=None): # keep parameters within bounds through a quadratic penalty term from boost.mpi import world import numpy as np if (ranges == None): ranges = [sys_input.bounds[1] for i in range(0, len(args))] if (x0 == None): x0 = args bounds = [x0 - ranges, x0 + ranges] wprint("in check_bounds: ranges ", ranges, " bounds ", bounds, " sys_input.bounds ", sys_input.bounds) if (run_input.bounds_penalty > 0): penalty = 0 for i in range(0, len(args)): a = args[i] if (a < bounds[0][i]): pterm = run_input.bounds_penalty * ((a - bounds[0][i])**2) wprint("rank %d, arg %d, penalizing %e by %e" % (world.rank, i, a, pterm)) penalty += pterm if (a > bounds[1][i]): pterm = run_input.bounds_penalty * ((a - bounds[1][i])**2) wprint("rank %d, arg %d, penalizing %e by %e" % (world.rank, i, a, pterm)) penalty += pterm # MINPACK wants the actual array of errors. How to distribute the penalty? # just add to all errors: if (penalty > 1): # note this allows small violations, but this way these get evaluated and smoothly pushed back # Candidates that fall into penalty <= 1 will be evaluated by VASP # if we use "penalty < 0" system finds (false) optima just over boundary size = get_result_size(sys_input, run_input) result = np.zeros((size,), dtype="float64") for i in range(0, len(result)): result[i] = penalty return result else: return None # bounds ok def report_result(args, result, msg, evals_file): from boost.mpi import world import math s = "rank %d calculating fit to data at x= " % (world.rank) for a in args: s += "%.12e " % a print(s) evals_file.write("%s\n" % s) evals_file.flush() s = "rank %d returning from array_function:" % (world.rank) sum = 0 for r in result: s += " %e " % r sum += r * r s += " %e %e" % (sum, math.sqrt(sum)) print(s) evals_file.write("%s\n" % s) evals_file.flush() def report_bad_result(args, result, evals_file): from boost.mpi import world import math s = "rank %d out of bounds at x = " % (world.rank) for a in args: s += "%.12e " % a print(s) evals_file.write("%s\n" % s) evals_file.flush() s = "rank %d out of bounds returned :" % (world.rank) sum = 0 for r in result: s += " %e " % r sum += r * r s += " %e %e" % (sum, math.sqrt(sum)) print(s) evals_file.write("%s\n" % s) evals_file.flush() def simple_printout(eigs, pc, pressure, occs): import numpy as np dims = np.shape(eigs) print("---------------------------------------") print("eigs = [%d X %d]" % (dims[0], dims[1])) for i in range(0, dims[0]): s = "" for j in range(0, dims[1]): s += "%f " % eigs[i][j] print(s) print("pc = ", pc) print("occs = ", occs) print("pressure = ", pressure) print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") def create_sys_dirs(systems, run_control): from os import path import os # if (len(systems.systems) > 1): # run dir for every system for s in systems.systems: sysdir = path.join(run_control.outdir, "%s" % (s.name)) if (not path.isdir(sysdir)): os.mkdir(sysdir) def create_directories(run_control, systems, job_comm, mycolor): from boost.mpi import world import os from os import path basedir = run_control.outdir # world rank 0 creates ALL the directories, no conflict if (world.rank == 0): # creates path where VASP runs are stored. if (not path.isdir(basedir)): os.mkdir(basedir) # if run_control.nbjobs > 1: for color in range(0, run_control.nbjobs): jobdir = path.join(basedir, "job%i" % (color)) run_control.outdir = jobdir if (not path.isdir(jobdir)): os.mkdir(jobdir) # further extension for ranks within a job if (job_comm.size > 1): for rank in range(0, job_comm.size): rankdir = path.join(jobdir, "rank%i" % (rank)) if (not path.isdir(rankdir)): os.mkdir(rankdir) run_control.outdir = rankdir create_sys_dirs(systems, run_control) else: create_sys_dirs(systems, run_control) # else: # create_sys_dirs(systems, run_control) # but each rank will USE certain directories run_control.outdir = basedir jobdir = basedir # if run_control.nbjobs > 1: run_control.outdir = path.join(run_control.outdir, "job%i" % (mycolor)) jobdir = basedir # further extension for ranks within a job if (job_comm.size > 1): run_control.outdir = path.join(run_control.outdir, "rank%i" % (job_comm.rank)) # and for different systems # if (len(systems.systems) > 1): for s in systems.systems: s.outdir = path.join(run_control.outdir, "%s" % (s.name)) class RunControl(): def __init__(self, run_input): self.outdir = run_input.outdir self.nbjobs = run_input.nbjobs self.optimizer = run_input.optimizer def job_main(job_comm, run_input, systems, vasp_comm): import random import numpy as np from scipy.optimize import leastsq, fmin as simplex from boost.mpi import world, broadcast use_test_objective = False ############ we are using some local functions, b/c they share data with t def array_function(args, objective, sys_input, special_pc, evals_file): """ Returns an array that is (weighted) term by term fit to data. out of bounds arguments trigger penalty, avoids call to VASP""" # result = check_bounds(args, sys_input, run_input, x0, ranges) # WARNING: this function now assumes that bounds have already been checked, # ie, that it is only called from array_function_multi if (not use_test_objective): eigs, pc, pressure, occs = objective(args) else: # the test objective is lame, just to see if code runs, not whether # optimizer really works eigs, pc, pressure, occs = test_objective(args, sys_input) result = array_function_calcs(args, eigs, pc, pressure, occs, sys_input, run_input, special_pc, ignore_weights=False) report_result(args, result, "compound ", evals_file) return result def array_function_multi(args): # first check for bounds problems, ob = False for s in systems.systems: x = systems.mapx_to_system(args, s) sub_ranges = systems.mapx_to_system(ranges, s) sub_x0 = systems.mapx_to_system(x0, s) result = check_bounds(x, s.input, run_input, sub_x0, sub_ranges) if (result != None): report_bad_result(x, result, s.evals_file) ob = True # now result has penalized result for one system. but that's not the right size # for returning. just duplicate that badness til it's right length sz = systems.get_result_size(run_input) res = [result[0] for i in range(0, sz)] if (ob): result = res else: result = [] # if no out of bounds, then do real calcs. for s in systems.systems: x = systems.mapx_to_system(args, s) wprint("mapped ", args, " to ", x) res = array_function(x, s.objective, s.input, s.special_pc, s.evals_file) wprint("array function returning: ", res) for r in res: result.append(r) wprint("array function MULTI returning: ", result) report_result(args, result, "multi ", systems.evals_file) return result def array_function_multi2(args, fx): # called from lmfit, tricky python->C->python interface, can't "return" a list result = array_function_multi(args) for i in range(0, len(result)): fx[i] = result[i] ################# end of local functions ############################ # if x0 provided, use it; otherwise randomizes starting point for each job_comm # first job uses x0 from specification of nlep params in input.py # if x0 provided, other jobs use it in order; # otherwise randomize starting point for each job_comm x0 = systems.getx() ranges = systems.get_ranges() print("ranges = ", ranges) if (job_comm.rank == 0 and (run_input.random_start == None or run_input.random_start == False)): x0 = systems.getx() wprint("using default initial condition ", x0) else: x0 = np.array([x0[i] + random.uniform(-ranges[i], ranges[i]) for i in range(0, len(x0))], dtype="float64") wprint("setting random initial condition ", x0) # elif (not input.x0 == None and world.rank-1 < len(input.x0)): # x0 = np.array(input.x0[world.rank-1]) ##THIS IS A BUG, if we specify x0 in input_generic.py # elif input.bounds != None: # x0 = np.array([random.uniform(*input.bounds) for u in x0], dtype="float64") # else: # x0 = np.zeros((x0.size), dtype="float64") # objective.x = broadcast(job_comm, x0, 0) # if world.rank == 0: print "x0: ", x0 print("rank %d x0 = " % world.rank, x0) print("rank %d ranges = " % world.rank, ranges) ########## # need fix. if (run_input.one_shot != None and run_input.one_shot == True): array_function_multi(x0) ########## if ((run_input.one_shot == None or not run_input.one_shot) and not run_input.do_scan): if run_input.optimizer == "leastsq": # least-square fit with scipy.optimize.leastsq # Somehow leastsq expects a function, but never a functor!! if (job_comm.rank == 0): # print some stuff: print("epsfcn = ", run_input.epsfcn) print("xtol = ", run_input.xtol) print("ftol = ", run_input.ftol) print("factor = ", run_input.step_factor) print("Calling scipy least squares fitter") x0, cov_x, infodict, mesg, ier\ = leastsq(array_function_multi, x0, maxfev=run_input.max_functional_eval, full_output=1, xtol=run_input.xtol, ftol=run_input.ftol, factor=run_input.step_factor, epsfcn=run_input.epsfcn) # computes/print optimal results. # result = objective.final(x0) print("rank %d minimum value of sum of squares:" % world.rank, np.linalg.norm(infodict["fvec"])) print("for: ", x0) print("after %i function calls." % (infodict["nfev"])) print("with warning flag: ", ier, mesg) # least square via lmmin (parallel finite difference derivative) elif run_input.optimizer == "lmmin": import liblmmin as lm npar = len(x0) ndat = systems.get_result_size(run_input) print("Calling lmmin fd-parallel least squares fitter with epsfcn = ", run_input.epsfcn) x0 = np.array([float(xi) for xi in x0]) lm.lmmin_py(job_comm, array_function_multi2, npar, x0, ndat, run_input.epsfcn) print("lmmin_py returned!") else: print("YOU DID NOT SPECIFY A FITTING METHOD") for s in systems.systems: s.evals_file.close() systems.evals_file.close() def load_options(): from optparse import OptionParser parser = OptionParser() parser.add_option("-t", "--run-input", dest="run_input_name", type="string", default="run_input.py", help="name of input file") (options, args) = parser.parse_args() return (options, args) def load_run_input(): from pylada.vasp import read_input # options, args = load_options() rin = "run_input.py" run_input = read_input("input_generic.py") # run_input.update(read_input(options.run_input_name)) run_input.update(read_input(rin)) return run_input def main(system_params=None): from boost.mpi import world, broadcast from pylada.vasp.extract import Extract, ExtractGW from pylada.vasp.specie import U, nlep from pylada.vasp import Vasp import os from os import path from .nlep import Objective from pylada.vasp.nlep.postprocessing import find_best, load_test, prepare_analog_fit print("mpi rank %d of %d" % (world.rank, world.size)) # Things which need to be put into dictionary of input script. # global_dict = { "Extract": Extract, "ExtractGW": ExtractGW, "Vasp": Vasp, "nlep": nlep, "U": U } # read file governing run. other input files should be generic run_input = load_run_input() run_control = RunControl(run_input) load_from_analogs = run_input.load_from_analogs # create systems from .systems import setup_systems systems = setup_systems(run_input, system_params) if (run_input.nbjobs == -1): run_control.nbjobs = world.size assert world.size >= run_control.nbjobs, "Too few procs granted, or too many jobs requested." job_comm = world vasp_comm = world color = world.rank % run_control.nbjobs job_comm = world.split(color) vasp_comm = job_comm if (job_comm.size > 1): vasp_comm = job_comm.split(job_comm.rank) create_directories(run_control, systems, job_comm, color) # barrier to be sure all necessary directories exist world.barrier() # creates objective functions from systems for s in systems.systems: print(s.outdir) s.objective = Objective(s.input.vasp, s.input.dft_in, s.input.gw_in, outdir=s.outdir, comm=vasp_comm, units=run_input.units) s.evals_file = file("%s/evals" % s.outdir, "w") systems.evals_file = file("%s/evals" % run_control.outdir, "w") # setup correspondence between vector "x" and list of species (ie at least # one subpart shared by > 1 systems): systems.setup_species() # barrier to be sure all necessary directories exist world.barrier() # only serial vasp so far, but lmmin is a parallel fitter if (job_comm.rank != 0 and run_input.optimizer != "lmmin"): print("rank %d superfluous, returning; beware barrier" % world.rank) return print("world rank %d job %d local rank %d working dir %s" % (world.rank, color, job_comm.rank, run_control.outdir)) job_main(job_comm, run_input, systems, vasp_comm) if __name__ == '__main__': try: main() except Exception as e: from boost.mpi import world, abort import traceback from sys import stderr print("Final exception encountered by process: ", world.rank, file=stderr) traceback.print_exc(file=stderr) abort(0)
pylada/pylada-light
src/pylada/vasp/nlep/mpopt.py
Python
gpl-3.0
21,833
[ "CRYSTAL", "VASP" ]
fa80f46269c065c3d5a4f9919289d04d03c6c6a8aebff59928494cad8cf07adb
# # This file is part of the CCP1 Graphical User Interface (ccp1gui) # # (C) 2002-2005 CCLRC Daresbury Laboratory # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # """A molecule viewer and editor built with Tkinter The TkMolView class defined here does not actually include the code to render the molecule into the main window, for this see the derived classes in files (e.g. vtkgraph.py and openglgraph.py) """ import os,sys if __name__ == "__main__": # Need to add the gui directory to the python path so # that all the modules can be imported gui_path = os.path.split(os.path.dirname( os.path.realpath( __file__ ) ))[0] sys.path.append(gui_path) # Before we do owt else, make sure we can import the modules that we need # and give the user a helpful messsage if we can't (apparently some people # don't like reading tracebacks...) # If that all works, set the PYTHONPATH variable to include the main GUI # directory so that we can find all of our modules header=""" ###################################################################### # # # MODULE IMPORT ERROR! # # # ######################################################################""" whereget=""" Alternatively, for information on all of the dependancies for the GUI and instructions for their installation proceedures, please visit: http://www.cse.clrc.ac.uk/ccg/software/ccp1gui/install.shtml Distributions of the CCP1GUI that contain the relevant Python modules and pre-compiled vtk libraries are available for download for some platforms from: ftp ftp.dl.ac.uk/qcg/ccp1gui """ # Tkinter try: import Tkinter except ImportError: print header print """ We are sorry but the CCP1GUI cannot run on your system as you do not appear to have Tkinter installed. For more information on installing Tkinter, please visit: http://tkinter.unpythonic.net/wiki/How_20to_20install_20Tkinter""" print whereget sys.exit(-1) # Pmw try: import Pmw except ImportError: print header print """ We are sorry but the CCP1GUI cannot run on your system as you do not appear to have Python MegaWidgets installed. For more information on installing Python Megawidgets, please visit: http://pmw.sourceforge.net/""" print whereget sys.exit(-1) # VTK try: import vtk except ImportError: print header print """ We are sorry but the CCP1GUI cannot run on your system as you do not appear to have VTK installed. For more information on installing VTK, please visit: http://public.kitware.com/VTK/get-software.php""" print whereget sys.exit(-1) from viewer.paths import paths print print 'Module paths:' print '=============' print 'VTK version',vtk.vtkVersion.GetVTKVersion(),' from ',vtk.__file__ #print Pmw.__file__ print "CCP1GUI directory: ",paths['gui'] print import Tkinter import stat import math from tkFileDialog import * from tkSimpleDialog import * import tkColorChooser from SimpleDialog import SimpleDialog import traceback import types import time from generic.graph import * import copy import chempy from chempy import cpv, Atom, Bond import viewer.help from viewer.debug import deb_setwidget,deb from viewer.initialisetk import initialiseTk from viewer.shell import env, mypyshell #print dir() #from interfaces.calc import * #from interfaces.calced import * from interfaces.gamessuk import GAMESSUKCalc, GAMESSUKCalcEd from interfaces.molpro import MOLPROCalc, MOLPROCalcEd from interfaces.chemshell import ChemShellCalc, ChemShellCalcEd from interfaces.dl_poly import DLPOLYCalc from interfaces.mopac import MopacCalc from interfaces.mndo import MNDOCalc from interfaces.dalton import DALTONCalc #from interfaces.charmm import * from interfaces.smeagol import SMEAGOLCalc import interfaces.am1calc import viewer.selections2 import objects from objects.zme import * from objects.periodic import sym2no, z_to_el, name_to_element from viewer.slavethread import SlaveThread import jobmanager.jobeditor from viewer.toolpanel import * from objects import symed import thread from viewer.defaults import defaults from interfaces.getfileio import GetFileIO class TkMolView(Pmw.MegaToplevel): """The Tk-based Widget""" def __init__(self, parent, title=''): Pmw.MegaToplevel.__init__(self) # First set any default values - the defaults are actaully set # when the defaults object is is instantiated, but we need to # to set the variables that are attributes of main # This group of options can be set by the user from the # Options tool - they can also be over-ridden by the users' # .ccp1guirc.py file (see read_ccp1guirc). # self.conn_scale = 1.0 self.conn_toler = 0.5 self.contact_scale = 1.0 self.contact_toler = 1.5 self.bg_rgb = (0,0,0) self.field_line_width = 1 self.field_point_size = 2 self.mol_line_width = 3 self.mol_point_size = 4 self.mol_sphere_resolution = 8 self.mol_sphere_specular = 1.0 self.mol_sphere_ambient = 0.4 self.mol_sphere_diffuse = 1.0 self.mol_sphere_specular_power = 5 self.mol_cylinder_resolution = 8 self.mol_cylinder_ambient = 0.4 self.mol_cylinder_specular = 0.7 self.mol_cylinder_diffuse = 0.7 self.mol_cylinder_specular_power = 10 ## this may have a different meaning in the derived class try: itest = self.pick_tolerance except AttributeError: self.pick_tolerance = -999 self.debug = 0 self.debug_callbacks = 0 self.debug_selection = 0 self.enable_undo = 1 self.title('CCP1GUI'+25*' '+title) self.iconname('CCP1GUI') # This is to provide a handle for the shell window to access # variables from this class env.tkmol = self if not parent: parent = Tkinter._default_root initialiseTk(parent) self.parent = parent # TEMP HACK self.master = self.interior() #Bind F1 to open a help menu and pass in error widget self.master.bind_all('<F1>', lambda event : viewer.help.helpall(event)) # Associate helpfile with widget viewer.help.sethelp(self.master,'Introduction') #self.master.bind("<j>",lambda e,s=self: s.restore_saved_jobs()) self.xmlreader = None self.getfileIO = None # object to get the correct reader for a file # We only want one instance of the allmoleculevisualiser self.allmolecule_visualiser = None # We only want one scene visualiser self.ani_image_widget = None self.__createBalloon() # create the menubar self.menuBar = self.createcomponent('menubar', (), None, Pmw.MenuBar, (self._hull,), # hull_relief=RAISED, # hull_borderwidth=0, #balloon=self.__balloon) balloon=self.balloon) self.menuBar.pack(fill=X) self.menuBar.addmenu('Help', 'Documentation', side='right') self.menuBar.addmenu('File', 'File Input/Output') self.menuBar.addmenu('Edit', 'Editing molecules and other tools') self.menuBar.addmenu('Views', 'Create and modify graphical representation') self.menuBar.addmenu('Info', 'Information listings for the loaded objects') self.menuBar.addmenu('Compute', 'Call computational chemistry codes') #self.menuBar.addmenu('Debug', 'Switch various debug options on/off') self.menuBar.addmenu('Shell', 'Access Python Shell \n(see info and debug output, \nand enter python commands)') #self.menuBar.addmenu('Edit', 'Atom and Variable') #self.menuBar.addmenu('Convert', 'Z-matrix/cartesian conversion') #self.menuBar.addmenu('Calculate', 'Generate Cartesians') # Build Menus #self.mBar = Frame(self.interior(),relief=RAISED, borderwidth=2) #self.mBar.pack(side='top', fill=X) self.FileMenu() self.EditMenu() self.InfoMenu() self.ViewMenu() #self.VisualiseMenu() self.ComputeMenu() #self.DebugMenu() self.ShellMenu() self.HelpMenu() # Build Dialogs self.build_msg_dialog() self.build_query_dialog() self.build_vis_dialog() self.build_data_dialog() self.build_help_dialog() self.build_watch_dialog() self.build_extend_dialog() self.build_distance_dialog() self.build_distance_dialog(include_xyz=1) self.build_command_window() if not defaults.get_value('save_image_dialog_quick'): self.build_save_image_dialog() self.build_save_movie_dialog() self.build_saveas_filetype_dialog() #Pass viewer object to the help.py module viewer.help.get_tkmolview(self) self.vis_list = [] self.data_list = [] # dictionary for mapping structures to images # one->many, each entry is a list self.vis_dict = {} # dictionary for working out which structures are being # actively edited (see vtkgraph.py) # one->one , each entry is a zme instance self.zme_dict = {} # dictionary for load/save self.file_dict = {} # dictionary for mapping structures to CalcEd instances # one->many, each entry is a list self.calced_dict = {} # default colourmaps self.define_colourmaps() self.undo_stack = [] # animation controls self.build_ani_toolbar() self.pack_ani_toolbar() # list of images from last animation frame #self.oldvisl = [] self.build_options_dialog() self.toolwidget = EditingToolsWidget(self.master, command=self.handle_edits) self.toolwidget.userdeletefunc(lambda s=self: s.toolwidget.withdraw()) self.toolwidget.withdraw() # Symmetry widget self.symmetryWidget = symed.SymmetryWidget( self.master, command=self.symmetry_operations, balloon = self.balloon ) self.symmetryWidget.withdraw() # For the iPython shell self.ipythonshell=None # Create a text widget for the debug output self.debug_window = Pmw.MegaToplevel(parent) self.debug_window.title('CCP1 GUI Debug Output') fixedFont = Pmw.logicalfont('Courier',size=10) txt = Pmw.ScrolledText( self.debug_window.interior(), borderframe = 1) txt.pack() txt.configure(text_font = fixedFont) self.debug_window.text = txt #Associated widget with its help file viewer.help.sethelp(self.debug_window,'Debug Window') self.debug_window.withdraw() self.debug_window.userdeletefunc(lambda s=self: s.debug_window.withdraw()) self.job_manager = jobmanager.JobManager() self.job_editor = jobmanager.jobeditor.JobEditor(parent,self.job_manager) #self.job_editor.userdeletefunc(lambda s=self: s.job_editor.withdraw()) self.job_editor.withdraw() # these are used for on-the-fly minimisations self.clean_calced = {} ##self.start_clean_calceds() self.window2d = Pmw.MegaToplevel(parent) self.window2d.title('CCP1 GUI 2D') self.window2d.userdeletefunc(lambda s=self: s.window2d.withdraw()) self.window2d.withdraw() self.mBar2d = Frame(self.window2d.interior(),relief=RAISED, borderwidth=2) self.mBar2d.pack(side='top', fill=X) self.FileMenu2d() global sel sel = viewer.selections2.SelectionManager() # Paul debug self.job_editor.mainobj = self #print 'Parent Geom', parent.geometry() #print 'Master Geom', self.master.geometry() self.new_molecule_index = 0 # A list of functions to be called whenever editing operations # are performed in the # Structure is a dictionary keyed on the ID of the object # that has changed. Each element is a list of tuples # each tuple is a character string to identify the callback and # a function to call when that object has been changed # If function is a method of another object, that object must # remove the callback on deletion # - by convention this is handled by the on_exit= argument self.editing_callbacks = {} # Set any defaults, then override and add any user-defined functions # from the ccp1guirc file self.read_ccp1guirc() def read_ccp1guirc(self): """Process the ccp1guirc file: Execute the file to execute any of the users python code, and then check for any variables that are set in the file. These are stored in the rc_vars dictionary. Any variables that are attributes of self are set. """ global defaults rcfile = defaults.rcfile if os.path.isfile( rcfile ): print "Executing ccp1guirc file %s" % rcfile execfile( rcfile ) # New read in the file using defaults defaults.read_from_file() # Now set anything in the defaults that might be an attribute of main for key,value in defaults.iteritems(): if hasattr( self, key ): #print "setting attribute of main: %s : %s" %(key,value) setattr( self, key, value ) def restore_saved_jobs(self,directory=None): """ See if there are any pickled jobs in this directory if there are - unpickle them - if the job has a calc * add the requisite endjob function to the job steps as it will have been deleted * instantiate a calculation editor passing it the main widget, the calculation, the job manager * restart the calculation with the start_job method of the calculation editor - otherwise just start the job """ #print "checking save jobs" job_ext = '.job' if not directory: directory = os.getcwd() files = os.listdir( directory ) jobfile_list = [] for fname in files: #print "checking fname ",fname ext = os.path.splitext( fname )[1] fpath = directory + os.sep + fname if ext == job_ext: print "got match for: %s" % fpath jobfile_list.append ( fpath ) if len( jobfile_list ): if not self.query("There are saved jobs in this directory. Would you like to restore them?"): return # User wants to restore the jobs for jfile in jobfile_list: try: fobj = open( jfile ) p = cPickle.Unpickler( fobj ) job = p.load() except Exception,e: self.error("Unpickle failed for jobfile %s\n%s" % (jfile,e)) continue try: calc = job.calc except AttributeError: calc = None if calc: print "Trying to start ",calc # Hack to add the tidy function - should probably do some more clever # checking here but for the time being assume that all jobs end with a tidy # function that can't be pickle and has been removed when the job was saved job.add_tidy( calc.endjob ) ed = self.edit_calc( calc ) # Currently we start the job automatically - might be better to let the # user hit run? ed.start_job( job ) else: self.job_editor.start_job( job ) # Restored job so remove the old file try: os.remove( jfile ) except IOError: self.error("Error removing job file: %s" % jfile ) return def __createBalloon(self): # Create the balloon help manager for the frame. # Create the manager for the balloon help #self.__balloon = self.createcomponent('balloon', (), None, # Pmw.Balloon, (self._hull,)) self.balloon = self.createcomponent('balloon', (), None, Pmw.Balloon, (self._hull,),initwait=2000) def update(self): """Update the screen """ print 'render should be overloaded' # def reset(self): # print 'reset' def build_ani_toolbar(self): bar = Frame(self.interior(),relief=SUNKEN, borderwidth=2) #bar.pack(side='bottom', fill=X) self.ani_toolbar = bar #b=Button(bar, text='Reset', command=self.reset) b=Button(bar, text='Reset', command=self.ani_reset) b.pack(side='left') b=Button(bar, text='|<', command=self.ani_rew) b.pack(side='left') b=Button(bar, text='<', command=self.ani_bak) b.pack(side='left') b=Button(bar, text='Stop', command=self.ani_stop) b.pack(side='left') b=Button(bar, text='Play', command=self.ani_play) b.pack(side='left') b=Button(bar, text='>', command=self.ani_fwd) b.pack(side='left') b=Button(bar, text='>|', command=self.ani_end) b.pack(side='left') #b=Button(bar, text='Hide', command=self.hide_ani_toolbar) #b.pack(side='left') b=Button(bar, text='Select', command=self.select_ani_images ) b.pack(side='left') b=Button(bar, text='Save Images', command=self.ask_save_movie ) b.pack(side='left') def pack_ani_toolbar(self): """ Pack the toolbar and reset it """ self.ani_toolbar.pack(side='bottom') self.ani_reset() def hide_ani_toolbar(self): self.ani_toolbar.forget() def FileMenu(self): mbutton = self.menuBar.component('File-button') ##Menubutton(self.mBar, text='File', underline=0) ##mbutton.pack(side=LEFT, padx="2m") menu = Menu(mbutton, tearoff=0) menu.add_command(label='Open ', underline=0, command=self.ask_load_from_file) menu.add_command(label='Save As', underline=0, command=self.ask_save_to_file) menu.add_command(label='New Molecule', underline=0, command = lambda s=self: s.new_coords() ) menu.add_separator() menu.add_command(label='Save Image', underline=0, command=self.ask_save_image3d) # menu.add_separator() # menu.add_command(label='Watch ', underline=0, # command=self.ask_watch_file) menu.add_separator() menu.add_command(label='Open Calc',underline=0, command = lambda s=self: s.open_calc() ) # menu.add_command(label='Hardcopy', underline=0, # command=self.hardcopy) menu.add_separator() menu.add_command(label='Quit', underline=0, command=self.myquit) mbutton['menu'] = menu return mbutton #=============================================================================== # def OldFileMenu(self): # mbutton = Menubutton(self.mBar, text='File', underline=0) # mbutton.pack(side=LEFT, padx="2m") # menu = Menu(mbutton, tearoff=0) # # menu.add_command(label='Open ', underline=0, # command=self.ask_load_from_file) # # menu.add_command(label='Save As', underline=0, # command=self.save_to_file) # # menu.add_command(label='New Molecule', underline=0, # command = lambda s=self: s.new_coords() ) # # menu.add_separator() # # menu.add_command(label='Save Image', underline=0, # command=self.save_image) # # # menu.add_separator() # # menu.add_command(label='Watch ', underline=0, # # command=self.ask_watch_file) # # menu.add_separator() # menu.add_command(label='Open Calc',underline=0, # command = lambda s=self: s.open_calc() ) # # # menu.add_command(label='Hardcopy', underline=0, # # command=self.hardcopy) # # menu.add_separator() # menu.add_command(label='Quit', underline=0, # command=self.myquit) # # mbutton['menu'] = menu # return mbutton #=============================================================================== def FileMenu2d(self): mbutton = Menubutton(self.mBar2d, text='File', underline=0) mbutton.pack(side=LEFT, padx="2m") menu = Menu(mbutton, tearoff=0) menu.add_command(label='Save Image(2d)', underline=0, command=self.ask_save_image2d) mbutton['menu'] = menu return mbutton def destroy(self): """Handler for window close events""" self.quit() def myquit(self): """Called on user-requested exit""" self.quit() def quit(self): """Handler for exit""" try: # process rc_vars #self.write_ccp1guirc() defaults.write_to_file() except Exception,e: print "Error writing ccp1guirc file!" traceback.print_exc() # Needs looking at... # try: # self.job_editor.ask_quit() # except Exception,e: # print "Error quitting jobeditor!\n%s" % e # # parent is the initial Tk root window (kept hidden) # destroy works better than exit when using Pmw.Ballon # see http://mail.python.org/pipermail/python-list/2005-February/308718.html self.parent.destroy() def EditMenu(self): #mbutton = Menubutton(self.mBar, text='Edit', underline=0) #mbutton.pack(side=LEFT, padx="2m") mbutton = self.menuBar.component('Edit-button') menu = Menu(mbutton, tearoff=0, postcommand=self.post_edit) self.edit_menu=menu mbutton['menu'] = menu return mbutton def InfoMenu(self): mbutton = self.menuBar.component('Info-button') menu = Menu(mbutton, tearoff=0, postcommand=self.post_info) self.info_menu=menu mbutton['menu'] = menu return mbutton def build_save_image_dialog_quick(self): """Build up the widgets that consitute the save image dialog box with the slider to specify the quality of the jpeg. """ from FileDialog import SaveFileDialog self.save_image_dialog=SaveFileDialog(self.master) myframe=Frame(self.save_image_dialog.top,background='blue') self.save_image_dialog.midframe.forget() self.save_image_dialog.botframe.forget() self.save_image_dialog.selection.forget() myframe.pack(side='bottom',fill='x',expand='yes') self.save_image_dialog.midframe.pack(expand=YES, fill=BOTH) self.save_image_dialog.botframe.pack(side=BOTTOM, fill=X) self.save_image_dialog.selection.pack(side=BOTTOM, fill=X) self.image_format = Tkinter.StringVar( ) self.image_format.set("jpg") format_frame = Tkinter.Frame( myframe ) jpegradio = Tkinter.Radiobutton( format_frame, text = "jpg", variable = self.image_format, value = "jpg", command = self.select_image_format ) pngradio = Tkinter.Radiobutton( format_frame, text = "png", variable = self.image_format, value = "png", command = self.select_image_format ) tiffradio = Tkinter.Radiobutton( format_frame, text = "tiff", variable = self.image_format, value = "tiff", command = self.select_image_format ) self.jpeg_res_frame = Tkinter.Frame( myframe ) format_frame.pack() jpegradio.select() jpegradio.pack( side = 'left' ) pngradio.pack( side = 'left' ) tiffradio.pack( side = 'left' ) # print dir(self.save_image_dialog) def build_save_image_dialog(self): """Build up the widgets that consitute the save image dialog box with the slider to specify the quality of the jpeg. """ format='jpg' self.image_format = Tkinter.StringVar( ) self.image_format.set(format) self.image_filename = Tkinter.StringVar() self.image_filename.set(paths['user']+os.sep+'out.'+format) self.save_image_dialog = Pmw.Dialog( self.master, buttons = ( 'Save', 'Cancel'), title = 'Save window as image', command = self.save_image3d ) format_frame = Tkinter.Frame( self.save_image_dialog.interior() ) jpegradio = Tkinter.Radiobutton( format_frame, text = "jpg", variable = self.image_format, value = "jpg", command = self.select_image_format ) pngradio = Tkinter.Radiobutton( format_frame, text = "png", variable = self.image_format, value = "png", command = self.select_image_format ) tiffradio = Tkinter.Radiobutton( format_frame, text = "tiff", variable = self.image_format, value = "tiff", command = self.select_image_format ) self.jpeg_res_frame = Tkinter.Frame( self.save_image_dialog.interior() ) self.jpeg_res_widget = Tkinter.Scale( self.jpeg_res_frame , label = 'Jpeg quality', orient = 'horizontal', tickinterval = '10', length = '400', from_ = 0, to_ = 100 ) self.jpeg_res_widget.set( '95' ) # This seems to be the default (see: VTK/IO/vtkJPEGWriter.cxx ) # Show/change name/path filepath_frame = Tkinter.Frame( self.save_image_dialog.interior() ) self.save_image_fpath_widget = Pmw.EntryField( filepath_frame, labelpos = 'w', entry_width=40, label_text = 'Filename:', value = self.image_filename.get()) self.save_image_fpath_button = Tkinter.Button( filepath_frame, text='Browse..', command = self.ask_save_image_filename) format_frame.pack() jpegradio.select() jpegradio.pack( side = 'left' ) pngradio.pack( side = 'left' ) tiffradio.pack( side = 'left' ) self.jpeg_res_frame.pack() self.jpeg_res_widget.pack() filepath_frame.pack() self.save_image_fpath_widget.pack(side='left') self.save_image_fpath_button.pack(side='left') self.save_image_dialog.withdraw() def ask_save_image_filename( self ): """ Select between jpeg and png image formats - if jpg is selected display the widget to specify the quality """ filepath = self.image_filename.get() filename = os.path.basename(filepath) format = self.image_format.get() filepath = tkFileDialog.asksaveasfilename( initialfile = filename, filetypes=[("All","*.*")]) if len(filepath): self.image_filename.set(filepath) self.save_image_fpath_widget.setentry(filepath) def select_image_format( self ): """ Select between jpeg and png image formats - if jpg is selected display the widget to specify the quality We also change the extension. """ if defaults.get_value('save_image_dialog_quick'): return format = self.image_format.get() # Change the extension to match the format filepath=self.image_filename.get() stem,ext = os.path.splitext( filepath ) if '.'+ext != format: filepath=stem+'.'+format self.image_filename.set(filepath) self.save_image_fpath_widget.setentry(filepath) if format == "jpg": self.jpeg_res_frame.pack() else: self.jpeg_res_frame.forget() def build_save_movie_dialog(self): """Build up the widgets that consitute the save image dialog box with the slider to specify the quality of the jpeg. """ self.movie_directory = paths['gui'] self.save_movie_dialog = Pmw.Dialog( self.master, buttons = ( 'Save', 'Close', 'Browse...' ), title = 'Save Movie', command = self.save_movie_buttonclick ) format_frame = Tkinter.Frame( self.save_movie_dialog.interior() ) self.movie_format = Tkinter.StringVar( ) self.movie_format.set("jpg") jpegradio = Tkinter.Radiobutton( format_frame, text = "jpg", variable = self.movie_format, value = "jpg", command = self.select_movie_format ) pngradio = Tkinter.Radiobutton( format_frame, text = "png", variable = self.movie_format, value = "png", command = self.select_movie_format ) self.movie_jpeg_res_frame = Tkinter.Frame( self.save_movie_dialog.interior() ) self.movie_jpeg_res_widget = Tkinter.Scale( self.movie_jpeg_res_frame , label = 'Jpeg quality', orient = 'horizontal', tickinterval = '10', length = '400', from_ = 0, to_ = 100 ) format_frame.pack() jpegradio.select() jpegradio.pack( side = 'left' ) pngradio.pack( side = 'left' ) self.movie_jpeg_res_frame.pack() self.movie_jpeg_res_widget.set( '95' ) # This seems to be the default (see: VTK/IO/vtkJPEGWriter.cxx ) self.movie_jpeg_res_widget.pack() self.save_movie_dialog.withdraw() def select_movie_format( self ): """ Select between jpeg and png image formats - if jpg is selected display the widget to specify the quality """ format = self.movie_format.get() if format == "jpg": self.movie_jpeg_res_frame.pack() elif format == "png": self.movie_jpeg_res_frame.forget() else: print "no image string :%s" % format def save_movie_buttonclick(self, result ): """ Process the result of clicking one of the buttons in the save_movie_dialog """ print "save_movie_buttonclick ", result if result == "Close": self.save_movie_dialog.withdraw() elif result == "Browse...": self.browse_movie_directory() elif result == "Save": format = self.movie_format.get() self.save_movie( format ) self.save_movie_dialog.withdraw() else: self.save_movie_dialog.withdraw() def browse_movie_directory(self): # askdirectory() cant create new directories so use asksaveasfilename is used instead # and the filename is discarded - also fixes problem with no askdirectory in Python2.1 olddir = self.movie_directory dummyfile="use_this_directory" path=tkFileDialog.asksaveasfilename(initialfile=dummyfile, initialdir=olddir) #path=tkFileDialog.askdirectory(initialdir=olddir) if len(path) == 0: # User didn't select anything pass else: self.movie_directory = os.path.dirname( path ) def save_movie(self, format ): """ """ print "format is ",format directory = self.movie_directory print "directory is ",directory # or should we ask? if len( self.ani_list ) == 0 : self.ani_reset() # hide everything self.showall(0) # Loop over the images, creating a unique name and then show the image, # take a snapshot and save this as a jpeg with the unique name and # then hide the image image_file_list = [] i = 0 renderWindow = self.pane.GetRenderWindow() for vis in self.ani_list: title = vis.title # Need to remove ":" from title & replace spaces with underscores title = string.replace( title, ":", "") title_list = string.split( title ) title = string.join( title_list, "_" ) myfile = directory + os.sep + title + "." + str( i ) + "." + format image_file_list.append( myfile ) vis.Show() if format == "jpg": quality = self.movie_jpeg_res_widget.get() self.save_image( renderWindow,myfile, format=format, quality=quality ) elif format == "png": self.save_image( renderWindow,myfile, format=format ) else: print "Unrecognised image format in save_movie" vis.Hide() i += 1 return def ask_save_image3d(self): if defaults.get_value('save_image_dialog_quick'): self.build_save_image_dialog_quick() filepath = self.save_image_dialog.go(paths['user'],"*.*","out.jpg") if (filepath): rw = self.pane.GetRenderWindow() format = self.image_format.get() self.save_image(rw, filepath, format=format ) else: self.save_image_dialog.show() def save_image3d( self, result ): """Function called by the save_image_dialog when the user has clicked Save or Cancel""" if result == 'Save': format = self.image_format.get() filename = self.image_filename.get() renderWindow = self.pane.GetRenderWindow() self.save_image( renderWindow, filename, format = format ) self.save_image_dialog.withdraw() def ask_save_image2d(self): """Save image from main window to a JPEG file""" name = 'out2d.jpg' ofile = tkFileDialog.asksaveasfilename( initialfile = name, filetypes=[("JPEG","*.jpg")]) if len(ofile): self.save_image2d(self.pane2d.GetRenderWindow(),ofile) def build_saveas_filetype_dialog(self): """ Create the dialog to use to query the user for the type of file they would like to save as""" # First variables used to pass data between the widgets self.saveas_filetype_name = None self.saveas_filetype_format=None self.saveas_filetype_appendext=Tkinter.BooleanVar() self.__saveas_oldext = None self.saveas_filetype_dialog = Pmw.Dialog( self.master, buttons = ('Save','Cancel'), title = 'Save As Filetype', command = self.saveas_filetype_dialog_process) # Only do this once if not self.getfileIO: self.getfileIO = GetFileIO() items = self.getfileIO.GetOutputFiletypesAsString() self.saveas_filetype_listbox = Pmw.ScrolledListBox( self.saveas_filetype_dialog.interior(), items=items, labelpos='n', label_text='Please select the type of file to save as', listbox_selectmode='browse', selectioncommand=self.saveas_filetype_addextension ) self.saveas_filetype_listbox.pack(expand=1,fill='both') f = Tkinter.Frame( self.saveas_filetype_dialog.interior() ) f.pack(padx=5,pady=5) flabel = Tkinter.Label( f, text='Saving as:', #relief='raised', padx=3, pady=3 ) flabel.pack(side='left') self.saveas_filetype_label = Tkinter.Label( f, text=self.saveas_filetype_name, relief='ridge', bg='white') self.saveas_filetype_label.pack(side='left') extension = Tkinter.Checkbutton( self.saveas_filetype_dialog.interior(), text="Automatically Append Extension", variable=self.saveas_filetype_appendext, command=self.saveas_filetype_addextension ) extension.pack() self.saveas_filetype_dialog.withdraw() def saveas_ask_filetype( self, filepath ): """ Fire up the dialog to get the use to specify the type of file they would like to save """ # Need to ask the user to specify the type self.saveas_filetype_name = filepath # Needed by the dialog # Now set this as the variable in the widget self.saveas_filetype_label.config( text=self.saveas_filetype_name ) # Highlight the first item in the list - need to do this before # we activate the widget or otherwise we can't sent it events. # Don't understand why we can't do this when we create the widget # but it seems not to work - it also fails if the user tries to # overwrite a file so it seems a bug with Tkinter self.saveas_filetype_listbox.select_set( 0 ) self.saveas_filetype_dialog.activate() format = self.saveas_filetype_format filepath = self.saveas_filetype_name return ( format, filepath ) def saveas_filetype_addextension(self): """User has clicked the button asking us to automatically append the extension. We add the extension if it wasn't already there or remove it depending on the option selected. """ doit = self.saveas_filetype_appendext.get() if doit: fpath = self.saveas_filetype_name # Get the extension - need to deal with the bug that nothing # will be selected if the user tried to overwrite a file try: ftypestr = self.saveas_filetype_listbox.getvalue()[0] except IndexError: # Get the whole list & select the first one ftypestr = self.saveas_filetype_listbox.get()[0] ext = ftypestr.split('[')[1].strip()[:-1] #print "ext ",ext # remember this as the old one if not self.__saveas_oldext: self.__saveas_oldext = ext # Check if it's already appended stem,cext = os.path.splitext( fpath ) #print "stem: %s cext %s" % (stem,cext) newname = None if not len(cext): # No extension so we can just add it newname = self.saveas_filetype_name+ext else: if cext == ext: # File already has the extension appended so pass pass elif cext == self.__saveas_oldext: # Extension on file is the last one we added so we # remove it before added the new one newname,next = os.path.splitext( self.saveas_filetype_name ) newname += ext if newname: # Set the old extension self.__saveas_oldext = ext # Set the name and the widget with it self.saveas_filetype_name = newname self.saveas_filetype_label.config( text=newname ) else: # Not appending extension - so remove it if it is already appended # Get the extension - need to deal with the bug that nothing # will be selected if the user tried to overwrite a file try: ftypestr = self.saveas_filetype_listbox.getvalue()[0] except IndexError: # Get the whole list & select the first one ftypestr = self.saveas_filetype_listbox.get()[0] ext = ftypestr.split('[')[1].strip()[:-1] newname,next = os.path.splitext( self.saveas_filetype_name ) if next == ext: self.saveas_filetype_name = newname self.saveas_filetype_label.config( text=newname ) def saveas_filetype_dialog_process(self,result): if result == 'Cancel': self.saveas_filetype_format = None self.saveas_filetype_name = None self.saveas_filetype_dialog.deactivate() elif result == 'Save': ftypestr = self.saveas_filetype_listbox.getvalue()[0] self.saveas_filetype_format = ftypestr.split('[')[0].strip() self.saveas_filetype_dialog.deactivate() def loaded_mols(self): """Return a list of all molecules currently loaded""" mols = [] for o in self.data_list: myclass=o.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': ####or myclass =='ZmatrixSequence': mols.append(o) return mols def loaded_seqs(self): """Return a list of all molecule sequences currently loaded""" mols = [] for o in self.data_list: myclass=o.GetClass() if myclass =='ZmatrixSequence': mols.append(o) return mols def loaded_fields(self): """Return a list of all field objects currently loaded""" fields = [] for o in self.data_list: myclass=o.GetClass() if myclass == 'Field': fields.append(o) return fields def post_edit(self): menu = self.edit_menu menu.delete(0,Tkinter.AtEnd()) mols=self.loaded_mols() fields=self.loaded_fields() if self.enable_undo: if len(self.undo_stack): menu.add_command(label="Undo", underline=0,command=self.undo) else: menu.add_command(label="Undo", underline=0,command=self.undo,state="disabled") menu.add_separator() self.add_mol_cmd(menu,mols,"Edit Coords",self.edit_coords) self.add_field_cmd(menu,fields,"Edit Grid",self.edit_grid) self.add_mol_cmd(menu,mols,"Connect",self.connect_model,all=1) self.add_mol_cmd(menu,mols,"Extend",self.extend_model,all=1) menu.add_separator() seqs = self.loaded_seqs() self.add_mol_seq_cmd(menu,seqs,"Extract Frame from Sequence",self.extract_frame,all=1) menu.add_separator() self.add_mol_cmd(menu,self.data_list,"Delete",self.delete_obj,all=1) menu.add_separator() # Simple molecular editing functions #self.add_mol_cmd(menu,mols,"Rename Molecule",self.rename_mol) menu.add_command(label='Editing Tools', underline=0, command=lambda x=self: x.toolwidget.show()) menu.add_separator() menu.add_command(label='Select All', underline=0, command=lambda x=self: x.select_all()) menu.add_command(label="Select connected",command=self.select_connected) menu.add_command(label="Select by bonds",command=self.select_by_bonds) menu.add_command(label="Select (dist to sel) ",command=self.select_by_distance_to_selected) menu.add_command(label="Select (dist to point)",command=self.select_by_distance_to_point) menu.add_command(label="Select (dist to point) + trim models",command=self.select_by_distance_to_point_and_trim) menu.add_separator() menu.add_command(label="Delete Selected Atoms",command=self.delete_atom) menu.add_command(label="Delete Unselected Atoms",command=self.delete_unselected) menu.add_separator() menu.add_command(label='Options', underline=0, command=lambda x=self: x.open_options_dialog()) def post_info(self): mols=self.loaded_mols() menu = self.info_menu menu.delete(0,Tkinter.AtEnd()) self.add_mol_cmd(menu,mols,"Coordinate List",self.list_model) self.add_mol_cmd(menu,mols,"Bond Lengths and Angles",self.list_geom) self.add_mol_cmd(menu,mols,"Contacts to Selected Atoms",self.list_contacts) def show_symmetry_widget( self ): """ Activate the symmetry widget """ self.symmetryWidget.show() def hide_symmetry_widget( self ): """ Deactivate the symmetry widget """ self.symmetryWidget.withdraw() def symmetry_operations(self,operation,argument): """Handler for operations requested by the symmetry widget """ if operation == 'getSymmetry': return self.get_symmetry( thresh = argument ) elif operation == 'symmetrise': self.symmetrise_molecule( thresh = argument) else: self.error('Unimplemented Symmetry Operation: '+operation+' '+argument) def get_symmetry(self,thresh=None ): """ Determine the symmetry for the currently selected molecule """ molecule = self.choose_mol() if not molecule: return None label,generators = molecule.getSymmetry( thresh=thresh ) # Need to refresh the view as we've reoriented the molecule self.update_from_object(molecule) return label, generators def symmetrise_molecule(self, thresh=None ): """ Symmetrise the currently selected molecule. """ molecule = self.choose_mol() if not molecule: return None # Undo code - when symmetrising we only change the coordinates and set all zorc to c # so we only need to remember these when reapplying the change atom_defs = [] for i in range( len(molecule.atom) ): # allocate memory atom_defs.append( None ) for atom in molecule.atom: i = atom.get_index() atom_defs[i] = [ atom.zorc, atom.coord ] self.undo_stack.append([lambda s = self: s.undo_symmetrise_molecule(molecule,atom_defs)]) # Got undo sorted so now carry out the op molecule.Symmetrise( thresh=thresh ) self.update_from_object(molecule) def undo_symmetrise_molecule(self,mol,atom_defs): """ Undo the symmetrisation of a molecule. """ for atom in mol.atom: i = atom.get_index() atom.zorc = atom_defs[i][0] atom.coord = atom_defs[i][1] self.update_from_object( mol ) def handle_edits(self,operation,argument): """Handler for operations requested e.g. from the Editing Tools panel """ if operation == 'Del Atom': self.delete_atom() elif operation == 'Del Bond': self.delete_bond() elif operation == 'Add Bond': self.add_bond() elif operation == 'All X->H': self.xtoh() elif operation == 'element': self.setz(argument) elif operation == 'hybridisation': self.sethyb(argument) elif operation == 'clean': self.clean(argument) elif operation == 'stop': self.stopAM1Opt() elif operation == 'cleanopts': self.clean_opts(argument) elif operation == 'fragment': self.addfrag(argument) elif operation == 'Distance': return self.measure_dist() elif operation == 'Angle': return self.measure_angle() elif operation == 'Torsion': return self.measure_torsion() elif operation == 'symmetry': return self.show_symmetry_widget() elif operation == 'change_bond_length': return self.change_bond_length(argument) elif operation == 'rotate_about_bond': return self.rotate_about_bond(argument) else: self.error('Unimplemented Edit: '+operation+' '+argument) def extract_frame(self,seq): """Load a single frame from a sequence (eg a trajectory) """ # We need to return the visualiser for this object so that # we can determine which is the current frame # Work out the visualiser for this object t = id(seq) if not self.vis_dict.has_key(t): self.error("No active visuliser for object in extract_frame!") #print "### Error returning visuliser for object in extract_frame! ###" return visl = self.vis_dict[t] # Should only be one active visualiser active_vis = None for v in visl: if v.is_showing: if active_vis: active_vis = -1 else: active_vis = v if active_vis == -1: self.error( """You have more than one trajectory visualiser active for this object. Please hide all those bar the one you would like to extract the frame from.""" ) return current_frame = active_vis.current_frame ex = seq.extract_frame() ex.title = 'Frame '+str(current_frame+1)+' of '+ seq.title ex.name = self.make_unique_name( ex.title ) self.append_data(ex); self.quick_obj_view(ex,'molecule') def delete_atom(self,unselected=None): """ Delete the selected atoms for the selected molecules, unless the unselected flag is supplied in which case, delete the unselected atoms """ sel = self.sel() dsel = sel.get() selats = {} selected_mols = [] for mol,atom in dsel: k = id(mol) if mol in selected_mols: selats[k].append(atom) else: selected_mols.append(mol) selats[k] = [atom] if unselected: # Invert the selection for mol in selected_mols: k = id(mol) atomlist = [] for atom in mol.atom: if atom not in selats[k]: atomlist.append(atom) selats[k] = atomlist if self.debug: deb('delete_atom'+str(dsel)) # NB - need to do shells too - below code from old delete_unselected #print 'sorting shells' ## keep only attached shells #oldshell = mol.shell #mol.shell = [] #for s in oldshell: # if s.linked_core.tempflag: # mol.shell.append(s) edited = [] undo = [] # Undo: need to restructure into loops by molecule # and have a single set of undos per mol for mol in selected_mols: # Undo code # convert connectivity table to bond list to simplify storage mol.update_bonds() old_list = copy.copy(mol.atom) old_bond = copy.deepcopy(mol.bond) #print 'check bonds saved' #for b in old_bond: # print b.index undo.append(lambda m = mol, oa = old_list: m.apply_atom_list(oa)) undo.append(lambda m = mol, ob = old_bond: m.apply_connect(ob)) undo.append(lambda m = mol: m.reindex()) undo.append(lambda m = mol: m.update_conn()) # End of undo code list = [] #for a in sel.get_by_mol(mol): k = id(mol) for a in selats[k]: list.append(a.get_index()) mol.delete_list(list) # clean_deleted is empty in the SelectionManager in selections2.py #sel.clean_deleted(mol) self.update_from_object(mol) undo.append(lambda m = mol, s = self: s.update_from_object(m)) self.undo_stack.append(undo) def delete_unselected(self): """ Delete the unselected atoms - this just calls self.delete_atom with the unselected argument """ self.delete_atom(unselected=1) return def add_bond(self): sel = self.sel() dsel = sel.get() if len(dsel) != 2: self.error('Select 2 atoms only') return m1,a1 = dsel[0] m2,a2 = dsel[1] if m1 != m2: self.error('Select 2 atoms in the same molecule') return m1.add_bond(a1,a2) self.update_from_object(m1) def delete_bond(self): sel = self.sel() sel.printsel() dsel = sel.get() if len(dsel) != 2: self.error('Select 2 atoms only') return m1,a1 = dsel[0] m2,a2 = dsel[1] if m1 != m2: self.error('Select 2 atoms in the same molecule') return a1.conn.remove(a2) a2.conn.remove(a1) bhit = None for b in m1.bond: if ( b.index[0] == a1.get_index() and b.index[1] == a2.get_index() ) or \ ( b.index[0] == a2.get_index() and b.index[1] == a1.get_index() ) : bhit = b m1.bond.remove(bhit) self.update_from_object(m1) def xtoh(self): sel = self.sel() dsel = sel.get() mols = [] if len(dsel) == 0: # no selection mols.append(self.choose_mol()) else: for mol,atom in dsel: mols.append(mol) undo = [] for mol in mols: for atom in mol.atom: if atom.symbol == 'X': func = mol.update_bond_distances( atom, 'H' ) if func: mol.calculate_coordinates() undo.append( func ) undo.append( lambda m = mol : m.calculate_coordinates() ) undo.append(lambda a = atom, oldsym = atom.symbol: a.set_symbol(oldsym)) undo.append(lambda a = atom, oldname = atom.name: a.set_name(oldname)) atom.symbol = 'H' atom.name = 'H' self.update_from_object(mol) undo.append(lambda m = mol, s = self: s.update_from_object(m)) self.undo_stack.append(undo) def setz(self,z): """ Change the tye of the atom. If the atom is of type x then also change the bond length. """ undo = [] newElement = z_to_el[z] sel = self.sel() mols = sel.get_mols() for mol in mols: updated = None atoms = sel.get_by_mol(mol) for atom in atoms: if atom.symbol[0].lower() == 'x': # If it's an x atom, try and change the bond length # This check will change if we implement an 'update'mode func = mol.update_bond_distances( atom, newElement ) if func: mol.calculate_coordinates() undo.append( func ) undo.append( lambda m = mol : m.calculate_coordinates() ) # Change name and symbol - do this whether we've moved the atoms or no undo.append(lambda a = atom, oldsym = atom.symbol: a.set_symbol(oldsym)) undo.append(lambda a = atom, oldname = atom.name: a.set_name(oldname)) atom.symbol = atom.name = newElement self.update_from_object(mol) undo.append(lambda m = mol, s = self: s.update_from_object(m)) self.undo_stack.append(undo) def stopAM1Opt(self): """ Stop the AM1 Optimisation """ print "in stop am1" if not self.AM1Lock: print "Can't stop an optimisation that isn't running. Duh..." return got = self.AM1Lock.acquire() while not got: print "stopAM1Opt failed to get lock!" got = self.AM1Lock.acquire() print "Stopping AM1 optimisation thread." self.AM1Stop = 1 self.AM1Lock.release() return def change_bond_length(self, distance): """Change a bond length""" molecule = self.choose_mol() if not molecule: print "change_bond_length no molecule" return None sel = self.sel() atoms = sel.get_by_mol( molecule ) if len(atoms) != 2: print "Only select two atoms to define the axis!" return atom1 = atoms[0] atom2 = atoms[1] myundo = molecule.change_bond_length( atom1, atom2, distance ) if myundo: self.undo_stack.append([ myundo, lambda m = molecule, s = self: s.update_from_object(m) ]) self.update_from_object( molecule ) def rotate_about_bond(self,angle): """ Rotate a fragement about an axis defined by two atoms""" molecule = self.choose_mol() if not molecule: return None sel = self.sel() atoms = sel.get_by_mol( molecule ) if len(atoms) != 2: print "Only select two atoms to define the axis!" return atom1 = atoms[0] atom2 = atoms[1] molecule.rotate_about_bond( atom1, atom2, angle ) molecule.calculate_coordinates() self.update_from_object( molecule ) def sethyb(self,hyb): """Set hybridisation for the selected atoms Uses methods of the Zmatrix object """ undo = [] sel = self.sel() mols = sel.get_mols() for mol in mols: atoms = sel.get_by_mol(mol) old_list = copy.copy(mol.atom) old_bond = copy.deepcopy(mol.bond) #print 'check bonds saved' #for b in old_bond: # print b.index undo.append(lambda m = mol, oa = old_list: m.apply_atom_list(oa)) undo.append(lambda m = mol, ob = old_bond: m.apply_connect(ob)) undo.append(lambda m = mol: m.reindex()) undo.append(lambda m = mol: m.update_conn()) # End of undo code for atom in atoms: (code,msg) = mol.hybridise(atom,hyb) if code: self.error(msg) break self.update_from_object(mol) undo.append(lambda m = mol, s = self: s.update_from_object(m)) self.undo_stack.append(undo) def measure_dist(self): sel = self.sel() sel.printsel() dsel = sel.get() if len(dsel) != 2: self.error('Select 2 atoms for a bond') return m1,a1 = dsel[0] m2,a2 = dsel[1] if m1 != m2: self.error('Select 2 atoms in the same molecule') return val = m1.get_distance(a1,a2) tag = str(a1.get_index()+1) + ' - ' + str(a2.get_index()+1) return (tag,val) def measure_angle(self): sel = self.sel() sel.printsel() dsel = sel.get_ordered() if len(dsel) != 3: self.error('Select 3 atoms for an angle') return m1,a1 = dsel[0] m2,a2 = dsel[1] m3,a3 = dsel[2] val = m1.get_angle(a1,a2,a3) tag = str(a1.get_index()+1) + ' - ' + str(a2.get_index()+1) + ' - ' + str(a3.get_index()+1) return (tag,val) def measure_torsion(self): sel = self.sel() sel.printsel() dsel = sel.get_ordered() if len(dsel) != 4: self.error('Select 4 atoms for a torsion') return m1,a1 = dsel[0] m2,a2 = dsel[1] m3,a3 = dsel[2] m4,a4 = dsel[3] if m1 != m2 or m1 != m3 or m1 != m4: self.error('Select 4 atoms in the same molecule') return val = m1.get_dihedral(a1,a2,a3,a4) tag = str(a1.get_index()+1) + ' - ' + str(a2.get_index()+1) + ' - ' + str(a3.get_index()+1) + ' - ' + str(a4.get_index()+1) return (tag,val) def clean(self,clean_code): # see how many structures are loaded if self.debug: print "Clean got %s structures" % len(self.data_list) # Get the selected molecule - just one for now molecule = self.choose_mol() if not molecule: return 0 self.start_clean_calced(molecule,clean_code) calced = self.clean_calced[clean_code] calc = calced.calc calc.set_input('mol_obj',molecule) print 'cleaning mol' molecule.list() calced.update_func = lambda o,s=self,t=str(id(molecule)) : s.update_model(t,o) calced.Run() def clean_opts(self,clean_code): # see how many structures are loaded print len(self.data_list) mol = self.data_list[0] self.start_clean_calced(mol,clean_code) # these are simplified invocations, no callbacks, reload_func etc # we pass None as the graph argument which means there is no dialog box # when the calculation finishes (or fails....) # would be better to trap errors really... calced = self.clean_calced[clean_code] calced.show() def start_clean_calced(self,mol,clean_code): # these are simplified invocations, no callbacks, reload_func etc # we pass None as the graph argument which means there is no dialog box # when the calculation finishes (or fails....) # would be better to trap errors really... root = self.master if not self.clean_calced.has_key(clean_code): if clean_code == 'AM1 (built-in)': calc = interfaces.am1calc.AM1Calc() calc.set_input('mol_obj',mol) ed = interfaces.am1calc.AM1CalcEd(root,calc,self,job_editor=self.job_editor) elif clean_code == 'MNDO': calc = MNDOCalc() calc.set_input('mol_obj',mol) calc.set_parameter('task',MENU_OPT) ed = MNDOCalcEd(root,calc,None,job_editor=self.job_editor) elif clean_code == 'MOPAC': calc = MopacCalc() calc.set_input('mol_obj',mol) calc.set_parameter('task',"optimise") ed = MopacCalcEd(root,calc,None,job_editor=self.job_editor) elif clean_code == 'GAMESS-UK': calc = GAMESSUKCalc() calc.set_input('mol_obj',mol) calc.set_parameter('task',MENU_OPT) calc.set_parameter('symmetry',0) ed = GAMESSUKCalcEd(root,calc,None,job_editor=self.job_editor) elif clean_code == 'UFF': calc = ChemShellCalc() calc.set_input('mol_obj',mol) calc.set_parameter('calctype','MM') calc.set_parameter('task','optimise') ed = ChemShellCalcEd(root,calc,None,job_editor=self.job_editor) # when the window is closed, we want to keep the editor alive # to save options between runs ed.userdeletefunc(lambda: ed.withdraw()) ed.withdraw() self.clean_calced[clean_code] = ed def addfrag(self,frag): """Add a fragment to the selected molecule non-trivial, because the process deletes (and replaces at the end) the selected atom, which may be referred to by other atoms ... multiple additions particularly troublesome. perhaps a replace_atom function could cover this? we need to do a deepcopy to make sure that each time we use a fragment we dont corrupt the template some atoms (e.g. the 1st 3) don't have the required internal coordinates anyway, so we will need to make them up, which may imply atom reordering lots of -998's (means i1,i2,i3 unexpectedly None) showing up also see zmatrix.py: #.....assumption that i1 is set is not generally safe if replacement atom has a known cartesian position, it shouldn't actually be necessary to generate one (maybe update a distance?) we need to resolve question of which connectivity representation is up-to-date at any point in time ... perhaps best strategy is to define API also suggests value of saving the internals for all atoms to a file, even if they are not being used - quite a big change! should change interface to menubutton + a button to activate. could usefully have a selection window that takes wild cards, and also equivalencies (z=12, symbol=c*) etc, parse to regex module on an atom-by atom basis, perhaps one window, with and/or relationships between them. could use some exceptions (e.g. atom is not in molecule..) """ sel = self.sel() undo = [] for mol in sel.get_mols(): atoms = sel.get_by_mol(mol) for atom in atoms: l1 = len(mol.atom) oa = atom ia = atom.get_index() (code,msg) = mol.add_fragment(atom,frag) if code: self.error(msg) break l2 = len(mol.atom) undo.append(lambda m = mol, i = ia, na = l2-l1: mol.remove_fragment(ia,oa,na)) self.update_from_object(mol) undo.append(lambda m = mol, s = self: s.update_from_object(m)) self.undo_stack.append(undo) def select_all(self): # First build a list of structures mols = self.loaded_mols() self.sel().clear() for m in mols: self.sel().append(m,m.atom) def select_by_distance_to_selected(self): """Uses distance to any selected atom""" sel = self.sel() dsel = sel.get() print 'dsel', dsel if not len(dsel): return res = self.distance_dialog.activate() if res == 'OK': val = float(self.distance_dialog.w_val.get()) else: return mol,atom = dsel[0] r2test = val*val print r2test, dsel set = [] print 'Selected Atoms' reslist = [] for a in mol.atom: for mol2,atom2 in dsel: if mol2 == mol: ori = atom2.coord r2 = ( (ori[0]-a.coord[0])*(ori[0]-a.coord[0]) + \ (ori[1]-a.coord[1])*(ori[1]-a.coord[1]) + \ (ori[2]-a.coord[2])*(ori[2]-a.coord[2]) ) if r2 < r2test: set.append(a) try: resno = a.resno try: ix = reslist.index(resno) except ValueError: reslist.append(resno) print a.get_index(), " ", a.resno, a.symbol, math.sqrt(r2) except AttributeError: print a.get_index(), " ", a.symbol, math.sqrt(r2) break else: print 'CANT PROCESS MULTIPLE MOLECULES' return sel.clear() print 'residues selected',reslist print 'Total number of atoms selected',len(set) #print 'set',set sel.append(mol,set) self.update_zme_sel() self.update() def select_by_distance_to_point(self): """Uses distance to a point (by default it is at the centroid of the selection)""" sel = self.sel() dsel = sel.get() print 'dsel', dsel if len(dsel): ori = sel.get_centroid() self.distance_dialog2.x.setentry(ori[0]) self.distance_dialog2.y.setentry(ori[1]) self.distance_dialog2.z.setentry(ori[2]) mol,atom = dsel[0] else: # no selection mol = self.choose_mol() self.distance_dialog2.x.setentry(0.0) self.distance_dialog2.y.setentry(0.0) self.distance_dialog2.z.setentry(0.0) res = self.distance_dialog2.activate() if res == 'OK': val = float(self.distance_dialog2.w_val.get()) ori = [ float(self.distance_dialog2.x.get()), float(self.distance_dialog2.y.get()), float(self.distance_dialog2.z.get())] else: return r2test = val*val print ori, r2test, dsel set = [] print 'Selected Atoms' reslist = [] for a in mol.atom: r2 = ( (ori[0]-a.coord[0])*(ori[0]-a.coord[0]) + \ (ori[1]-a.coord[1])*(ori[1]-a.coord[1]) + \ (ori[2]-a.coord[2])*(ori[2]-a.coord[2]) ) if r2 < r2test: set.append(a) try: resno = a.resno try: ix = reslist.index(resno) except ValueError: reslist.append(resno) print a.get_index(), " ", a.resno, a.symbol, math.sqrt(r2) except AttributeError: print a.get_index(), " ", a.symbol, math.sqrt(r2) sel.clear() print 'residues selected',reslist print 'Total number of atoms selected',len(set) #print 'set',set sel.append(mol,set) self.update_zme_sel() self.update() def select_by_distance_to_point_and_trim(self): """Uses distance to a point (by default it is at the centroid of the selection)""" sel = self.sel() dsel = sel.get() print 'dsel', dsel if len(dsel): ori = sel.get_centroid() self.distance_dialog2.x.setentry(ori[0]) self.distance_dialog2.y.setentry(ori[1]) self.distance_dialog2.z.setentry(ori[2]) mol,atom = dsel[0] else: # no selection mol = self.choose_mol() self.distance_dialog2.x.setentry(0.0) self.distance_dialog2.y.setentry(0.0) self.distance_dialog2.z.setentry(0.0) res = self.distance_dialog2.activate() if res == 'OK': val = float(self.distance_dialog2.w_val.get()) ori = [ float(self.distance_dialog2.x.get()), float(self.distance_dialog2.y.get()), float(self.distance_dialog2.z.get())] else: return r2test = val*val print ori, r2test, dsel set = [] print 'Selected Atoms' reslist = [] mols = self.loaded_mols() for mol in mols: for a in mol.atom: r2 = ( (ori[0]-a.coord[0])*(ori[0]-a.coord[0]) + \ (ori[1]-a.coord[1])*(ori[1]-a.coord[1]) + \ (ori[2]-a.coord[2])*(ori[2]-a.coord[2]) ) if r2 < r2test: set.append(a) try: resno = a.resno try: ix = reslist.index(resno) except ValueError: reslist.append(resno) print a.get_index(), " ", a.resno, a.symbol, math.sqrt(r2) except AttributeError: print a.get_index(), " ", a.symbol, math.sqrt(r2) sel.clear() print 'residues selected',reslist print 'Total number of atoms selected',len(set) #print 'set',set sel.append(mol,set) self.update_zme_sel() # Now update all images based on the new selections for v in self.vis_list: try: v.draw_by_selection() except AttributeError: pass self.update() def sel(self): """Return the selection manager for use in other modules""" global sel return sel def select_connected(self): # First build a list of structures sel = self.sel() dsel = sel.get() print 'dsel', dsel edited = [] for mol in sel.get_mols(): set = sel.get_by_mol(mol) set2 = copy.copy(set) for a in set2: for b in a.conn: if b in set: pass else: set.append(b) sel.append(mol,set) def select_by_bonds(self): # First build a list of structures sel = self.sel() dsel = sel.get() print 'dsel', dsel edited = [] for mol in sel.get_mols(): for a in mol.atom: a.tmp = 0 set = sel.get_by_mol(mol) for a in set: a.tmp = 1 more = 1 while more: more = 0 for a in mol.atom: if a.tmp == 1: a.tmp = 2 for b in a.conn: if b.tmp == 0: b.tmp = 1 more=1 set = [] for a in mol.atom: if a.tmp: set.append(a) #sel.clear() sel.append(mol,set) def ViewMenu(self): mbutton = self.menuBar.component('Views-button') #mbutton = Menubutton(self.mBar, text="Views", underline=0) #mbutton.pack(side=LEFT, padx="2m") menu = Menu(mbutton, tearoff=0, postcommand=self.post_view) self.view_menu=menu mbutton['menu'] = menu return mbutton def post_view(self): menu = self.view_menu menu.delete(0,Tkinter.AtEnd()) greyedfont = ("Helvetica", 9, "normal") showfont = ("Helvetica", 9, "bold") # Create the Menu Item to Alter all molecules # First instantiate the visualiser if it doesn't exist if not self.allmolecule_visualiser: # Need to import this here because the others are set up in vtkgraph.py but we are different # because we are not tied to a single image and so have no vtk-specific code from generic.visualiser import AllMoleculeVisualiser self.allmolecule_visualiser = AllMoleculeVisualiser( self.master, self ) # update_mol_list returns None if no molecules to display if self.allmolecule_visualiser.update_mol_list(): menu.add_command(label="Adust All Molecules", underline=0, font=showfont, command = lambda s=self : s.adjust_allmolc(1) ) else: menu.add_command(label="Adust All Molecules", underline=0, font=greyedfont, command = lambda s=self : s.adjust_allmolc(0) ) if ( len( self.vis_list ) >= 1 ): myfont = showfont else: myfont = greyedfont menu.add_command(label="Show All", underline=0, font=myfont, command=lambda x=self : x.showall(1)) menu.add_command(label="Hide All", underline=0, font=myfont, command=lambda x=self : x.showall(0)) # menu.add_separator() # menu.add_command(label="Animation...", underline=0, font=myfont, # command=lambda x=self : x.pack_ani_toolbar()) menu.add_separator() menu.add_command(label="Centre on Selected", underline=0, command=lambda x=self : x.centre_on_selected()) menu.add_separator() for obj in self.data_list: # one submenu for each object cascade = Menu(menu,tearoff=0) t = id(obj) show=0 built=0 try: visl = self.vis_dict[t] built=1 for vis in visl: if vis.IsShowing(): show=1 except KeyError: pass if show: myfont=("Helvetica", 9, "bold") else: myfont=("Helvetica", 9, "normal") if obj.name is not None: name = obj.name else: name = obj.title menu.add_cascade(label=name, font=myfont,menu=cascade) t = id(obj) if built: for vis in visl: if vis.IsShowing(): txt = "Hide " + vis.GetTitle() cascade.add_command(label=txt, underline=0,command=lambda x=vis: x.Hide()) else: txt = "Show " + vis.GetTitle() cascade.add_command(label=txt, underline=0,command=lambda x=vis: x.Show()) txt = "Adjust " + vis.GetTitle() cascade.add_command(label=txt, command= lambda x=vis : x.Open()) cascade.add_separator() # # build menu of options, note double lambda form.... # inner lambda wraps up the call to the visualiser with any arguments # that are needed (these are visualiser-specific) # outer lambda passes this function to self.visualise, which # creates the visualiser, and also registers it in self.vis_dict # myclass=obj.GetClass() #print 'MYCLASS',myclass if myclass == 'Indexed' or myclass == 'Zmatrix': if self.molecule_visualiser: cascade.add_command( label="New Molecule View",command=\ lambda s=self,obj=obj: s.visualise(obj,'molecule',open_widget=1)) if myclass == 'ZmatrixSequence': if self.trajectory_visualiser: cascade.add_command( label="New Trajectory View",command=\ lambda s=self,obj=obj: s.visualise(obj,'trajectory',open_widget=1)) if myclass == 'Field' : if obj.dimensions() == 3: if obj.ndd == 1: # scalar visualiser tools cascade.add_command( label="New Orbital View",command=\ lambda s=self,obj=obj: s.visualise(obj,'orbital',open_widget=1)) cascade.add_command( label="New Density View",command=\ lambda s=self,obj=obj: s.visualise(obj,'density',open_widget=1)) cascade.add_command( label="Density Volume Visualisation View",command=\ lambda s=self,obj=obj: s.visualise(obj,'volume_density',open_widget=1)) cascade.add_command( label="Orbital Volume Visualisation View",command=\ lambda s=self,obj=obj: s.visualise(obj,'volume_orbital',open_widget=1)) cascade.add_command( label="New Cut Slice View",command=\ lambda s=self,obj=obj: s.visualise(obj,'cut_slice',open_widget=1)) cascade.add_command( label="New Colour Surface View",command=\ lambda s=self,obj=obj: s.visualise(obj,'colour_surface',open_widget=1)) if obj.dimensions() == 2: if self.slice_visualiser: cascade.add_command( label="New 2D View",command=\ lambda s=self,obj=obj: s.visualise(obj,'slice',open_widget=1)) #print 'ndd',obj.ndd if obj.ndd == 3: if self.vector_visualiser: cascade.add_command( label="Vector Visualisation View",command=\ lambda s=self,obj=obj: s.visualise(obj,'vector',open_widget=1)) else: if self.irregular_data_visualiser: cascade.add_command( label="New Grid View",command=\ lambda s=self,obj=obj: s.visualise(obj,'irregular_data',open_widget=1)) if myclass == 'VibFreq' : if self.vibration_visualiser: cascade.add_command( label="Animate Vibration",command=\ lambda s=self,obj=obj: s.visualise(obj,'vibration',open_widget=1)) if myclass == 'VibFreqSet' : if self.vibration_set_visualiser: cascade.add_command( label="Animate",command=\ lambda s=self,obj=obj: s.visualise(obj,'vibration_set',open_widget=1)) if myclass == 'File' and obj.MoldenReadable() : if self.wavefunction_visualiser: cascade.add_command( label="Run Molden",command=\ lambda s=self,obj=obj: s.visualise(obj,'wavefunction',open_widget=1)) if myclass == 'Dl_PolyHISTORYFile': if self.trajectory_visualiser: cascade.add_command( label="New Trajectory View",command=\ lambda s=self,obj=obj: s.visualise(obj,'dlpoly_trajectory',open_widget=1)) def add_vis_menu(self,menu,txt,fnc,objects): """ make a list of objects that can be visualised in a particular way """ if len(objects) == 0: menu.add_command(label=txt, underline=0,state="disabled") elif len(objects) == 1: menu.add_command(label=txt, underline=0, command=lambda f=fnc,s=self,o=objects[0]: s.visualise(o,visualiser=f)) else: cascade = Menu(menu,tearoff=0) menu.add_cascade(label=txt, menu=cascade) for obj in objects: if obj.name is not None: name = obj.name else: name = obj.title cascade.add_command(label=obj.name, command=lambda f=fnc,s=self,o=obj: s.visualise(o,visualiser=f)) def add_obj_cmd(self,menu,txt,fnc): """Loop over all objects and build a submenu """ mols = self.data_list if len(mols) == 0: menu.add_command(label=txt, underline=0,state="disabled") elif len(mols) == 1: menu.add_command(label=txt, underline=0, command=lambda f=fnc,o=mols[0] : f(o)) else: cascade = Menu(menu,tearoff=0) menu.add_cascade(label=txt, menu=cascade) for obj in mols: cascade.add_command(label=obj.name, command= lambda f=fnc,o=obj : f(o)) def adjust_allmolc(self, show): """Display the widget to adjust all the molecule representations together if we have any molecules to adjust """ if ( show == 1 ): self.allmolecule_visualiser.Open() else: if self.allmolecule_visualiser.dialog: self.allmolecule_visualiser.dialog.withdraw() else: pass def showall(self,show): for o in self.vis_list: if show: o.Show() else: o.Hide() def centre_on_selected(self): if len(self.sel().get()): self.set_origin(self.sel().get_centroid()) ## def VisualiseMenu(self): ## mbutton = Menubutton(self.mBar, text='Visualise', underline=0) ## mbutton.pack(side=LEFT, padx="2m") ## menu = Menu(mbutton, tearoff=0, postcommand=self.post_vis) ## self.visualiser_menu=menu ## mbutton['menu'] = menu ## return mbutton def ComputeMenu(self): #mbutton = Menubutton(self.mBar, text='Compute', underline=0) #mbutton.pack(side=LEFT, padx="2m") mbutton = self.menuBar.component('Compute-button') self.compute_menu=Menu(mbutton, tearoff=0, postcommand=self.post_compute_menu) mbutton['menu'] = self.compute_menu return mbutton def post_compute_menu(self): menu = self.compute_menu menu.delete(0,Tkinter.AtEnd()) # First build a list of structures mols = self.loaded_mols() ###menu.add_command(label="Test", underline=0, command=self.testcmd2) self.add_mol_cmd(menu,mols,"GAMESS-UK",self.gamessuk_calced) self.add_mol_cmd(menu,mols,"MOLPRO",self.molpro_calced) self.add_mol_cmd(menu,mols,"MNDO",self.mndo_calced) self.add_mol_cmd(menu,mols,"Dalton",self.dalton_calced) self.add_mol_cmd(menu,mols,"Mopac",self.mopac_calced) self.add_mol_cmd(menu,mols,"ChemShell",self.chemshell_calced) self.add_mol_cmd(menu,mols,"SMEAGOL",self.smeagol_calced) def add_mol_cmd(self,menu,mols,txt,fnc,all=0): if len(mols) == 0: menu.add_command(label=txt, underline=0,state="disabled") elif len(mols) == 1: menu.add_command(label=txt, underline=0, command=lambda f=fnc,o=mols[0] : f(o)) else: cascade = Menu(menu,tearoff=0) if all: cascade.add_command(label='All', command= lambda f=fnc,o=None : f(o,all=1)) cascade.add_separator() menu.add_cascade(label=txt, menu=cascade) for obj in mols: cascade.add_command(label=obj.name, command= lambda f=fnc,o=obj : f(o)) def add_mol_seq_cmd(self,menu,mols,txt,fnc,all=0): if len(mols) == 0: menu.add_command(label=txt, underline=0,state="disabled") elif len(mols) == 1: menu.add_command(label=txt, underline=0, command=lambda f=fnc,o=mols[0] : f(o)) else: cascade = Menu(menu,tearoff=0) if all: cascade.add_command(label='All', command= lambda f=fnc,o=None : f(o,all=1)) cascade.add_separator() menu.add_cascade(label=txt, menu=cascade) for obj in mols: cascade.add_command(label=obj.name, command= lambda f=fnc,o=obj : f(o)) def add_field_cmd(self,menu,fields,txt,fnc): if len(fields) == 0: menu.add_command(label=txt, underline=0,state="disabled") elif len(fields) == 1: menu.add_command(label=txt, underline=0, command=lambda f=fnc,o=fields[0] : f(o)) else: cascade = Menu(menu,tearoff=0) menu.add_cascade(label=txt, menu=cascade) for obj in fields: cascade.add_command(label=obj.name, command= lambda f=fnc,o=obj : f(o)) def testcmd(self): """ this can be used to explore problems with threads etc """ job = BackgroundJob() job.add_step(RUN_APP,'test cmd',local_command="cmdx.exe") job.run() def testcmd2(self): job = BackgroundJob() job.add_step(RUN_APP,'test cmd',local_command="cmdx.exe") self.job_editor.manager.RegisterJob(job) self.job_editor.show() self.job_thread = JobThread(job) try: self.job_thread.start() except RuntimeError,e: print 'exception' self.error(str(e)) #print 'job done' def DebugMenu(self): #mbutton = Menubutton(self.mBar, text='Debug', underline=0) #mbutton.pack(side=LEFT, padx="2m") mbutton = self.menuBar.component('Debug-button') menu = Menu(mbutton, tearoff=0, postcommand=self.post_debug_menu) self.debug_menu=menu mbutton['menu'] = menu return mbutton def post_debug_menu(self): menu = self.debug_menu menu.delete(0,Tkinter.AtEnd()) menu.add_command(label='Debug Window', underline=0, command=lambda x=self: x.open_debug_window()) #menu.add_separator() def ShellMenu(self): #mbutton = Menubutton(self.mBar, text='Debug', underline=0) #mbutton.pack(side=LEFT, padx="2m") mbutton = self.menuBar.component('Shell-button') menu = Menu(mbutton, tearoff=0, postcommand=self.post_shell_menu) self.shell_menu=menu mbutton['menu'] = menu return mbutton def post_shell_menu(self): menu = self.shell_menu menu.delete(0,Tkinter.AtEnd()) menu.add_command(label='Idle Shell', underline=0, command=lambda x=self: x.idleShell()) menu.add_command(label='iPython Shell', underline=0, command=lambda x=self: x.iPythonShell()) #menu.add_separator() def open_debug_window(self): deb_setwidget(self.debug_window.text) self.debug_window.deiconify() def HelpMenu(self): """Create the help menu """ self.toggleBalloonVar = IntVar() self.toggleBalloonVar.set(1) # self.setting = Setting() mbutton = self.menuBar.component('Help-button') menu = self.menuBar.component('Help-menu') # temporarily use an explicitly created menu to avoid # error messages from ballon help #self.help_menu=Menu(mbutton, tearoff=0, postcommand=self.post_compute_menu) self.menuBar.addmenuitem('Help', 'checkbutton', 'Toggle balloon help', label='Balloon help', variable = self.toggleBalloonVar, command=self.toggleBalloon) self.menuBar.addmenuitem('Help', 'command', 'Introduction', label='Introductory Documentation', command = lambda s=self, lab="Introduction": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'separator', '') self.menuBar.addmenuitem('Help', 'command', 'File Menu', label='Help on File Menu', command = lambda s=self, lab="File Menu": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'command', 'Edit Menu', label='Help on Edit Menu', command = lambda s=self, lab="Edit Menu": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'command', 'Views Menu', label='Help on Views Menu', command = lambda s=self, lab="View Menu": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'command', 'Compute Menu', label='Help on Compute Menu', command = lambda s=self, lab="Compute Menu": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'command', 'Shell Menu', label='Help on Shell Menu', command = lambda s=self, lab="Shell Menu": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'separator', '') self.menuBar.addmenuitem('Help', 'command', 'Key Bindings', label='Key Bindings', command = lambda s=self, lab="Key Bindings": s.showhelp(lab)) self.menuBar.addmenuitem('Help', 'separator', '') self.menuBar.addmenuitem('Help', 'command', 'About', label='About', command = self.about) def showhelp(self,lab): """Call on the help modlue to open a browser or display a widget with the help. """ htmlfile,txtfile = viewer.help.getfiles(lab) viewer.help.displayhelp(htmlfile,txtfile, lab) def toggleBalloon(self): # from abstractapp if self.toggleBalloonVar.get(): #self.__balloon.configure(state = 'both') self.balloon.configure(state = 'both') else: #self.__balloon.configure(state = 'status') self.balloon.configure(state = 'status') # # The following bit of code is very similar to that # used in the calculation editor to control the visualisation # of results # def open_visualise_window(self): """Open a new window with all the graphics controls """ self.__update_data_list() self.data_dialog.show() def quick_obj_view(self,objects, toview, noshow=None, open=None): """Create a default image of those supplied object(s) that are of the type listed in the toview list (or string) and include them in the tables (vis_dict, vis_list) Then attempt to fit everything on screen The open flag determines whether we open the visualiser dialogue Use the noshow flag to build but not show the objects - this is needed where we read a long list of objects into the gui but don't want to render them initially """ if type(objects) != list: objects=[objects] if type(toview) != list: toview=[toview] visdict={} # dict mapping objects to visualisers if 'molecule' in toview: for obj in objects: myclass=obj.GetClass() if myclass == 'Zmatrix' or myclass == 'Zmatrix': visdict[obj] = self.get_visualiser( obj, 'molecule' ) if 'trajectory' in toview: for obj in objects: if obj.GetClass() == 'ZmatrixSequence': visdict[obj] = self.get_visualiser( obj, 'trajectory' ) if 'vibration_set' in toview: for obj in objects: if obj.GetClass() == 'VibFreqSet': visdict[obj] = self.get_visualiser( obj, 'vibration_set' ) for obj,vis in visdict.items(): t = id(obj) self.vis_dict[t] = [vis] self.vis_list.append(vis) self.__update_vis_list() if noshow: vis._build(object=obj) else: vis.Show(update=0) if open: vis.Open() self.fit_to_window() def build_distance_dialog(self,include_xyz=0): """Create a dialog which we will use to determine distances """ dialog = Pmw.Dialog(self.master, title='Enter Distance', buttons = ('OK','Cancel')) labels = [] dialog.withdraw() i = dialog.interior() if include_xyz: grp = Pmw.Group(i,tag_text = 'Reference Position') ig = grp.interior() dialog.x = Pmw.Counter( ig, labelpos = 'w', label_text = 'x', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'real' }) dialog.x.pack(expand='yes',fill='x',side='left') dialog.y = Pmw.Counter( ig, labelpos = 'w', label_text = 'y', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'real' }) dialog.y.pack(expand='yes',fill='x',side='left') dialog.z = Pmw.Counter( ig, labelpos = 'w', label_text = 'z', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'real' }) dialog.z.pack(expand='yes',fill='x',side='left') grp.pack(expand='yes',fill='x',side='top') d = {'counter' : 'real' } dialog.w_val = Pmw.Counter( i, datatype=d, labelpos = 'w', label_text = 'd = ', increment = 0.5, entryfield_entry_width = 10, entryfield_value = 1.0, entryfield_validate = { 'validator' : 'real' }) dialog.w_val.pack(expand='yes',fill='x',side='top') if include_xyz: self.distance_dialog2 = dialog else: self.distance_dialog = dialog def build_extend_dialog(self): """Create a dialog which we will use to determine extent of periodic images represented """ self.extend_dialog = Pmw.Dialog(self.master, title='Extend', buttons = ('OK','Cancel')) labels = [] self.extend_dialog.withdraw() i = self.extend_dialog.interior() self.extend_dialog.fx = Pmw.Group(i,tag_text = 'X range') self.extend_dialog.fy = Pmw.Group(i,tag_text = 'Y range') self.extend_dialog.fz = Pmw.Group(i,tag_text = 'Z range') self.extend_dialog.minx = Pmw.Counter( self.extend_dialog.fx.interior(), labelpos = 'w', label_text = 'min', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.minx.pack(expand='yes',fill='x',side='left') self.extend_dialog.maxx = Pmw.Counter( self.extend_dialog.fx.interior(), labelpos = 'w', label_text = 'max', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.maxx.pack(expand='yes',fill='x',side='left') labels = labels + [self.extend_dialog.fx] self.extend_dialog.miny = Pmw.Counter( self.extend_dialog.fy.interior(), labelpos = 'w', label_text = 'min', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.miny.pack(expand='yes',fill='x',side='left') self.extend_dialog.maxy = Pmw.Counter( self.extend_dialog.fy.interior(), labelpos = 'w', label_text = 'max', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.maxy.pack(expand='yes',fill='x',side='left') labels = labels + [self.extend_dialog.fy] self.extend_dialog.minz = Pmw.Counter( self.extend_dialog.fz.interior(), labelpos = 'w', label_text = 'min', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.minz.pack(expand='yes',fill='x',side='left') self.extend_dialog.maxz = Pmw.Counter( self.extend_dialog.fz.interior(), labelpos = 'w', label_text = 'max', increment = 1, entryfield_entry_width = 6, entryfield_value = 0, entryfield_validate = { 'validator' : 'integer' }) self.extend_dialog.maxz.pack(expand='yes',fill='x',side='left') labels = labels + [self.extend_dialog.fz] self.extend_dialog.fx.pack(expand='yes',fill='x',side='top') self.extend_dialog.fy.pack(expand='yes',fill='x',side='top') self.extend_dialog.fz.pack(expand='yes',fill='x',side='top') Pmw.alignlabels(labels) def build_data_dialog(self): """Create a dialog which we will use to visualise objects as read in from files """ self.data_dialog = Pmw.MegaToplevel( title='Visualise') self.data_dialog.withdraw() self.sel_height = 10 self.data_dialog.listbox = Pmw.ScrolledListBox( self.data_dialog.interior(), listbox_selectmode='extended', listbox_height=self.sel_height, selectioncommand=self.__click_result) self.data_dialog.listbox.pack(expand = 1, fill='x') self.data_dialog.buttonbox = Pmw.ButtonBox(self.data_dialog.interior()) self.data_dialog.buttonbox.add('Options',command = self.__data_options) self.data_dialog.buttonbox.add('Show',command = self.__data_show) self.data_dialog.buttonbox.add('Hide',command = self.__data_hide) self.data_dialog.buttonbox.add('Connect',command = self.__data_connect) self.data_dialog.buttonbox.add('Edit',command = self.__data_edit) self.data_dialog.buttonbox.add('Delete',command = self.__data_destroy) self.data_dialog.buttonbox.pack(expand = 1, fill='x') def __update_data_list(self): # load a list of the result objects into the selector self.data_dialog.listbox.delete(0,'end') if not len(self.data_list): self.data_dialog.listbox.insert(Tkinter.AtEnd(), 'No Results Yet') else: for r in self.data_list: txt = r.name + ' ; ' + r.title self.data_dialog.listbox.insert(Tkinter.AtEnd(), txt) def __click_result(self): cursel = self.data_dialog.listbox.curselection() nsel = len(cursel) sels = self.data_dialog.listbox.getcurselection() print 'click results', sels def __data_options(self): self.__control_data('Options') def __data_show(self): self.__control_data('Show') def __data_hide(self): self.__control_data('Hide') def __data_connect(self): cursel = self.data_dialog.listbox.curselection() targets = [] for sel in cursel: ix = int(sel) if ix < len(self.data_list): targets.append(ix) for ix in targets: o = self.data_list[ix] myclass=o.GetClass() if myclass == 'Indexed': self.connect_model(o) elif myclass == 'Zmatrix': self.connect_model(o) else: print 'cant connect (not a molecule)' def __data_edit(self): cursel = self.data_dialog.listbox.curselection() targets = [] for sel in cursel: ix = int(sel) if ix < len(self.data_list): targets.append(ix) for ix in targets: o = self.data_list[ix] myclass=o.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': self.edit_coords(o) else: print 'cant edit (not a molecule)' def __data_destroy(self): """Deletion of the selected objects from the listbox""" cursel = self.data_dialog.listbox.curselection() temp = [] for res in self.data_list: temp.append(1) for sel in cursel: ix = int(sel) if ix < len(self.data_list): o = self.data_list[ix] t = id(o) try: visl = self.vis_dict[t] for vis in visl: vis.delete() except KeyError: pass temp[ix] = 0 newres = [] for ix in range(len(self.data_list)): if temp[ix]: newres.append(self.data_list[ix]) self.data_list = newres self.__update_data_list() self.__update_vis_list() def __control_data(self,cmd): """Handles processing of controls for a selection of calculation results. Creates a visualisation object if not already defined """ cursel = self.data_dialog.listbox.curselection() targets = [] for sel in cursel: ix = int(sel) if ix < len(self.data_list): targets.append(ix) for ix in targets: o = self.data_list[ix] t = id(o) try: visl = self.vis_dict[t] except KeyError: # There is no visualiser, try and make one # take the last field of the class specification vis = self.visualise(o) visl = [ vis ] for vis in visl: if cmd == 'Hide': if vis: vis.Hide() elif cmd == 'Show': if vis: vis.Show() if cmd == 'Options': if vis: vis.Open() def visualise(self, object, visualiser ,open_widget=0 ): """Visualise object with the type of visualiser specified with the visualiser argument. The visualiser argument can either be a string specifying the visualiser or a visualiser instance. """ # If it's not a string we assume it's a visualiser if type(visualiser) != types.StringType: visualiser=visualiser else: visualiser=self.get_visualiser(object,visualiser) myclass=object.GetClass() t = id(object) try: x = self.vis_dict[t] self.vis_dict[t].append(visualiser) except KeyError: self.vis_dict[t] = [visualiser] if open_widget: visualiser.Open() self.vis_list.append(visualiser) self.__update_vis_list() # to get correct view/show/hide # self.__update_data_list() visualiser.Show() return visualiser def get_visualiser(self, object, vistype ): """Return a visualiser of type vistype for viewing the supplied object. """ if vistype == 'molecule': visualiser=self.molecule_visualiser(self.master,self,object) elif vistype == 'trajectory': visualiser=self.trajectory_visualiser(self.master,self,object) elif vistype == 'orbital': visualiser=self.orbital_visualiser(self.master,self,object) elif vistype == 'density': visualiser=self.density_visualiser(self.master,self,object) elif vistype == 'volume_density': visualiser=self.volume_density_visualiser(self.master,self,object) elif vistype == 'volume_orbital': visualiser=self.volume_orbital_visualiser(self.master,self,object) elif vistype == 'cut_slice': visualiser=self.cut_slice_visualiser(self.master,self,object) elif vistype == 'colour_surface': visualiser=self.colour_surface_visualiser(self.master,self,object) elif vistype == 'slice': visualiser=self.slice_visualiser(self.master,self,object) elif vistype == 'vector': visualiser=self.vector_visualiser(self.master,self,object) elif vistype == 'irregular_data': visualiser=self.irregular_data_visualiser(self.master,self,object) elif vistype == 'vibration': visualiser=self.vibration_visualiser(self.master,self,object) elif vistype == 'vibration_set': visualiser=self.vibration_set_visualiser(self.master,self,object) elif vistype == 'wavefunction': visualiser=self.wavefunction_visualiser(self.master,self,object) elif vistype == 'dlpoly_trajectory': visualiser=self.trajectory_visualiser(self.master,self,object,type='DLPOLYHISTORY') else: raise KeyError("No visualiser of type: %s found!" % vistype) return visualiser def graphics(self): """Open a new window with all the graphics controls """ self.__update_vis_list() self.vis_dialog.show() def build_vis_dialog(self): """Create a dialog which we will use to control the visibility and parameters of the objects in the viewer """ self.vis_dialog = Pmw.MegaToplevel( title='visualisation options') self.vis_dialog.withdraw() self.sel_height = 10 self.vis_dialog.listbox = Pmw.ScrolledListBox( self.vis_dialog.interior(), listbox_selectmode='extended', listbox_height=self.sel_height, selectioncommand=self.__click_result) self.vis_dialog.listbox.pack(expand = 1, fill='x') self.vis_dialog.buttonbox = Pmw.ButtonBox(self.vis_dialog.interior()) self.vis_dialog.buttonbox.add('Options',command = self.__vis_options) self.vis_dialog.buttonbox.add('Show',command = self.__vis_show) self.vis_dialog.buttonbox.add('Hide',command = self.__vis_hide) self.vis_dialog.buttonbox.add('Delete',command = self.__vis_destroy) self.vis_dialog.buttonbox.pack(expand = 1, fill='x') def __update_vis_list(self): """load a list of the current visualiser objects into the selector""" self.vis_dialog.listbox.delete(0,'end') if not len(self.vis_list): self.vis_dialog.listbox.insert(Tkinter.AtEnd(), 'No Graphics Yet') else: for r in self.vis_list: txt = r.GetTitle() self.vis_dialog.listbox.insert(Tkinter.AtEnd(), txt) def __click_vis(self): cursel = self.vis_dialog.listbox.curselection() nsel = len(cursel) sels = self.vis_dialog.listbox.getcurselection() print 'click results', sels def __vis_options(self): self.__control_vis('Options') def __vis_show(self): self.__control_vis('Show') def __vis_hide(self): self.__control_vis('Hide') def __vis_destroy(self): """Deletion of the selected objects from the listbox""" cursel = self.vis_dialog.listbox.curselection() temp = [] for res in self.vis_list: temp.append(1) for sel in cursel: # this code is wrong - fortunately not used at present ix = int(sel) vis = self.vis_list[ix] for x in self.vis_dict.keys(): if self.vis_dict[x] == vis: del self.vis_dict[x] vis.delete() temp[ix] = 0 newvis=[] for ix in range(len(self.vis_list)): if temp[ix]: newvis.append(self.vis_list[ix]) self.vis_list = newvis self.__update_vis_list() def __control_vis(self,cmd): """Handles processing of controls for a visualiser""" cursel = self.vis_dialog.listbox.curselection() targets = [] for sel in cursel: ix = int(sel) vis = self.vis_list[ix] if cmd == 'Hide': vis.Hide() elif cmd == 'Show': vis.Show() if cmd == 'Options': vis.Open() def setscale(self): scale=askfloat(title='Set scale', prompt='Scale', initialvalue=self.grid.scale, minvalue=0.1, maxvalue=100.0) self.setscale(scale) def bgcolor(self): color=tkColorChooser.askcolor() self.setbgcolor(color[0]) def fgcolor(self): color=tkColorChooser.askcolor() self.setfgcolor(color[0]) def colorheight(self): self.setheightcolor() def ask_load_from_file(self): """Ask for a file to load structure from""" # Only do this once if not self.getfileIO: self.getfileIO = GetFileIO() # Build up the list of tuples mapping FileTypes -> extensions ftypes = self.getfileIO.GetInputFiletypesAsTuple() #print "ftypes is ",ftypes filepath = tkFileDialog.askopenfilename( # defaultextension='', initialdir=paths['user'], filetypes=ftypes) if not filepath: print "No file selected" return None # As of python 2.6, askopenfilename returns unicode, so we need to convert the string # Thanks to Noel O'Boyle for pointing this out filepath=str(filepath) self.load_from_file( filepath ) def load_from_file(self, filepath, display=1): """load structure from a file""" #print 'ATTEMPT LOAD',filepath # Only do this once if not self.getfileIO: self.getfileIO = GetFileIO() # See if we have a reader suitable for the selected file reader = self.getfileIO.GetReader( filepath=filepath ) if not reader: self.error( "A suitable reader for the file %s could not be found!" % filepath ) return try: objects = reader.GetObjects() except Exception,e: self.error( "There was a problem reading in structures from the file:\n%s\n\ Please check the output on the terminal/log file for further information." % filepath ) # Print a traceback to stderr for information print "Printing traceback" traceback.print_exc() return if objects: name = reader.name self.import_view_objects( objects, name=name, display=display ) #self.info("Imported %s objects for viewing" % len(objects)) # Set this directory as the cwd for future operations dirname = os.path.dirname(filepath) paths['user'] = dirname print 'user directory is now',paths['user'] def import_view_objects( self, objects, name=None, display=1 ): """ Import a selection of objects into the GUI """ if not name: name = 'untitled' mols = [] trajectories = [] for o in objects: myclass = o.GetClass() #print 'import_view_objects: obj',o #print 'class ',myclass #print 'unique',root, o.title #root = os.path.basename( filepath ) #o.name = self.make_unique_name(root,o.title) o.name = self.make_unique_name(name,title=o.title) #print 'o.name is', o.name if myclass == 'VibFreq': self.append_data(o) elif myclass == 'VibFreqSet' : self.append_data(o) elif myclass == 'Indexed' or myclass == 'Zmatrix': # will need to organise together with other results # assume overwrite for now if len( o.atom ) < 500: o.connect() self.append_data(o) # Used by visualisers #o.title = name #o.list() mols.append(o) elif myclass == 'ZmatrixSequence': if len( o.atom ) < 500: o.connect() self.append_data(o) trajectories.append(o) elif myclass == 'Brick': self.append_data(o) elif myclass == 'Field': self.append_data(o) elif myclass == 'Dl_PolyHISTORYFile': self.append_data(o) else: print "import_view_objects unknown class ",myclass # Below wasn't working # Add to the main dictionary #t = id(o) #self.file_dict[t] = file if display: self.quick_obj_view(objects,['molecule','trajectory','vibration_set'],open=1) # add to any open dialogs self.__update_data_list() def append_data(self, data): self.data_list.append(data) # Initially the callback list is empty self.editing_callbacks[id(data)] = {} def update_from_object(self, obj): """Update dependencies from object obj """ if self.debug_callbacks: print 'update_from_object: ID=',id(obj) print 'Callbacks:',self.editing_callbacks # Run the callbacks try: callbacks = self.editing_callbacks[id(obj)] for k in callbacks.keys(): if self.debug_callbacks: print 'Running callback',k try: callbacks[k]() except Exception: print 'warning: update_from_object - callback failed',k except KeyError: if self.debug_callbacks: print 'update_from_object - no callbacks' # Replace all graphical representations of a given object t = id(obj) if self.debug: deb('vis_update of '+str(t)) deb(str(self.vis_dict)) try: visl = self.vis_dict[t] except KeyError: if self.debug: print 'update_from_object - no visualisers' return for v in visl: if self.debug: print 'update vis' v.Build() def delete_callback(self,object,key=None): """Helper function to remove a callback from the table """ if self.debug_callbacks: if key: print 'Deleting callback key=',key,'obj=',object else: print 'Deleting all callbacks for',object t = self.editing_callbacks[id(object)] if key: keylist = [key] else: keylist = t.keys() for key in keylist: del t[key] if key[0:3] == 'ZME': # Also remove the zme_dict entry if self.debug_callbacks: print 'Deleting zme_dict key=',id(object) try: del self.zme_dict[id(object)] except KeyError: print 'zme_dict entry missing??' if key[0:4] == 'CALC': # Also remove the calced_dict entry if self.debug_callbacks: print 'Deleting calced_dict key=',id(object) try: del self.calced_dict[id(object)] except KeyError: print 'calced_dict entry missing??' def rdjagout(self,file): patt_start = regex.compile('^ *Input geometry') while(1): line = file.readline() if not line: break n = patt_start.match(line) if n >= 0: break line = file.readline() #skip the "angstroms" line line = file.readline() #skip the "atom x y z" line while(1): line = file.readline() if not line: break words = string.split(line) if len(words) < 4: break words = string.split(line) atsym = words[0] x = eval(words[1]) y = eval(words[2]) z = eval(words[3]) # Need to write a converter to clean up the Jaguar labels realsym = Element.cleansym(atsym) atno = Element.sym2no[realsym] a = ZAtom() a.coord = [x,y,z] self.addatom(a) return def rdsys(self,file): while 1: line = file.readline() if not line: break words = string.split(line) if words[0] == 'atom' : atname = words[2] atno = Element.name2no[atname] x = eval(words[3])*0.52918 y = eval(words[4])*0.52918 z = eval(words[5])*0.52918 at = ZAtom(x,y,z,atno) self.addatom(at) return def rdxbs(self,file): while 1: line = file.readline() if not line: break words = string.split(line) if not words: break if words[0] == 'atom' : atsym = words[1] atno = Element.sym2no[atsym] x = eval(words[2]) y = eval(words[3]) z = eval(words[4]) a = ZAtom() a.coord = [x,y,z] a.symbol = atsym self.addatom(a) return def rdmsc(self,file): while 1: line = file.readline() if not line: break words = string.split(line) if not words: continue if words[0] == 'atomlist': self.rdmscatomlist(file) if words[0] == 'fraglist': self.rdmscfraglist(file) if words[0] == 'charge': self.charge = eval(words[1]) if words[0] == 'spin': self.charge = eval(words[1]) if words[0] == 'fragmentbuffersize': self.fragmentbuffersize = eval(words[1]) return def rdmscatomlist(self,file): while 1: line = file.readline() if not line: break words = string.split(line) if not words: continue if words[0] == 'endatomlist': break sym = words[0] x = eval(words[1]) y = eval(words[2]) z = eval(words[3]) num = Element.sym2no[sym] at = Atom(x,y,z,num) self.addatom(at) return def rdmscfraglist(self,file): while 1: line = file.readline() if not line: break words = string.split(line) if not words: continue if words[0] == 'endfraglist': break for word in words: self.fraglist.append(eval(word)) return def ask_save_to_file(self): """Save molecule to file""" mol = self.choose_mol() if not mol: return # Get the object that returns a suitable IO object if not self.getfileIO: self.getfileIO = GetFileIO() # This (was?) bust under linux as the menu gets too long #ftypes = {} ftypes = self.getfileIO.GetOutputFiletypesAsTuple() filepath = tkFileDialog.asksaveasfilename( initialfile = mol.name, initialdir = paths['user'], # defaultextension='.pun', filetypes= ftypes ) if not len(filepath): print "No file selected" return None # Try and determine the format from the extension format = self.getfileIO.FormatFromExt( filepath ) if not format: format,filepath = self.saveas_ask_filetype( filepath ) if not format: # User probably canced #print "### User cancelled write" return None if self.debug: print 'ATTEMPT WRITE',filepath,format # See if we have a reader suitable for the selected file writer = self.getfileIO.GetWriter( dataobj=mol, filepath=filepath, format=format ) if not writer: self.error( "A suitable writer for the molecule %s could not be found!" % mol ) return None try: writer.WriteFile( mol ) except Exception,e: traceback.print_exc() self.error("Error writing file: %s\n%s\nPlease see the terminal for more info" %( filepath, e)) return def make_unique_name(self,name,title=None): old_names = self.get_names() # Build up a list of suffixes suf = [] suf.append('') for i in range(1,1000): suf.append('['+str(i)+']') orig = name sname = name # first try the title, if provided if title: t = string.maketrans(' ','_') name = string.translate(string.strip(title),t) sname = name else: name = orig if name not in old_names: return name # try a combination of name and title if title: t = string.maketrans(' ','_') name = orig + '.' + string.translate(string.strip(title),t) sname = name if name not in old_names: return name # finally append a suffix for s in suf: name = sname + s if name not in old_names: return name def connect_model(self,model,all=0): """Update connectivity for a structure and redisplay """ if all: undo = [] for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': # NEED TO UPDATE BOND before this d.update_bonds() undo.append (lambda obj = d, oldc=d.bond: obj.apply_connect(oldc)) undo.append (lambda s = self, obj = d: update_from_object(obj)) d.connect(scale=self.conn_scale,toler=self.conn_toler) self.update_from_object(d) self.undo_stack.append(undo) else: undo = [] model.update_bonds() # NEED TO UPDATE BOND before this will work undo.append (lambda obj = model, oldc=model.bond: obj.apply_connect(oldc)) undo.append (lambda s = self, obj = model: s.update_from_object(obj)) self.undo_stack.append(undo) model.connect(scale=self.conn_scale,toler=self.conn_toler) self.update_from_object(model) def extend_model(self,model,all=0): """Generate a number of cells from the primitive cell contents """ models = [] if all: for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': models.append(d) else: models = [model] for model in models: if len(model.cell) != 3 and len(model.cell) !=2 : self.error('cant extend '+model.name+' .. system is not periodic') return if len(models) == 0: self.warn('nothing to extend') return res = self.extend_dialog.activate() if res == 'OK': minx = int(self.extend_dialog.minx.get()) maxx = int(self.extend_dialog.maxx.get()) miny = int(self.extend_dialog.miny.get()) maxy = int(self.extend_dialog.maxy.get()) minz = int(self.extend_dialog.minz.get()) maxz = int(self.extend_dialog.maxz.get()) else: return for model in models: model.extend(minx,maxx,miny,maxy,minz,maxz) self.connect_model(model) # update_from_model skipped as there is a call at end of connect_model def delete_obj(self,model0,all=0): """Delete the model and all it representations """ if all: deadmen=copy.copy(self.data_list) else: deadmen=[model0] for model in deadmen: # data list self.data_list.remove(model) # visualisers t = id(model) if self.vis_dict.has_key(t): for v in self.vis_dict[t]: print 'deleting rep' self.vis_list.remove(v) v.Delete() del self.vis_dict[t] # destroy zme and calced instances # this should clear the relevant callbacks if self.zme_dict.has_key(t): self.zme_dict[t].Quit() if self.calced_dict.has_key(t): for ed in self.calced_dict[t]: ed.Close() del model self.update() def gamessuk_calced(self,obj=None): c = GAMESSUKCalc(mol=obj) print 'calced mol is ',obj self.edit_calc(c) def molpro_calced(self,obj=None): c = MOLPROCalc(mol=obj) self.edit_calc(c) def dalton_calced(self,obj=None): c = DALTONCalc(mol=obj) self.edit_calc(c) def chemshell_calced(self,obj=None): c = ChemShellCalc(mol=obj) self.edit_calc(c) def dlpoly_calced(self,obj=None): c = DLPOLYCalc(mol=obj) self.edit_calc(c) def mopac_calced(self,obj=None): c= MopacCalc(mol=obj) self.edit_calc(c) def mndo_calced(self,obj=None): c= MNDOCalc(mol=obj) self.edit_calc(c) def smeagol_calced(self,obj=None): c= SMEAGOLCalc(mol=obj) self.edit_calc(c) def edit_calc(self,calc): """Open an editor for a given calculation Also ensures correct handling of the target structure """ obj = calc.get_input("mol_obj") if obj in self.data_list: print 'obj already loaded' else: print 'loading new obj' self.quick_obj_view(obj,'molecule') self.append_data(obj) tt = id(obj) # First define a unique string to key the callback count = 1 while 1: callback_key = 'CALC'+str(count)+'.'+str(id(obj)) if self.editing_callbacks[id(obj)].has_key(callback_key): count = count + 1 else: break if self.debug_callbacks: print 'Callback key is ',callback_key if self.vis_dict.has_key(tt): vis=self.vis_dict[tt] else: vis=None ed = calc.edit(self.master,self, vis=vis, job_editor=self.job_editor, reload_func= lambda s=self,t=str(id(obj)) : s.load_from_graph(t), update_func= lambda o,s=self,t=str(id(obj)) : s.update_model(t,o), on_exit=lambda s=self,k=callback_key,o=obj : s.delete_callback(o,k), balloon=self.balloon ) if ed: try: ed.Show() except RuntimeError,exception: pass if self.calced_dict.has_key(id(obj)): self.calced_dict[id(obj)].append(ed) else: self.calced_dict[id(obj)] = [ed] self.editing_callbacks[id(obj)][callback_key] = lambda editor=ed: editor.Reload() # jmht hack - return ed so that we can use this when restoring jobs return ed def undo(self): print 'undo stack',len(self.undo_stack) cmds = self.undo_stack.pop() print 'undo stack now',len(self.undo_stack) print 'executing',len(cmds),'steps' for c in cmds: c() def edit_coords(self,i): # First define a unique string to key the callback callback_key = 'ZME.'+str(id(i)) if self.editing_callbacks[id(i)].has_key(callback_key): self.warn('This structure is already being edited!!') return if self.debug_callbacks: print 'Callback key is ',callback_key #print 'on edit',len(i.bond),len(i.atom[0].coord) e = ZME(self.master, reload_func= lambda s=self,t=str(id(i)) : s.load_from_graph(t), update_func= lambda o,s=self,t=str(id(i)) : s.update_model(t,o), export_selection_func = lambda mol,atoms,s=self : s.select_from_zme(mol,atoms), import_selection_func = lambda mol,s=self : s.provide_selection_to_zme(mol), on_exit=lambda s=self,k=callback_key,o=i : s.delete_callback(o,k), v_key=1) self.editing_callbacks[id(i)][callback_key] = lambda editor=e: editor.Reload() self.zme_dict[id(i)] = e def select_from_zme(self,mol,atoms): """When an atom is selected in the zmatrix editor this function should cause the selection to be visible in the graphics window""" sel = self.sel() if len(atoms): if self.debug_selection: print 'upd sel',atoms sel.clear() sel.add(mol,atoms) self.update() def provide_selection_to_zme(self,mol): """When an atom is selected in the zmatrix editor this function should cause the selection to be visible in the graphics window""" sel = self.sel() return sel.get_by_mol(mol) def new_coords(self): # Start with a single atom i = Zmatrix() new = ZAtom() new.symbol = 'C' new.name = 'C' i.insert_atom(0,new) self.new_molecule_index = self.new_molecule_index + 1 i.title = 'New' + str(self.new_molecule_index) i.name = 'new' + str(self.new_molecule_index) #label='new' #cmd.load_model(i,label) #cmd.enable(label) # this is to handle the bug in windows which means a single # point doesn't show up i.hybridise(new,'sp3') self.append_data(i) vis = self.quick_obj_view(i,'molecule') # We will need the editing tools self.toolwidget.show() def open_calc(self): """Open a calculation from a file""" # initialdir = self.calcdir, ofile = tkFileDialog.askopenfilename( initialdir=paths['user'], filetypes=[("Calc File","*.clc"),] ) ofile=str(ofile) if len(ofile): fobj = open(ofile,'r') u = pickle.Unpickler(fobj) obj = u.load() fobj.close() self.edit_calc(obj) def about(self): """ """ d=SimpleDialog(self.master, title='About the CCP1 GUI Tk Viewer widget', text=' CCP1 GUI Tk Viewer widget version 0.8 \n\n' ' by Paul Sherwood, Huub van Dam and \n' ' Jens Thomas\n' ' http://www.cse.clrc.ac.uk/qcg/ccp1gui, 2004.\n\n' ' Daresbury Laboratory\n', buttons= ['Close',], cancel=0) # copied from simpledialog source file, stops app exiting # on dialog close d.go() def edit_grid(self,i): """ Open a grid editor """ if i.data: if not self.query("This will trash the data, Proceed?"): return i.data = None try: x = self.grid_vis except AttributeError: self.grid_vis = None window=GridEditor(self.master, i, command=self.view_grid, exitcommand=self.done_view_grid) window.show() def view_grid(self, field): """ callback for the grid editor to enable the grid to be visualised as it is being edited """ # Create the image if not already active if not self.grid_vis: t = id(field) self.grid_vis = self.grid_visualiser(self.master,self,field) self.vis_dict[t] = [self.grid_vis] self.grid_vis.Show() self.grid_vis.Build() def done_view_grid(self, field): """ remove the image of the grid""" t = id(field) vis = self.vis_dict[t][0] vis.Hide() # # Support for CCP1 quantum chemistry interface # # get_names returns the list of objects # load_from_graph returns a molecule given its name # def get_names(self,molecules_only=0): list = [] for d in self.data_list: myclass = d.GetClass() if (not molecules_only) or (myclass == 'Indexed' or myclass == 'Zmatrix'): list.append(d.name) return list def load_from_graph(self,name): """return a structure from the viewer the second argument (name) should actually be the string form of the python id """ print 'viewer: load_from_graph',name for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': ############or myclass == 'ZmatrixSequence': #if name == d.name or name == str(id(d)): # return d if name == str(id(d)): return d self.warn('internal error: load failed') def update_model(self,name,obj): """Update a structure in the viewer name identifies the object which the viewer should obj should be the incoming data to write into it. From October 03, name is replaced by the python object id However, the name mapping is retained for compatibility with pymol """ tobj = None if self.debug: print 'viewer: update_model name=',name,' obj=',obj # Look for a structure with the matching name for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix' : if self.debug: print 'Name check in viewer',d.name if name == d.name or name == str(id(d)): tobj = d; if not tobj: # This should not now happen unless operations on sequences # are re-enabled self.warn("Structure imported " + obj.name + "\n This is not an update of an existing structure, Loading as new model ") self.import_objects([obj]) return elif tobj == obj: # found it print ' Running update_from_object' self.update_from_object(obj) else: print ' Replacing object contents' newd = [] copycontents(tobj, obj) self.update_from_object(tobj) def import_objects(self,objects): """Provided to allow calculation editors to load data into the viewer All objects are assumed to have a name attribute which must be unique to allow it to be used to identify objects when returned from menus. Needs some more design work!!! """ for o in objects: try: dum = o.get_name() if not dum: dum = "None" except: try: dum = o.title except: dum = "???" o.name = self.make_unique_name(dum) self.append_data(o) def import_objects_info(self,objects): """Provided to allow calculation editors to load data into the viewer This version pops up a dialog Needs some more design work!!! """ txt = "Objects from calculation:\n" for o in objects: self.append_data(o) # # need to make a unique name # try: txt = txt + o.title + "\n" except AttributeError: txt = txt + "????\n" except: print 'Other error' txt = txt + "????\n" self.info(txt) def choose_mol(self): """ Select a single molecule (i.e of class zmatrix). If more than one is present in the structures, choose the one that is selected, or if none are selected, get the user to choose one from a list. """ mols = self.loaded_mols() if len(mols) == 0: message_text = "No molecules to choose from present in viewer.\n" + \ "Please load a structure and retry." self.error(message_text) raise EditError,"No molecular structures present!" elif len(mols) == 1: # Select the 1 molecule present... return mols[0] elif len( self.sel().get_mols() ) == 1: # There is one selected molecule, so use that return self.sel().get_mols()[0] else: # Get a list of the names of the molecules\ name_list = [] for m in mols: name_list.append(m.name) # Bring up a selection widget self.result = Tkinter.StringVar() self.dialog = Pmw.Dialog(self.master, buttons = ('OK','Cancel'), title = 'Select Molecule', command = self.__StoreResult) self.var = Tkinter.StringVar() self.dialog.mol = Pmw.OptionMenu( self.dialog.interior(), labelpos = 'n', label_text="Please select a molecular\nstructure "+ "from the list", menubutton_textvariable = self.var, items = name_list, initialitem = mols[0].name) self.dialog.mol.pack(fill='both') self.dialog.activate() if self.result.get() == 'OK': mol_name = self.var.get() else: raise EditError,"No molecular structure selected!" #print 'mol_name',mol_name #print 'data list', self.data_list for d in self.data_list: myclass=d.GetClass() #print 'class', myclass if myclass == 'Indexed' or myclass == 'Zmatrix': #print 'check name ', d.name if mol_name == d.name: t = d; return t def __StoreResult(self,option): """Store the name of the pressed button and destroy the dialog box.""" self.result.set(option) self.dialog.destroy() def get_selection(self,name): """Load the selected atoms from molecule name""" #PS still work to do here to replace use of name with object id for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': if name == d.name: mol = d if not mol: print 'no matching mol',name return "" sel = self.sel() return sel.get_by_mol(mol) def set_selection(self,name,atoms): """Set the current selection, using a list of atoms""" #PS still work to do here to replace use of name with object id print 'set_selection',name,atoms for d in self.data_list: myclass=d.GetClass() if myclass == 'Indexed' or myclass == 'Zmatrix': if name == d.name: mol = d if not mol: print 'no matching mol' return sel = self.sel() sel.clear() sel.add(mol,atoms) self.update() def map_names(self,mol,names): """Translate from a string containing names to atoms In this implementation the names are the integer labels counting from 1 (potentially dangerous) """ res = [] for txt in string.split(names): res.append(mol.atom[int(txt) - 1]) return res def atom_names(self,atoms,exclude_dummies=0): """return a list of unique names to identify the atoms""" res = "" print 'atoms in atom_names', atoms for a in atoms: if exclude_dummies: res = res + str(a.get_index2() + 1) + " " else: res = res + str(a.get_index() + 1) + " " return res def get_angle(self,p1,p2,p3): r1 = cpv.distance(p1,p2) r2 = cpv.distance(p2,p3) r3 = cpv.distance(p1,p3) small = 1.0e-10 cnv = 57.29577951 if r1 + r2 - r3 < small: # printf("trig error %f\n",r3-r1-r2) # This seems to happen occasionally for 180 angles theta = 180.0 else: theta = cnv*math.acos( (r1*r1 + r2*r2 - r3*r3) / (2.0 * r1*r2) ) return theta; def get_dihedral(self,p1,p2,p3,p4): cnv=57.29577951 vec_ij = cpv.sub(p1, p2) vec_kj = cpv.sub(p3, p2) vec_kl = cpv.sub(p3, p4) # vec1 is the normal to the plane defined by atoms i, j, and k vec1 = cpv.cross_product(vec_ij,vec_kj) magvec1 = cpv.dot_product(vec1,vec1) # vec2 is the normal to the plane defined by atoms j, k, and l vec2 = cpv.cross_product(vec_kl,vec_kj) magvec2 = cpv.dot_product(vec2,vec2) # the definition of a dot product is used to find the angle between # vec1 and vec2 and hence the angle between the planes defined by # atoms i, j, k and j, k, l # # the factor of pi (180.0) is present since when we defined the # vectors vec1 and vec2, one used the right hand rule while the # other used the left hand rule dotprod = cpv.dot_product(vec1,vec2) #print magvec1, magvec2 #print type(magvec1), type(magvec2) fac = dotprod / math.sqrt(magvec1*magvec2) if(fac > 1.0): fac = 1.0 if(fac < -1.0): fac = -1.0 dihed = 180.0 - cnv * math.acos(fac ) # the dot product between the bond between atoms i and j and the # normal to the plane defined by atoms j, k, and l is used to # determine whether or not the dihedral angle is clockwise or # anti_clockwise # # if the dot product is positive, the rotation is clockwise sign_check = cpv.dot_product(vec_ij,vec2) if( sign_check > 0.0): dihed = dihed * -1.0 return dihed def list_contacts(self,model): """Output a list of the contacts to the gui's python terminal """ print 'Contacts for ',model.title sel = self.sel() sel = sel.get() tt = {} obj = {} for mol,atom in sel: if not tt.has_key(id(mol)): tt[id(mol)] = [] obj[id(mol)] = mol tt[id(mol)].append(atom) for k in tt.keys(): l = [] for a in tt[k]: l.append(a.get_index()) obj[k].find_contacts(contact_scale=self.contact_scale,contact_toler=self.contact_toler,pr=1,list=l) def list_model(self,model): """Bring up an editor to list the bond lengths and angles with a list of the coordinates. """ data=[] data.append('Listing of %s\n' % model.title) data.append('Atoms\n') for a in model.atom: txt = '' try: for b in a.conn: txt = txt + '%d ' % (b.get_index() + 1) except AttributeError: pass data.append('%3d %2s %-6s %10.4f %10.4f %10.4f %8.3f %s\n' % ( a.get_index()+1, a.symbol, a.name, a.coord[0],a.coord[1],a.coord[2], a.partial_charge, txt)) self.infoeditor = interfaces.inputeditor.Editor(self.interior(),title="Model List",data=data) return def list_geom(self,model): """List all the bonds and angles in this moleclue in an editor """ data=[] data.append('Geometrical Info for %s\n' % model.title) for t in model.bonds_and_angles(): data.append(t+"\n") self.infoeditor = interfaces.inputeditor.Editor(self.interior(),title="Geometry List",data=data,directory=paths['user']) def ask_watch_file(self): """Ask for a file to monitor for appended data""" file=askopenfilename( defaultextension='', initialdir=paths['user'], filetypes=[('Molecules','.c'), ('All', '*')]) if not file: return # Need to convert from unicode to standard str file=str(file) words2 = string.split(file,'/') name = words2[-1] words = string.split(name,'.') root = words[0] p = PunchReader() p.scan(file) for o in p.objects: myclass=o.GetClass() o.name = self.make_unique_name(root,o.title) if myclass == 'VibFreq' : self.append_data(o) elif myclass == 'Indexed' or myclass == 'Zmatrix': # will need to organise together with other results # assume overwrite for now self.append_data(o) self.quick_obj_view(o,'molecule') self.__update_data_list() # create the Lock self.lock = threading.RLock() # Create the queues self.queue1 = Queue.Queue() self.queue2 = Queue.Queue() self.periodicCall() self.watcher = SlaveThread(self.lock, self.queue1 ,self.upd_from_watch) self.watch_obj = o self.watch_reader = p self.watch_file=file self.mtime=os.stat(self.watch_file)[stat.ST_MTIME] try: self.watcher.start() self.watch_dialog.activate(globalMode = 'nograb') except RuntimeError,e: self.gui.error.configure(message_text = str(e)) self.gui.error.activate() def end_watcher(self,event): self.watch_dialog.deactivate() self.queue2.put(999) # # This is executed in the slave thread # def upd_from_watch(self): if self.queue2.qsize(): try: code = self.queue2.get() print 'watcher queue:', code if code ==999: return 99 except Queue.Empty: print 'empty' pass mtime = os.stat(self.watch_file)[stat.ST_MTIME] #print 'mtime',mtime if mtime != self.mtime: self.watch_reader.rescan(self.watch_file,object=self.watch_obj) self.mtime = mtime return 2 else: return 0 # # Stuff to handle slave threads, see jobman.py # def periodicCall(self): """ Check every 100 ms if there is something new in the queue. """ self.processIncoming() self.after(100, self.periodicCall) def processIncoming(self): """ Handle all the messages currently in the queue (if any). """ while self.queue1.qsize(): try: msg = self.queue1.get(0) # Check contents of message and do what it says # As a test, we simply print it #print 'Queue get',msg if msg ==0: pass elif msg == 1: pass elif msg == -1: pass elif msg == 2: # The file has changed self.update_from_object(self.watch_obj) except Queue.Empty: print 'empty' pass def atom_info(self,mol,i): print 'mol: ',mol.title a = mol.atom[i] print 'atom:',i+1, a.name print 'posn:',a.coord print 'pchg:',a.partial_charge try: c = a.conn except AttributeError: c = [] for t in c: print 'conn:',t.get_index()+1, t.name, distance(a.coord, t.coord) for t in c: for tt in c: if tt.get_index() > t.get_index(): print ' ',t.get_index()+1, a.get_index()+1, tt.get_index()+1, \ self.get_angle(t.coord,a.coord, tt.coord) def measure_selection(self): selection = self.sel().get_ordered() #print selection if len(selection) >= 2: mol4,atom4 = selection[-1] mol3,atom3 = selection[-2] i3 = atom3.get_index() + 1 i4 = atom4.get_index() + 1 print 'Distance (', i3, ',',i4,') = ', mol4.get_distance(atom4,atom3) if len(selection) >= 3: mol2,atom2 = selection[-3] i2 = atom2.get_index() + 1 #print 'Distance (', i2, ',',i3,') = ', mol4.get_distance(atom3,atom2) print 'Angle (', i4,',',i3,',',i2,') =',mol2.get_angle(atom4,atom3,atom2) if len(selection) >= 4: mol1,atom1 = selection[-4] i1 = atom1.get_index() + 1 #print 'Distance (', i1, ',',i2,') = ', mol4.get_distance(atom2,atom1) #print 'Angle (', i3,i2,i1,') =',mol2.get_angle(atom3,atom2,atom1) print 'Torsion (',i4,',',i3,',',i2,',',i1,') =',mol2.get_dihedral(atom4,atom3,atom2,atom1) # # ------------- Animation Controls ------------------- # def select_ani_images(self): """ Pop up the widget to select the images for an animation: Create the scene widget if it doesn't already exists. Regenerate the list of objects and refresh the widget if it does. """ #print 'start' if not self.ani_image_widget: from objects import selector #print 'sel' #self.ani_image_widget = selector.Selector( self.master, self ) print 'show' self.ani_image_widget.show() else: #print "self.ani_image_widget is ",str(self.ani_image_widget) self.ani_image_widget.refresh() self.ani_image_widget.show() #print 'done' def ask_save_movie(self): """ The use has clicked on the button to save a movie """ self.save_movie_dialog.show() def ani_reset(self): """ Build up a fresh animation list ani_list is a list of the images for the animation - stored in the order they will be shown. """ # Build up a fresh animation list self.new_ani_list() # Redraw the selector if self.ani_image_widget: self.ani_image_widget.refresh() # Redraw the main window self.ani_refresh() def new_ani_list(self): """Generate a fresh ani_list from the objects in the data_list that have representations. """ self.ani_list = [] if len( self.data_list ): for obj in self.data_list: t = id(obj) try: visl = self.vis_dict[t] for vis in visl: #if vis.IsShowing(): self.ani_list.append( vis ) except KeyError: # No representation so just pass pass def ani_refresh(self): """ Reset the main window so that is clears out all images showing and displays the first one in the ani_list """ #print 'ani_refresh' ## for obj in self.data_list: ## t = id(obj) ## print 'ani_refresh loop' ## try: ## visl = self.vis_dict[t] ## for vis in visl: ## vis.Hide() ## except KeyError: ## pass for v in self.vis_list: if v.IsShowing(): v.Hide() #self._ani_hide_all() self.frame_no = 0 #print '_ani_show' if self._ani_show(): #print 'update' self.update() def ani_rew(self): """ Go to the first frame of the animation and display the image """ self.frame_no = 0 self._ani_hide_all() if self._ani_show(): self.update() def ani_end(self): """ Go to the last frame of the animation and display the image. """ lani = len(self.ani_list) if lani <= 1: print "ani_end: only one or no frames to display" else: self.frame_no = lani - 1 self._ani_hide_all() if self._ani_show(): self.update() def ani_bak(self): """ Step back a single frame in the animation """ # Need to initialise frame_no if the animation toolbar was # open when objects were read in try: tmp = self.frame_no except: self.frame_no = 0 if self.frame_no > 0: self._ani_hide() self.frame_no -= 1 if self._ani_show(): self.update() else: #self.error( " Already at the start of animation.\nI can\'t go any further back!" ) print " Already at the start of animation.\nI can\'t go any further back!" return #self._ani_show() def ani_fwd(self): """ Step forward a single frame in the animation """ # Need to initialise frame_no if the animation toolbar was # open when objects were read in try: tmp = self.frame_no except: self.frame_no = 0 if self.frame_no < ( len(self.ani_list)-1 ): self._ani_hide() self.frame_no = self.frame_no+1 if self._ani_show(): self.update() #self.update() else: #self.error( " Already at the end of animation.\nI can\'t go any further forward!" ) print " Already at the end of animation.\nI can\'t go any further forward!" return def ani_stop(self): """ Stop the animation """ self.ani_stop = 1 def ani_play(self): """ Play through the sequence of images from self.frame_no to the end """ # Need to initialise frame_no if the animation toolbar was # open when objects were read in try: tmp = self.frame_no except: self.frame_no = 0 # If the ani_list is empty reset if len ( self.ani_list ) == 0 : self.ani_reset() #return # Go back to the start if we're at the end if ( self.frame_no == len( self.ani_list )-1 ): self._ani_hide() self.frame_no = 0 # Display the current frame if self._ani_show(): self.update() time.sleep(0.2) self.ani_stop = 0 while ( self.frame_no <= len(self.ani_list)-2 ): #print 'Frame:',self.frame_no self.interior().update() if self.ani_stop: return self._ani_hide() self.frame_no += 1 if self._ani_show(): self.update() time.sleep(0.2) def _ani_hide(self): """ Hide the current image as defined in self.frame_no """ try: vis = self.ani_list[self.frame_no] vis._hide() # Hack so the view menu display what is showing/hidden vis.is_showing = 0 #vis.Hide() #self.update() except IndexError: print "ani_hide: nothing to hide" pass def _ani_hide_all(self): """ Hide all the images in the animation list """ for vis in self.ani_list: try: vis._hide() # Hack so the view menu display what is showing/hidden vis.is_showing = 0 except IndexError: pass #self.update() def _ani_show(self): """ Show the image as specified by the current frame number. Return 1 if we have an image to show, None if not """ try: #print 'show',self.frame_no vis = self.ani_list[ self.frame_no ] vis._show() # Hack so the view menu display what is showing/hidden vis.is_showing = 1 # vis.Show() #self.update() #print '_ani_show frame #',self.frame_no return 1 except IndexError: #print "ani_show: nothing to show" return None #------------- messages ----------------------------- def build_msg_dialog(self): """Message information""" dialog = Pmw.MessageDialog(self.master, title = 'Information', iconpos='w', icon_bitmap='info', defaultbutton = 0) dialog.withdraw() self.msg_dialog = dialog def info(self,txt): dialog = self.msg_dialog dialog.configure(message_text=txt) dialog.component('icon').configure(bitmap='info') dialog.configure(title="CCP1 GUI Information") dialog.activate() def warn(self,txt): dialog = self.msg_dialog dialog.configure(message_text=txt) dialog.configure(title='CCP1 GUI Warning') dialog.component('icon').configure(bitmap='warning') dialog.activate() def error(self,txt): dialog = self.msg_dialog dialog.configure(message_text=txt) dialog.configure(title='CCP1 GUI Error') dialog.component('icon').configure(bitmap='error') dialog.activate() #------------- yes/no questions -------------------------- def build_query_dialog(self): self.query_dialog = Pmw.MessageDialog(self.master, title = "Query:", iconpos='w', icon_bitmap='question', buttons = ("Yes","No"), command = self.__QueryResult) self.query_dialog.withdraw() def query(self,txt): self.dialogresult = 'Zzz' dialog = self.query_dialog dialog.configure(message_text=txt) dialog.configure(title='CCP1 GUI Query') dialog.component('icon').configure(bitmap='question') dialog.activate() if self.query_result == 'Zzz': print 'Problem' elif self.query_result == 'Yes': return 1 else: return 0 def __QueryResult(self,result): """Pmw silliness, need to get the result of a query. Have to have a routine to store the result and remove the window (sigh).""" self.query_result = result self.query_dialog.deactivate() #------------- watch ----------------------------- def build_watch_dialog(self): self.watch_dialog = Pmw.Dialog(self.master, buttons = ('End',), title = 'Select Molecule', command = self.end_watcher) self.watch_dialog.withdraw() #------------- help ----------------------------- def build_help_dialog(self): #fixedFont = Pmw.logicalfont('Courier',size=12) #text_font=("Courier", 10, "normal"), dialog = Pmw.TextDialog(self.master, scrolledtext_labelpos = 'n', title = 'Help', defaultbutton = 0, text_bg = 'white', label_text = '') dialog.withdraw() self.help_dialog = dialog def open_help_dialog(self,label,txt): dialog = self.help_dialog dialog.configure(text_state = 'normal') dialog.delete('1.0','end') dialog.insert('end', txt) dialog.configure(label_text = label) dialog.configure(text_state = 'disabled') dialog.show() #-------------- Options ------------------------- def build_options_dialog(self): """Options are set using a Notebook widget presented in a dialog widget """ self.options_dialog = Pmw.Dialog(self.master, buttons = ('Apply','Close and Apply','Cancel'), title = 'CCP1 GUI: tkMolView Options', command = self.store_options) nb = Pmw.NoteBook(self.options_dialog.interior()) page = nb.add('Files') page = nb.add('Connectivity') grp = Pmw.Group(page,tag_text = 'Connection parameters') d = {'counter' : 'real' } self.w_conn_scale = Pmw.Counter( grp.interior(), datatype = d, labelpos = 'w', label_text = "Radius Scale", increment = 0.1, entryfield_entry_width = 10, entryfield_value = self.conn_scale) self.w_conn_scale.pack(side='left') self.w_conn_toler = Pmw.Counter( grp.interior(), datatype = d, labelpos = 'w', label_text = "Tolerance", increment = 0.1, entryfield_entry_width = 10, entryfield_value = self.conn_toler) self.w_conn_toler.pack(side='left') grp.pack(side='top',fill='x') grp = Pmw.Group(page,tag_text = 'Non-bonded Contact parameters') d = {'counter' : 'real' } self.w_contact_scale = Pmw.Counter( grp.interior(), datatype = d, labelpos = 'w', label_text = "Radius Scale", increment = 0.1, entryfield_entry_width = 10, entryfield_value = self.contact_scale) self.w_contact_scale.pack(side='left') self.w_contact_toler = Pmw.Counter( grp.interior(), datatype = d, labelpos = 'w', label_text = "Tolerance", increment = 0.1, entryfield_entry_width = 10, entryfield_value = self.contact_toler) self.w_contact_toler.pack(side='left') grp.pack(side='top',fill='x') page = nb.add('Visualisation') # Background colour f1 = Tkinter.Frame(page) self.cframe = Tkinter.Frame(f1) self.w_colorlab = Tkinter.Label(self.cframe,text='Background Colour: ') self.bg_colour = '#%02x%02x%02x' % self.bg_rgb self.w_bgcolor = Tkinter.Button(self.cframe, text = 'Choose', foreground = self.bg_colour, command= self.__choose_bg_colour) # Pick tolerance self.pktframe = Tkinter.Frame(f1) d = {'counter' : 'real' } self.w_picktol = Pmw.Counter( self.pktframe, datatype = d, labelpos = 'w', label_text = "Pick Tolerance", increment = 0.005, entryfield_entry_width = 10, entryfield_value = self.pick_tolerance) f1.pack(side='top') self.w_picktol.pack(side='left') self.w_colorlab.pack(side='left') self.w_bgcolor.pack(side='left') self.pktframe.pack(side='left',fill='x') self.cframe.pack(side='left',fill='x') # Clipping self.clipframe = Pmw.Group(page,tag_text='Clipping Planes') d = {'counter' : 'real' } v = "Auto" if self.near: v = str(self.near) self.w_nearclip = Pmw.EntryField( self.clipframe.interior(), labelpos = 'w', label_text = "Near", value = v) self.w_nearclip.pack(side='left') v = "Auto" if self.far: v = str(self.far) self.w_farclip = Pmw.EntryField( self.clipframe.interior(), labelpos = 'w', label_text = "Far", value = v) self.w_farclip.pack(side='left') self.clipframe.pack(side='top',fill='x') # Line Width and Point Size (Molecule drawings) self.mol_line_frame = Pmw.Group(page,tag_text="Molecule Line Drawing Settings") grp = self.mol_line_frame.interior() d = {'counter' : 'integer' } self.w_mol_line_width = Pmw.Counter( grp, datatype = d, labelpos = 'w', label_text = "Line Width", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_line_width) self.w_mol_point_size = Pmw.Counter( grp, datatype = d, labelpos = 'w', label_text = "Point Size", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_point_size) self.w_mol_line_width.pack(side='left') self.w_mol_point_size.pack(side='left') self.mol_line_frame.pack(side='top',fill='x') # Sphere representation and properties self.sphere_prop_frame = Pmw.Group(page,tag_text="Sphere Properties") grp = self.sphere_prop_frame.interior() f1 = Tkinter.Frame(grp) f2 = Tkinter.Frame(grp) d = {'counter' : 'integer' } self.w_mol_sphere_resolution = Pmw.Counter( f1, datatype = d, labelpos = 'w', label_text = "Resolution", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_sphere_resolution) self.w_mol_sphere_specular_power = Pmw.Counter( f1, datatype = d, labelpos = 'w', label_text = "Specular Power", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_sphere_specular_power) d = {'counter' : 'real' } self.w_mol_sphere_diffuse = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Diffuse", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_sphere_diffuse) self.w_mol_sphere_ambient = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Ambient", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_sphere_ambient) self.w_mol_sphere_specular = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Specular", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_sphere_specular) self.w_mol_sphere_resolution.pack(side='left') self.w_mol_sphere_specular_power.pack(side='left') f1.pack(side='top') self.w_mol_sphere_diffuse.pack(side='left') self.w_mol_sphere_ambient.pack(side='left') self.w_mol_sphere_specular.pack(side='left') f2.pack(side='top') self.sphere_prop_frame.pack(side='top',fill='x') # Cylinder representation and properties self.cylinder_prop_frame = Pmw.Group(page,tag_text="Cylinder Properties") grp = self.cylinder_prop_frame.interior() f1 = Tkinter.Frame(grp) f2 = Tkinter.Frame(grp) d = {'counter' : 'integer' } self.w_mol_cylinder_resolution = Pmw.Counter( f1, datatype = d, labelpos = 'w', label_text = "Resolution", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_cylinder_resolution) self.w_mol_cylinder_specular_power = Pmw.Counter( f1, datatype = d, labelpos = 'w', label_text = "Specular Power", increment = 1, entryfield_entry_width = 5, entryfield_value = self.mol_cylinder_specular_power) d = {'counter' : 'real' } self.w_mol_cylinder_diffuse = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Diffuse", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_cylinder_diffuse) self.w_mol_cylinder_ambient = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Ambient", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_cylinder_ambient) self.w_mol_cylinder_specular = Pmw.Counter( f2, datatype = d, labelpos = 'w', label_text = "Specular", increment = 0.1, entryfield_entry_width = 5, entryfield_value = self.mol_cylinder_specular) self.w_mol_cylinder_resolution.pack(side='left') self.w_mol_cylinder_specular_power.pack(side='left') f1.pack(side='top') self.w_mol_cylinder_diffuse.pack(side='left') self.w_mol_cylinder_ambient.pack(side='left') self.w_mol_cylinder_specular.pack(side='left') f2.pack(side='top') self.cylinder_prop_frame.pack(side='top',fill='x') # Line Width and Point Size (Field Representations drawings) self.field_line_frame = Pmw.Group(page,tag_text="Data Line Settings") grp = self.field_line_frame.interior() d = {'counter' : 'integer' } self.w_field_line_width = Pmw.Counter( grp, datatype = d, labelpos = 'w', label_text = "Line Width", increment = 1, entryfield_entry_width = 5, entryfield_value = self.field_line_width) self.w_field_point_size = Pmw.Counter( grp, datatype = d, labelpos = 'w', label_text = "Point Size", increment = 1, entryfield_entry_width = 5, entryfield_value = self.field_point_size) self.w_field_line_width.pack(side='left') self.w_field_point_size.pack(side='left') self.field_line_frame.pack(side='top',fill='x') # Other options # rotation origin # - not so important now we have found 'r' key binding # in preferences store initial location for load/save # lod actors # clipping planes page = nb.add('Developmental') #hull_width = self.width, #hull_height = self.height, #createcommand=self.CreatePage, # raisecommand=self.RaisePage, # lowercommand=self.LowerPage) nb.pack(expand=1, fill='both') #self.options_notebook = nb nb.setnaturalsize() self.options_dialog.withdraw() #Associate widget with its helpfile viewer.help.sethelp(self.options_dialog,'Edit Options') def __choose_bg_colour(self): colour = tkColorChooser.askcolor(initialcolor=self.bg_colour) self.bg_rgb = colour[0] self.bg_colour = colour[1] self.w_bgcolor.configure(foreground = self.bg_colour) def open_options_dialog(self): self.save_bg_rgb = self.bg_rgb self.save_pick_tolerance = self.pick_tolerance self.save_near = self.near self.save_far = self.far self.options_dialog.activate(globalMode = 'nograb') def store_options(self,result): """Code executed when the dialog is closed""" if result == 'Apply' or result == 'Close and Apply': # Here we need to apply any options that have # been modified print 'Store' self.set_bg_colour(self.bg_rgb) defaults.set_value( 'bg_rgb', self.bg_rgb ) self.pick_tolerance = float(self.w_picktol.get()) self.set_pick_tolerance() defaults.set_value( 'pick_tolerance', self.pick_tolerance ) txt = self.w_nearclip.get() if txt == "Auto": self.near = None else: self.near = float(txt) txt = self.w_farclip.get() if txt == "Auto": self.far = None else: self.far = float(txt) self.set_clipping_planes() self.conn_toler = float(self.w_conn_toler.get()) defaults.set_value( 'conn_toler', self.conn_toler ) self.conn_scale = float(self.w_conn_scale.get()) defaults.set_value( 'conn_scale', self.conn_scale ) self.contact_toler = float(self.w_contact_toler.get()) defaults.set_value( 'contact_toler', self.contact_toler ) self.contact_scale = float(self.w_contact_scale.get()) defaults.set_value( 'contact_scale', self.contact_scale ) self.mol_line_width = int(self.w_mol_line_width.get()) defaults.set_value( 'mol_line_width', self.mol_line_width ) self.mol_point_size = int(self.w_mol_point_size.get()) defaults.set_value( 'mol_point_size', self.mol_point_size ) self.field_line_width = int(self.w_field_line_width.get()) defaults.set_value( 'field_line_width', self.field_line_width ) self.field_point_size = int(self.w_field_point_size.get()) defaults.set_value( 'field_point_size', self.field_point_size ) self.mol_sphere_resolution = int(self.w_mol_sphere_resolution.get()) defaults.set_value( 'mol_sphere_resolution', self.mol_sphere_resolution ) self.mol_sphere_specular_power = int(self.w_mol_sphere_specular_power.get()) defaults.set_value( 'mol_sphere_specular_power', self.mol_sphere_specular_power ) self.mol_sphere_diffuse = float(self.w_mol_sphere_diffuse.get()) defaults.set_value( 'mol_sphere_diffuse', self.mol_sphere_diffuse ) self.mol_sphere_ambient = float(self.w_mol_sphere_ambient.get()) defaults.set_value( 'mol_sphere_ambient', self.mol_sphere_ambient ) self.mol_sphere_specular = float(self.w_mol_sphere_specular.get()) defaults.set_value( 'mol_sphere_specular', self.mol_sphere_specular ) self.mol_cylinder_resolution = int(self.w_mol_cylinder_resolution.get()) defaults.set_value( 'mol_cylinder_resolution', self.mol_cylinder_resolution ) self.mol_cylinder_specular_power = int(self.w_mol_cylinder_specular_power.get()) defaults.set_value( 'mol_cylinder_specular_power', self.mol_cylinder_specular_power ) self.mol_cylinder_diffuse = float(self.w_mol_cylinder_diffuse.get()) defaults.set_value( 'mol_cylinder_diffuse', self.mol_cylinder_diffuse ) self.mol_cylinder_ambient = float(self.w_mol_cylinder_ambient.get()) defaults.set_value( 'mol_cylinder_ambient', self.mol_cylinder_ambient ) self.mol_cylinder_specular = float(self.w_mol_cylinder_specular.get()) defaults.set_value( 'mol_cylinder_specular', self.mol_cylinder_specular ) else: # Cancel them self.bg_rgb = self.save_bg_rgb self.pick_tolerance = self.save_pick_tolerance if result == 'Close and Apply' or result == 'Cancel': self.options_dialog.deactivate(result) #self.options_dialog.close() self.update() #-------------- Command Window ------------------------- def idleShell(self): mypyshell(self.master) def iPythonShell(self): if self.ipythonshell: self.ipythonshell.withdraw() self.ipythonshell.show() return try: import ipython.ipythonTk banner="This is the CCP1GUI IPython shell.\n" + \ "For info on IPython see: http://ipython.scipy.org\n" + \ "The main CCP1GUI instance can be accessed as the variable: gui\n\n" self.ipythonshell=ipython.ipythonTk.IPythonTopLevel(self.master, banner=banner) self.ipythonshell.userdeletefunc(lambda s=self: s.ipythonshell.withdraw()) self.ipythonshell.component('console').updateNamespace({'gui':self}) self.ipythonshell.show() except ImportError: self.warn("Cannot execute iPython shell as iPython does not\n"+\ "appear to be installed. Please install iPython from:\n"+\ "http://ipython.scipy.org") def build_command_window(self): self.shell_dialog = Pmw.TextDialog(self.master, scrolledtext_labelpos = 'n', title = 'Python Shell', buttons = ('Close',), label_text = '') self.text = self.shell_dialog.component('text') self.text.bind('<Return>', lambda e,s=self,g=globals(),l=locals(): s.ev(g,l,e) ) self.shell_dialog.withdraw() #Associate widget with its helpfile viewer.help.sethelp(self.shell_dialog,'Python Shell') # 'viewer.pythonshell.txt') def ev(self,globals,locals,arg): line = self.text.get('insert linestart','insert lineend') exec line in globals,locals def define_colourmaps(self): """colourmap_func is defined in the visualisation class that this inherits from. The function itself is inherited from the ColourMap class that is found in generic/colourmap.py - this is where the various set_title etc. methods are defined """ self.colourmaps = [] c = self.colourmap_func() self.colourmaps.append(c) c.set_title("black") c.set_range(-1.0,1.0) c.set_colours( [ (0 , 0 , 0), (0 , 0 , 0)]) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("red-black-blue") c.set_range(-0.0001,0.0001) c.set_colours([ (255 , 0 , 0), (0 , 0 , 0), (0 , 0 , 255)]) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("red-grey-blue") c.set_range(-1,1.) c.set_colours([ (255 , 0 , 0), (250 , 20 , 20), (245 , 40 , 40), (240 , 70 , 70), (235 , 85 , 85), (230 , 100 , 100), (225 , 120 , 120), (220 , 150 , 150), (215 , 170 , 170), (210 , 190 , 190), (205 , 205 , 205), (190 , 190 , 210), (170 , 170 , 215), (150 , 150 , 220), (120 , 120 , 225), (100 , 100 , 230), ( 85, 85, 235), ( 70, 70, 240), ( 40, 40, 245), ( 20, 20, 250), ( 0, 0, 255) ] ) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("red-blue") c.set_colours([ (0 , 0 , 255), (1 , 0 , 254), (2 , 0 , 253), (3 , 0 , 252), (4 , 0 , 251), (5 , 0 , 250), (6 , 0 , 249), (7 , 0 , 248), (8 , 0 , 247), (9 , 0 , 246), (10 , 0 , 245), (11 , 0 , 244), (12 , 0 , 243), (13 , 0 , 242), (14 , 0 , 241), (15 , 0 , 240), (16 , 0 , 239), (17 , 0 , 238), (18 , 0 , 237), (19 , 0 , 236), (20 , 0 , 235), (21 , 0 , 234), (22 , 0 , 233), (23 , 0 , 232), (24 , 0 , 231), (25 , 0 , 230), (26 , 0 , 229), (27 , 0 , 228), (28 , 0 , 227), (29 , 0 , 226), (30 , 0 , 225), (31 , 0 , 224), (32 , 0 , 223), (33 , 0 , 222), (34 , 0 , 221), (35 , 0 , 220), (36 , 0 , 219), (37 , 0 , 218), (38 , 0 , 217), (39 , 0 , 216), (40 , 0 , 215), (41 , 0 , 214), (42 , 0 , 213), (43 , 0 , 212), (44 , 0 , 211), (45 , 0 , 210), (46 , 0 , 209), (47 , 0 , 208), (48 , 0 , 207), (49 , 0 , 206), (50 , 0 , 205), (51 , 0 , 204), (52 , 0 , 203), (53 , 0 , 202), (54 , 0 , 201), (55 , 0 , 200), (56 , 0 , 199), (57 , 0 , 198), (58 , 0 , 197), (59 , 0 , 196), (60 , 0 , 195), (61 , 0 , 194), (62 , 0 , 193), (63 , 0 , 192), (64 , 0 , 191), (65 , 0 , 190), (66 , 0 , 189), (67 , 0 , 188), (68 , 0 , 187), (69 , 0 , 186), (70 , 0 , 185), (71 , 0 , 184), (72 , 0 , 183), (73 , 0 , 182), (74 , 0 , 181), (75 , 0 , 180), (76 , 0 , 179), (77 , 0 , 178), (78 , 0 , 177), (79 , 0 , 176), (80 , 0 , 175), (81 , 0 , 174), (82 , 0 , 173), (83 , 0 , 172), (84 , 0 , 171), (85 , 0 , 170), (86 , 0 , 169), (87 , 0 , 168), (88 , 0 , 167), (89 , 0 , 166), (90 , 0 , 165), (91 , 0 , 164), (92 , 0 , 163), (93 , 0 , 162), (94 , 0 , 161), (95 , 0 , 160), (96 , 0 , 159), (97 , 0 , 158), (98 , 0 , 157), (99 , 0 , 156), (100 , 0 , 155), (101 , 0 , 154), (102 , 0 , 153), (103 , 0 , 152), (104 , 0 , 151), (105 , 0 , 150), (106 , 0 , 149), (107 , 0 , 148), (108 , 0 , 147), (109 , 0 , 146), (110 , 0 , 145), (111 , 0 , 144), (112 , 0 , 143), (113 , 0 , 142), (114 , 0 , 141), (115 , 0 , 140), (116 , 0 , 139), (117 , 0 , 138), (118 , 0 , 137), (119 , 0 , 136), (120 , 0 , 135), (121 , 0 , 134), (122 , 0 , 133), (123 , 0 , 132), (124 , 0 , 131), (125 , 0 , 130), (126 , 0 , 129), (127 , 0 , 128), (128 , 0 , 127), (129 , 0 , 126), (130 , 0 , 125), (131 , 0 , 124), (132 , 0 , 123), (133 , 0 , 122), (134 , 0 , 121), (135 , 0 , 120), (136 , 0 , 119), (137 , 0 , 118), (138 , 0 , 117), (139 , 0 , 116), (140 , 0 , 115), (141 , 0 , 114), (142 , 0 , 113), (143 , 0 , 112), (144 , 0 , 111), (145 , 0 , 110), (146 , 0 , 109), (147 , 0 , 108), (148 , 0 , 107), (149 , 0 , 106), (150 , 0 , 105), (151 , 0 , 104), (152 , 0 , 103), (153 , 0 , 102), (154 , 0 , 101), (155 , 0 , 100), (156 , 0 , 99), (157 , 0 , 98), (158 , 0 , 97), (159 , 0 , 96), (160 , 0 , 95), (161 , 0 , 94), (162 , 0 , 93), (163 , 0 , 92), (164 , 0 , 91), (165 , 0 , 90), (166 , 0 , 89), (167 , 0 , 88), (168 , 0 , 87), (169 , 0 , 86), (170 , 0 , 85), (171 , 0 , 84), (172 , 0 , 83), (173 , 0 , 82), (174 , 0 , 81), (175 , 0 , 80), (176 , 0 , 79), (177 , 0 , 78), (178 , 0 , 77), (179 , 0 , 76), (180 , 0 , 75), (181 , 0 , 74), (182 , 0 , 73), (183 , 0 , 72), (184 , 0 , 71), (185 , 0 , 70), (186 , 0 , 69), (187 , 0 , 68), (188 , 0 , 67), (189 , 0 , 66), (190 , 0 , 65), (191 , 0 , 64), (192 , 0 , 63), (193 , 0 , 62), (194 , 0 , 61), (195 , 0 , 60), (196 , 0 , 59), (197 , 0 , 58), (198 , 0 , 57), (199 , 0 , 56), (200 , 0 , 55), (201 , 0 , 54), (202 , 0 , 53), (203 , 0 , 52), (204 , 0 , 51), (205 , 0 , 50), (206 , 0 , 49), (207 , 0 , 48), (208 , 0 , 47), (209 , 0 , 46), (210 , 0 , 45), (211 , 0 , 44), (212 , 0 , 43), (213 , 0 , 42), (214 , 0 , 41), (215 , 0 , 40), (216 , 0 , 39), (217 , 0 , 38), (218 , 0 , 37), (219 , 0 , 36), (220 , 0 , 35), (221 , 0 , 34), (222 , 0 , 33), (223 , 0 , 32), (224 , 0 , 31), (225 , 0 , 30), (226 , 0 , 29), (227 , 0 , 28), (228 , 0 , 27), (229 , 0 , 26), (230 , 0 , 25), (231 , 0 , 24), (232 , 0 , 23), (233 , 0 , 22), (234 , 0 , 21), (235 , 0 , 20), (236 , 0 , 19), (237 , 0 , 18), (238 , 0 , 17), (239 , 0 , 16), (240 , 0 , 15), (241 , 0 , 14), (242 , 0 , 13), (243 , 0 , 12), (244 , 0 , 11), (245 , 0 , 10), (246 , 0 , 9), (247 , 0 , 8), (248 , 0 , 7), (249 , 0 , 6), (250 , 0 , 5), (251 , 0 , 4), (252 , 0 , 3), (253 , 0 , 2), (254 , 0 , 1), (255 , 0 , 0) ] ) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("rainbow") c.set_range(-1.0,1.0) c.set_colours([ (255 , 0, 0 ), (255 , 6 , 0 ), (255 , 12 , 0 ), (255 , 18 , 0 ), (255 , 24 , 0 ), (255 , 30 , 0 ), (255 , 36 , 0 ), (255 , 42 , 0 ), (255 , 48 , 0 ), (255 , 54 , 0 ), (255 , 60 , 0 ), (255 , 66 , 0 ), (255 , 72 , 0 ), (255 , 78 , 0 ), (255 , 84 , 0 ), (255 , 90 , 0 ), (255 , 96 , 0 ), (255 , 102 , 0 ), (255 , 108 , 0 ), (255 , 114 , 0 ), (255 , 120 , 0 ), (255 , 126 , 0 ), (255 , 132 , 0 ), (255 , 138 , 0 ), (255 , 144 , 0 ), (255 , 150 , 0 ), (255 , 156 , 0 ), (255 , 162 , 0 ), (255 , 168 , 0 ), (255 , 174 , 0 ), (255 , 180 , 0 ), (255 , 186 , 0 ), (255 , 192 , 0 ), (255 , 198 , 0 ), (255 , 204 , 0 ), (255 , 210 , 0 ), (255 , 216 , 0 ), (255 , 222 , 0 ), (255 , 228 , 0 ), (255 , 234 , 0 ), (255 , 240 , 0 ), (255 , 246 , 0 ), (255 , 252 , 0 ), (250 , 255 , 0 ), (244 , 255 , 0 ), (238 , 255 , 0 ), (232 , 255 , 0 ), (226 , 255 , 0 ), (220 , 255 , 0 ), (214 , 255 , 0 ), (208 , 255 , 0 ), (202 , 255 , 0 ), (196 , 255 , 0 ), (190 , 255 , 0 ), (184 , 255 , 0 ), (178 , 255 , 0 ), (172 , 255 , 0 ), (166 , 255 , 0 ), (160 , 255 , 0 ), (154 , 255 , 0 ), (148 , 255 , 0 ), (142 , 255 , 0 ), (136 , 255 , 0 ), (130 , 255 , 0 ), (124 , 255 , 0 ), (118 , 255 , 0 ), (112 , 255 , 0 ), (106 , 255 , 0 ), (100 , 255 , 0 ), (94 , 255 , 0 ), (88 , 255 , 0 ), (82 , 255 , 0 ), (76 , 255 , 0 ), (70 , 255 , 0 ), (64 , 255 , 0 ), (58 , 255 , 0 ), (52 , 255 , 0 ), (46 , 255 , 0 ), (40 , 255 , 0 ), (34 , 255 , 0 ), (28 , 255 , 0 ), (22 , 255 , 0 ), (16 , 255 , 0 ), (10 , 255 , 0 ), (4 , 255 , 0 ), (0 , 255 , 2 ), (0 , 255 , 8 ), (0 , 255 , 14 ), (0 , 255 , 20 ), (0 , 255 , 26 ), (0 , 255 , 32 ), (0 , 255 , 38 ), (0 , 255 , 44 ), (0 , 255 , 50 ), (0 , 255 , 56 ), (0 , 255 , 62 ), (0 , 255 , 68 ), (0 , 255 , 74 ), (0 , 255 , 80 ), (0 , 255 , 86 ), (0 , 255 , 92 ), (0 , 255 , 98 ), (0 , 255 , 104 ), (0 , 255 , 110 ), (0 , 255 , 116 ), (0 , 255 , 122 ), (0 , 255 , 128 ), (0 , 255 , 134 ), (0 , 255 , 140 ), (0 , 255 , 146 ), (0 , 255 , 152 ), (0 , 255 , 158 ), (0 , 255 , 164 ), (0 , 255 , 170 ), (0 , 255 , 176 ), (0 , 255 , 182 ), (0 , 255 , 188 ), (0 , 255 , 194 ), (0 , 255 , 200 ), (0 , 255 , 206 ), (0 , 255 , 212 ), (0 , 255 , 218 ), (0 , 255 , 224 ), (0 , 255 , 230 ), (0 , 255 , 236 ), (0 , 255 , 242 ), (0 , 255 , 248 ), (0 , 255 , 255 ), (0 , 248 , 255 ), (0 , 242 , 255 ), (0 , 236 , 255 ), (0 , 230 , 255 ), (0 , 224 , 255 ), (0 , 218 , 255 ), (0 , 212 , 255 ), (0 , 206 , 255 ), (0 , 200 , 255 ), (0 , 194 , 255 ), (0 , 188 , 255 ), (0 , 182 , 255 ), (0 , 176 , 255 ), (0 , 170 , 255 ), (0 , 164 , 255 ), (0 , 158 , 255 ), (0 , 152 , 255 ), (0 , 146 , 255 ), (0 , 140 , 255 ), (0 , 134 , 255 ), (0 , 128 , 255 ), (0 , 122 , 255 ), (0 , 116 , 255 ), (0 , 110 , 255 ), (0 , 104 , 255 ), (0 , 98 , 255 ), (0 , 92 , 255 ), (0 , 86 , 255 ), (0 , 80 , 255 ), (0 , 74 , 255 ), (0 , 68 , 255 ), (0 , 62 , 255 ), (0 , 56 , 255 ), (0 , 50 , 255 ), (0 , 44 , 255 ), (0 , 38 , 255 ), (0 , 32 , 255 ), (0 , 26 , 255 ), (0 , 20 , 255 ), (0 , 14 , 255 ), (0 , 8 , 255 ), (0 , 2 , 255 ), (4 , 0 , 255 ), (10 , 0 , 255 ), (16 , 0 , 255 ), (22 , 0 , 255 ), (28 , 0 , 255 ), (34 , 0 , 255 ), (40 , 0 , 255 ), (46 , 0 , 255 ), (52 , 0 , 255 ), (58 , 0 , 255 ), (64 , 0 , 255 ), (70 , 0 , 255 ), (76 , 0 , 255 ), (82 , 0 , 255 ), (88 , 0 , 255 ), (94 , 0 , 255 ), (100 , 0 , 255 ), (106 , 0 , 255 ), (112 , 0 , 255 ), (118 , 0 , 255 ), (124 , 0 , 255 ), (130 , 0 , 255 ), (136 , 0 , 255 ), (142 , 0 , 255 ), (148 , 0 , 255 ), (154 , 0 , 255 ), (160 , 0 , 255 ), (166 , 0 , 255 ), (172 , 0 , 255 ), (178 , 0 , 255 ), (184 , 0 , 255 ), (190 , 0 , 255 ), (196 , 0 , 255 ), (202 , 0 , 255 ), (208 , 0 , 255 ), (214 , 0 , 255 ), (220 , 0 , 255 ), (226 , 0 , 255 ), (232 , 0 , 255 ), (238 , 0 , 255 ), (244 , 0 , 255 ), (250 , 0 , 255 ), (255 , 0 , 252 ), (255 , 0 , 246 ), (255 , 0 , 240 ), (255 , 0 , 234 ), (255 , 0 , 228 ), (255 , 0 , 222 ), (255 , 0 , 216 ), (255 , 0 , 210 ), (255 , 0 , 204 ), (255 , 0 , 198 ), (255 , 0 , 192 ), (255 , 0 , 186 ), (255 , 0 , 180 ), (255 , 0 , 174 ), (255 , 0 , 168 ), (255 , 0 , 162 ), (255 , 0 , 156 ), (255 , 0 , 150 ), (255 , 0 , 144 ), (255 , 0 , 138 ), (255 , 0 , 132 ), (255 , 0 , 126 ), (255 , 0 , 120 ), (255 , 0 , 114 ), (255 , 0 , 108 ), (255 , 0 , 102 ), (255 , 0 , 96 ), (255 , 0 , 90 ), (255 , 0 , 84 ), (255 , 0 , 78 ), (255 , 0 , 72 ), (255 , 0 , 66 ), (255 , 0 , 60 ), (255 , 0 , 54 ), (255 , 0 , 48 ), (255 , 0 , 42 ), (255 , 0 , 36 ), (255 , 0 , 30 ), (255 , 0 , 24 ), (255 , 0 , 18 ), (255 , 0 , 12 ), (255 , 0 , 6 ), (255 , 0 , 0 ) ] ) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("rainbow plus half") c.set_range(-1.0,1.0) c.set_colours([ (0 , 255 , 255 ), (0 , 248 , 255 ), (0 , 242 , 255 ), (0 , 236 , 255 ), (0 , 230 , 255 ), (0 , 224 , 255 ), (0 , 218 , 255 ), (0 , 212 , 255 ), (0 , 206 , 255 ), (0 , 200 , 255 ), (0 , 194 , 255 ), (0 , 188 , 255 ), (0 , 182 , 255 ), (0 , 176 , 255 ), (0 , 170 , 255 ), (0 , 164 , 255 ), (0 , 158 , 255 ), (0 , 152 , 255 ), (0 , 146 , 255 ), (0 , 140 , 255 ), (0 , 134 , 255 ), (0 , 128 , 255 ), (0 , 122 , 255 ), (0 , 116 , 255 ), (0 , 110 , 255 ), (0 , 104 , 255 ), (0 , 98 , 255 ), (0 , 92 , 255 ), (0 , 86 , 255 ), (0 , 80 , 255 ), (0 , 74 , 255 ), (0 , 68 , 255 ), (0 , 62 , 255 ), (0 , 56 , 255 ), (0 , 50 , 255 ), (0 , 44 , 255 ), (0 , 38 , 255 ), (0 , 32 , 255 ), (0 , 26 , 255 ), (0 , 20 , 255 ), (0 , 14 , 255 ), (0 , 8 , 255 ), (0 , 2 , 255 ), (4 , 0 , 255 ), (10 , 0 , 255 ), (16 , 0 , 255 ), (22 , 0 , 255 ), (28 , 0 , 255 ), (34 , 0 , 255 ), (40 , 0 , 255 ), (46 , 0 , 255 ), (52 , 0 , 255 ), (58 , 0 , 255 ), (64 , 0 , 255 ), (70 , 0 , 255 ), (76 , 0 , 255 ), (82 , 0 , 255 ), (88 , 0 , 255 ), (94 , 0 , 255 ), (100 , 0 , 255 ), (106 , 0 , 255 ), (112 , 0 , 255 ), (118 , 0 , 255 ), (124 , 0 , 255 ), (130 , 0 , 255 ), (136 , 0 , 255 ), (142 , 0 , 255 ), (148 , 0 , 255 ), (154 , 0 , 255 ), (160 , 0 , 255 ), (166 , 0 , 255 ), (172 , 0 , 255 ), (178 , 0 , 255 ), (184 , 0 , 255 ), (190 , 0 , 255 ), (196 , 0 , 255 ), (202 , 0 , 255 ), (208 , 0 , 255 ), (214 , 0 , 255 ), (220 , 0 , 255 ), (226 , 0 , 255 ), (232 , 0 , 255 ), (238 , 0 , 255 ), (244 , 0 , 255 ), (250 , 0 , 255 ), (255 , 0 , 252 ), (255 , 0 , 246 ), (255 , 0 , 240 ), (255 , 0 , 234 ), (255 , 0 , 228 ), (255 , 0 , 222 ), (255 , 0 , 216 ), (255 , 0 , 210 ), (255 , 0 , 204 ), (255 , 0 , 198 ), (255 , 0 , 192 ), (255 , 0 , 186 ), (255 , 0 , 180 ), (255 , 0 , 174 ), (255 , 0 , 168 ), (255 , 0 , 162 ), (255 , 0 , 156 ), (255 , 0 , 150 ), (255 , 0 , 144 ), (255 , 0 , 138 ), (255 , 0 , 132 ), (255 , 0 , 126 ), (255 , 0 , 120 ), (255 , 0 , 114 ), (255 , 0 , 108 ), (255 , 0 , 102 ), (255 , 0 , 96 ), (255 , 0 , 90 ), (255 , 0 , 84 ), (255 , 0 , 78 ), (255 , 0 , 72 ), (255 , 0 , 66 ), (255 , 0 , 60 ), (255 , 0 , 54 ), (255 , 0 , 48 ), (255 , 0 , 42 ), (255 , 0 , 36 ), (255 , 0 , 30 ), (255 , 0 , 24 ), (255 , 0 , 18 ), (255 , 0 , 12 ), (255 , 0 , 6 ), (255 , 0 , 0 ), (255 , 6 , 0 ), (255 , 12 , 0 ), (255 , 18 , 0 ), (255 , 24 , 0 ), (255 , 30 , 0 ), (255 , 36 , 0 ), (255 , 42 , 0 ), (255 , 48 , 0 ), (255 , 54 , 0 ), (255 , 60 , 0 ), (255 , 66 , 0 ), (255 , 72 , 0 ), (255 , 78 , 0 ), (255 , 84 , 0 ), (255 , 90 , 0 ), (255 , 96 , 0 ), (255 , 102 , 0 ), (255 , 108 , 0 ), (255 , 114 , 0 ), (255 , 120 , 0 ), (255 , 126 , 0 ), (255 , 132 , 0 ), (255 , 138 , 0 ), (255 , 144 , 0 ), (255 , 150 , 0 ), (255 , 156 , 0 ), (255 , 162 , 0 ), (255 , 168 , 0 ), (255 , 174 , 0 ), (255 , 180 , 0 ), (255 , 186 , 0 ), (255 , 192 , 0 ), (255 , 198 , 0 ), (255 , 204 , 0 ), (255 , 210 , 0 ), (255 , 216 , 0 ), (255 , 222 , 0 ), (255 , 228 , 0 ), (255 , 234 , 0 ), (255 , 240 , 0 ), (255 , 246 , 0 ), (255 , 252 , 0 ), (250 , 255 , 0 ), (244 , 255 , 0 ), (238 , 255 , 0 ), (232 , 255 , 0 ), (226 , 255 , 0 ), (220 , 255 , 0 ), (214 , 255 , 0 ), (208 , 255 , 0 ), (202 , 255 , 0 ), (196 , 255 , 0 ), (190 , 255 , 0 ), (184 , 255 , 0 ), (178 , 255 , 0 ), (172 , 255 , 0 ), (166 , 255 , 0 ), (160 , 255 , 0 ), (154 , 255 , 0 ), (148 , 255 , 0 ), (142 , 255 , 0 ), (136 , 255 , 0 ), (130 , 255 , 0 ), (124 , 255 , 0 ), (118 , 255 , 0 ), (112 , 255 , 0 ), (106 , 255 , 0 ), (100 , 255 , 0 ), (94 , 255 , 0 ), (88 , 255 , 0 ), (82 , 255 , 0 ), (76 , 255 , 0 ), (70 , 255 , 0 ), (64 , 255 , 0 ), (58 , 255 , 0 ), (52 , 255 , 0 ), (46 , 255 , 0 ), (40 , 255 , 0 ), (34 , 255 , 0 ), (28 , 255 , 0 ), (22 , 255 , 0 ), (16 , 255 , 0 ), (10 , 255 , 0 ), (4 , 255 , 0 ), (0 , 255 , 2 ), (0 , 255 , 8 ), (0 , 255 , 14 ), (0 , 255 , 20 ), (0 , 255 , 26 ), (0 , 255 , 32 ), (0 , 255 , 38 ), (0 , 255 , 44 ), (0 , 255 , 50 ), (0 , 255 , 56 ), (0 , 255 , 62 ), (0 , 255 , 68 ), (0 , 255 , 74 ), (0 , 255 , 80 ), (0 , 255 , 86 ), (0 , 255 , 92 ), (0 , 255 , 98 ), (0 , 255 , 104 ), (0 , 255 , 110 ), (0 , 255 , 116 ), (0 , 255 , 122 ), (0 , 255 , 128 ), (0 , 255 , 134 ), (0 , 255 , 140 ), (0 , 255 , 146 ), (0 , 255 , 152 ), (0 , 255 , 158 ), (0 , 255 , 164 ), (0 , 255 , 170 ), (0 , 255 , 176 ), (0 , 255 , 182 ), (0 , 255 , 188 ), (0 , 255 , 194 ), (0 , 255 , 200 ), (0 , 255 , 206 ), (0 , 255 , 212 ), (0 , 255 , 218 ), (0 , 255 , 224 ), (0 , 255 , 230 ), (0 , 255 , 236 ), (0 , 255 , 242 ), (0 , 255 , 248 ), (0 , 255 , 255 ) ] ) c.build() c = self.colourmap_func() self.colourmaps.append(c) c.set_title("rainbow on black") c.set_range(-1.0,1.0) c.set_colours([ (0 , 0 , 0), (10 , 0 , 0), (20 , 0 , 0), (30 , 0 , 0), (40 , 0 , 0), (50 , 0 , 0), (60 , 0 , 0), (70 , 0 , 0), (80 , 0 , 0), (90 , 0 , 0), (100 , 0 , 0), (110 , 0 , 0), (120 , 0 , 0), (130 , 0 , 0), (140 , 0 , 0), (150 , 0 , 0), (160 , 0 , 0), (170 , 0 , 0), (180 , 0 , 0), (190 , 0 , 0), (200 , 0 , 0), (210 , 0 , 0), (220 , 0 , 0), (230 , 0 , 0), (240 , 0 , 0), (250 , 0 , 0), (255 , 6 , 0 ), (255 , 18 , 0 ), (255 , 30 , 0 ), (255 , 42 , 0 ), (255 , 54 , 0 ), (255 , 66 , 0 ), (255 , 78 , 0 ), (255 , 90 , 0 ), (255 , 102 , 0 ), (255 , 114 , 0 ), (255 , 126 , 0 ), (255 , 138 , 0 ), (255 , 150 , 0 ), (255 , 162 , 0 ), (255 , 174 , 0 ), (255 , 186 , 0 ), (255 , 198 , 0 ), (255 , 210 , 0 ), (255 , 222 , 0 ), (255 , 234 , 0 ), (255 , 246 , 0 ), (250 , 255 , 0 ), (238 , 255 , 0 ), (232 , 255 , 0 ), (226 , 255 , 0 ), (220 , 255 , 0 ), (214 , 255 , 0 ), (208 , 255 , 0 ), (202 , 255 , 0 ), (196 , 255 , 0 ), (190 , 255 , 0 ), (184 , 255 , 0 ), (178 , 255 , 0 ), (172 , 255 , 0 ), (166 , 255 , 0 ), (160 , 255 , 0 ), (154 , 255 , 0 ), (148 , 255 , 0 ), (142 , 255 , 0 ), (136 , 255 , 0 ), (130 , 255 , 0 ), (124 , 255 , 0 ), (118 , 255 , 0 ), (112 , 255 , 0 ), (106 , 255 , 0 ), (100 , 255 , 0 ), (94 , 255 , 0 ), (88 , 255 , 0 ), (82 , 255 , 0 ), (76 , 255 , 0 ), (70 , 255 , 0 ), (64 , 255 , 0 ), (58 , 255 , 0 ), (52 , 255 , 0 ), (46 , 255 , 0 ), (40 , 255 , 0 ), (34 , 255 , 0 ), (28 , 255 , 0 ), (22 , 255 , 0 ), (16 , 255 , 0 ), (10 , 255 , 0 ), (4 , 255 , 0 ), (0 , 255 , 2 ), (0 , 255 , 8 ), (0 , 255 , 14 ), (0 , 255 , 20 ), (0 , 255 , 26 ), (0 , 255 , 32 ), (0 , 255 , 38 ), (0 , 255 , 44 ), (0 , 255 , 50 ), (0 , 255 , 56 ), (0 , 255 , 62 ), (0 , 255 , 68 ), (0 , 255 , 74 ), (0 , 255 , 80 ), (0 , 255 , 86 ), (0 , 255 , 92 ), (0 , 255 , 98 ), (0 , 255 , 104 ), (0 , 255 , 110 ), (0 , 255 , 116 ), (0 , 255 , 122 ), (0 , 255 , 128 ), (0 , 255 , 134 ), (0 , 255 , 140 ), (0 , 255 , 146 ), (0 , 255 , 152 ), (0 , 255 , 158 ), (0 , 255 , 164 ), (0 , 255 , 170 ), (0 , 255 , 176 ), (0 , 255 , 182 ), (0 , 255 , 188 ), (0 , 255 , 194 ), (0 , 255 , 200 ), (0 , 255 , 206 ), (0 , 255 , 212 ), (0 , 255 , 218 ), (0 , 255 , 224 ), (0 , 255 , 230 ), (0 , 255 , 236 ), (0 , 255 , 242 ), (0 , 255 , 248 ), (0 , 255 , 255 ), (0 , 248 , 255 ), (0 , 242 , 255 ), (0 , 236 , 255 ), (0 , 230 , 255 ), (0 , 224 , 255 ), (0 , 218 , 255 ), (0 , 212 , 255 ), (0 , 206 , 255 ), (0 , 200 , 255 ), (0 , 194 , 255 ), (0 , 188 , 255 ), (0 , 182 , 255 ), (0 , 176 , 255 ), (0 , 170 , 255 ), (0 , 164 , 255 ), (0 , 158 , 255 ), (0 , 152 , 255 ), (0 , 146 , 255 ), (0 , 140 , 255 ), (0 , 134 , 255 ), (0 , 128 , 255 ), (0 , 122 , 255 ), (0 , 116 , 255 ), (0 , 110 , 255 ), (0 , 104 , 255 ), (0 , 98 , 255 ), (0 , 92 , 255 ), (0 , 86 , 255 ), (0 , 80 , 255 ), (0 , 74 , 255 ), (0 , 68 , 255 ), (0 , 62 , 255 ), (0 , 56 , 255 ), (0 , 50 , 255 ), (0 , 44 , 255 ), (0 , 38 , 255 ), (0 , 32 , 255 ), (0 , 26 , 255 ), (0 , 20 , 255 ), (0 , 14 , 255 ), (0 , 8 , 255 ), (0 , 2 , 255 ), (4 , 0 , 255 ), (10 , 0 , 255 ), (16 , 0 , 255 ), (22 , 0 , 255 ), (28 , 0 , 255 ), (34 , 0 , 255 ), (40 , 0 , 255 ), (46 , 0 , 255 ), (52 , 0 , 255 ), (58 , 0 , 255 ), (64 , 0 , 255 ), (70 , 0 , 255 ), (76 , 0 , 255 ), (82 , 0 , 255 ), (88 , 0 , 255 ), (94 , 0 , 255 ), (100 , 0 , 255 ), (106 , 0 , 255 ), (112 , 0 , 255 ), (118 , 0 , 255 ), (124 , 0 , 255 ), (130 , 0 , 255 ), (136 , 0 , 255 ), (142 , 0 , 255 ), (148 , 0 , 255 ), (154 , 0 , 255 ), (160 , 0 , 255 ), (166 , 0 , 255 ), (172 , 0 , 255 ), (178 , 0 , 255 ), (184 , 0 , 255 ), (190 , 0 , 255 ), (196 , 0 , 255 ), (202 , 0 , 255 ), (208 , 0 , 255 ), (214 , 0 , 255 ), (220 , 0 , 255 ), (226 , 0 , 255 ), (232 , 0 , 255 ), (238 , 0 , 255 ), (244 , 0 , 255 ), (250 , 0 , 255 ), (255 , 0 , 252 ), (255 , 0 , 246 ), (255 , 0 , 240 ), (255 , 0 , 234 ), (255 , 0 , 228 ), (255 , 0 , 222 ), (255 , 0 , 216 ), (255 , 0 , 210 ), (255 , 0 , 204 ), (255 , 0 , 198 ), (255 , 0 , 192 ), (255 , 0 , 186 ), (255 , 0 , 180 ), (255 , 0 , 174 ), (255 , 0 , 168 ), (255 , 0 , 162 ), (255 , 0 , 156 ), (255 , 0 , 150 ), (255 , 0 , 144 ), (255 , 0 , 138 ), (255 , 0 , 132 ), (255 , 0 , 126 ), (255 , 0 , 120 ), (255 , 0 , 114 ), (255 , 0 , 108 ), (255 , 0 , 102 ), (255 , 0 , 96 ), (255 , 0 , 90 ), (255 , 0 , 84 ), (255 , 0 , 78 ), (255 , 0 , 72 ), (255 , 0 , 66 ), (255 , 0 , 60 ), (255 , 0 , 54 ), (255 , 0 , 48 ), (255 , 0 , 42 ), (255 , 0 , 36 ), (255 , 0 , 30 ), (255 , 0 , 24 ), (255 , 0 , 18 ), (255 , 0 , 12 ), (255 , 0 , 6 ), (255 , 0 , 0 ) ] ) c.build() def prtk(w): """Debugging utility to trace Tk widget trees""" print 'Widget :',w #print w.children for c in w.children.keys(): print 'Child',c, w.children[c].__class__ prtk(w.children[c]) def copycontents(to,fro): """Used to update an object by copying in the contents from another""" c = to.__class__ d1 = c.__dict__ try: d2 = fro.__dict__ except AttributeError: d2 = {} for k in d2.keys(): to.__dict__[k] = fro.__dict__[k] if __name__ == "__main__": import viewer.vtkgraph root = Tkinter.Tk() root.withdraw() # On OSX might need to hide the additional console window when # run as an application from the finder try: root.tk.call('console', 'hide') except: pass vt = viewer.vtkgraph.VtkGraph(root) for file in sys.argv[1:]: print 'loading',file vt.load_from_file(file) #root.withdraw() vt.mainloop()
alexei-matveev/ccp1gui
viewer/main.py
Python
gpl-2.0
218,187
[ "CHARMM", "ChemPy", "DL_POLY", "Dalton", "GAMESS", "Jaguar", "MOPAC", "Molpro", "PyMOL", "VTK", "VisIt" ]
7f3b64eed225f8f8d18cbd58d85e4ac245289f07a6ddffdf97336aaaf95aa3d8
""" calculate coverage across a list of regions """ import os import os.path as op import yaml from argparse import ArgumentParser # import matplotlib.pyplot as plt # from matplotlib.backends.backend_pdf import PdfPages # import matplotlib # import seaborn as sns from ichwrapper import cluster, arguments # import pandas as pd # from collections import Counter, defaultdict import pybedtools # import vcf # from bcbio.provenance import do from bcbio.distributed.transaction import file_transaction from bcbio.bam.fastq import is_fastq from bcbio.utils import file_exists, splitext_plus, tmpfile, safe_makedir from bcbio.install import _get_data_dir from asm.trimming import prepare from asm.align import create_bam from asm.bissnp import call_variations from asm.report import create_report from asm.select import get_het, is_good_cpg, post_processing, detect_asm from asm.show import plot, region_selection, region_selection_by_read def _update_algorithm(data, resources): """ Update algorithm dict with new cores set """ new_data = [] for sample in data: sample[0]['config']['algorithm'] = resources new_data.append(sample) return new_data def _prepare_samples(args): """ create dict for each sample having all information """ if args.galaxy: system_config = args.galaxy else: system_config = os.path.join(_get_data_dir(), "galaxy", "bcbio_system.yaml") config = yaml.load(open(system_config)) config['algorithm'] = {} data = [] vcf_files = [fn for fn in args.files if fn.endswith('vcf')] bam_files = [fn for fn in args.files if fn.endswith('bam')] fastq_files = [fn for fn in args.files if is_fastq(fn)] if not fastq_files: fastq_files = vcf_files for sample in fastq_files: dt = {} dt['name'] = splitext_plus(op.basename(sample))[0] dt['config'] = config dt['fastq'] = op.abspath(sample) if bam_files: dt['bam'] = _find_bam(bam_files, sample) data.append([dt]) return data def select_regions(args): """ select regions and create coverage plots """ assert args.files, "Need a set of fastq files" assert args.out, "Need --out" region = os.path.abspath(args.region) workdir = 'select' safe_makedir(workdir) out_file = os.path.join(workdir, splitext_plus(args.out)[0] + "_cpg.bed") out_snp_file = os.path.join(workdir, splitext_plus(args.out)[0] + '_snp.bed') if not file_exists(out_file): with file_transaction(out_file) as tx_out: with open(tx_out, 'w') as out_handle: # print >> out_handle, "chrom\tstart\tend\tcu\tcm\tstrand\tgene\tsample" for in_vcf in args.files: snp_file = in_vcf.replace("rawcpg", "rawsnp") sample = splitext_plus(os.path.basename(in_vcf))[0].split("_")[0] get_het(snp_file, region, sample, out_snp_file) res = pybedtools.BedTool(in_vcf).intersect(b=region, wo=True) # cmd = ("bedtools intersect -u -a {in_vcf} -b {region} > {tx_tmp}") # do.run(cmd.format(**locals()), "selecting %s" % in_vcf) for record in res: gene = record[-2] chrom, pos, info, header, frmt = record[0], int(record[1]), record[7], record[8], record[9] cs = info.split(';')[0].split('=')[1] frmt = dict(zip(header.split(":"), frmt.split(':'))) if is_good_cpg(frmt): tag = "%s-%s-%s-%s" % (frmt['CU'], frmt['CM'], gene, sample) print >> out_handle, "%s\t%s\t%s\t%s\t.\t%s" % (chrom, pos, pos + 1, tag, cs) def detect_positions(data, args): assert args.reference, "Need --reference" assert args.index, "Need --index" assert args.files, "Need a set of fastq files" assert args.snp, "Need --snp" resources = {'name': 'trimming', 'mem': 4, 'cores': 1} data = _update_algorithm(data, resources) data = cluster.send_job(prepare, data, args, resources) resources = {'name': 'align', 'mem': 2, 'cores': 8} data = _update_algorithm(data, resources) data = cluster.send_job(create_bam, data, args, resources) resources = {'name': 'bissnp', 'mem': 3, 'cores': 8} data = _update_algorithm(data, resources) data = cluster.send_job(call_variations, data, args, resources) resources = {'name': 'report', 'mem': 2, 'cores': 5} data = _update_algorithm(data, resources) data = cluster.send_job(create_report, data, args, resources) def _find_bam(bam_files, sample): """ Find the most similar file name """ score = 0 candidate = None for fn in bam_files: sc = sum(a == b for a, b in zip(op.basename(sample), op.basename(fn))) if sc > score: score = sc candidate = fn return candidate def link_sites(data, args): assert args.files, "Need a set of fastq files" assert args.out, "Need prefix" resources = {'name': 'link', 'mem': 6, 'cores': 1} workdir = args.out workdir = op.abspath(safe_makedir(workdir)) data = _update_algorithm(data, resources) data = cluster.send_job(detect_asm, data, args, resources) vcf_res = [sample[0]['asm'] for sample in data] vcf_merged = op.join(workdir, args.out + ".vcf") post_processing(vcf_res, vcf_merged, op.join(workdir, "link")) if __name__ == "__main__": parser = ArgumentParser(description="task related to allele methylation specific") parser = arguments.myargs(parser) parser.add_argument("--region", help="bed file with regions.") parser.add_argument("--reference", help="genome fasta file.") parser.add_argument("--index", help="genome index for bismark.") parser.add_argument("--is_rrbs", action="store_true", help="RRBS data.") parser.add_argument("--is_directional", action="store_true", help="is directional sequencing.") parser.add_argument("--bowtie2", action="store_true", help="bowtie2 index.") parser.add_argument("--snp", help="SNPdb database.") # parser.add_argument("--galaxy", help="bcbio galaxy resources.") parser.add_argument("--out", help="output file.") parser.add_argument("files", nargs="*", help="Bam files.") parser.add_argument("--run", required=1, help="Calculate bam stats", choices=['select', 'detection', 'link', 'show', 'raw']) parser.add_argument("--n_sample", default=1000, help="sample bed files with this number of lines") parser.add_argument("--seed", help="replication of sampling") args = parser.parse_args() if args.run == 'select': pairs = [fn for fn in args.files if fn.endswith("tsv")] bams = [fn for fn in args.files if fn.endswith("bam")] region_selection(pairs, bams, args.out, bed_file=args.region, min_samples=args.n_sample) if args.run == 'raw': pairs = [fn for fn in args.files if fn.endswith("tsv")] bams = [fn for fn in args.files if fn.endswith("bam")] cpg = [fn for fn in args.files if fn.endswith("_rawcpg.vcf")] snp = [fn for fn in args.files if fn.endswith("_rawsnp.vcf")] region_selection_by_read(pairs, cpg, snp, bams, args.out, args.region) # select_regions(args) if args.run == "detection": data = _prepare_samples(args) detect_positions(data, args) if args.run == 'link': data = _prepare_samples(args) link_sites(data, args) if args.run == 'show': plot(args.files, args.region, args.out)
lpantano/ASMfinder
scripts/asm-pipeline.py
Python
mit
7,652
[ "Galaxy" ]
0c274c87094ddca6edf5e08ccab2383860357ed2b16d81b4649e2a31f136dea6
""" Some classes and functions for analysing chromosome conformations generated with Hamiltonian Monte Carlo. """ import numpy as np import pylab as plt from isdhic import utils from csb.bio.utils import distance_matrix from collections import OrderedDict class Ensemble(object): def __init__(self, samples): self.samples = samples def average_distances(self, burnin=0, thining=1): d = 0. n = 0 for x in self.samples[burnin::thining]: d += distance_matrix(x) n += 1 d/= n return d def calculate_energies(self, posterior, burnin=0, thining=1): energies = OrderedDict() for p in posterior: energies[p.name] = [] coords = posterior.params['coordinates'] for x in self.samples[burnin::thining]: coords.set(x) posterior.update() for p in posterior: energies[p.name].append(-p.log_prob()) for name in energies: energies[name] = np.array(energies[name]) return energies if __name__ == '__main__': pymol = utils.ChainViewer() X = np.array([state.positions for state in samples]).reshape(len(samples),-1,3) V = np.array([state.potential_energy for state in samples]) K = np.array([state.kinetic_energy for state in samples]) ensemble = Ensemble(X) ## show distance matrix and superimpose contacts n_particles = X.shape[1] limits = (1,n_particles+1) burnin, thining = -500, 10 burnin, thining = -100, 1 fig, ax = plt.subplots(1,1,figsize=(10,10),subplot_kw=dict(xlim=limits,ylim=limits)) ax.matshow(ensemble.average_distances(burnin,thining), cmap=cm.hot, origin='lower',extent=limits+limits) ax.scatter(*(1+np.transpose(list(posterior['contacts'].mock.pairs))), color='w', alpha=0.7, s=80) ax.xaxis.set_ticks_position('bottom') ax.set_xlabel(r'bead $i$', fontsize=24) ax.set_ylabel(r'bead $j$', fontsize=24) ## calculate energies and plot energy traces energies = ensemble.calculate_energies(posterior,burnin=100) fig, ax = plt.subplots(1,len(energies),figsize=(16,4), subplot_kw=dict(xlabel='HMC iteration')) for i, name in enumerate(energies.keys()): ax[i].plot(energies[name],color='k',lw=3,alpha=0.7) ax[i].set_ylabel('energy (-log probability)') ax[i].set_title(name) ax[i].xaxis.get_major_formatter().set_powerlimits((0, 1)) ax[i].yaxis.get_major_formatter().set_powerlimits((0, 1)) fig.tight_layout() ## plot observed and backcalculated data models = [model for model in posterior.likelihoods if len(model.data) > 1] fig, ax = plt.subplots(1,len(models),figsize=(10,4), subplot_kw=dict(xlabel='data point')) for i, model in enumerate(models): ax[i].plot(model.mock.get(),color='k',lw=3,alpha=0.7,label='model') ax[i].plot(model.data,color='r',lw=2,ls='--',alpha=0.7,label='observed') ax[i].set_title(model.name) ax[i].legend(loc=3) fig.tight_layout()
michaelhabeck/isdhic
scripts/analyze.py
Python
mit
3,085
[ "PyMOL" ]
7fc73d85fddedd19912879176fc2e27ffb98e5a2bff991dc06b1b1ed52b4e253
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- ### BEGIN LICENSE # Copyright (C) 2014 Brian Douglass bhdouglass@gmail.com # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. ### END LICENSE from agui import Signal from agui.awidgets import AWidget class ASlider(AWidget): def __init__(self, item = None): self._value = 0 self.changed = Signal() AWidget.__init__(self, item) def emit_changed(self, *args): self.changed.emit(self.value) @property def value(self): return self._value @value.setter def value(self, value): self._value = value
bhdouglass/agui
agui/awidgets/slider.py
Python
gpl-3.0
1,189
[ "Brian" ]
38141ccc5fc718719db3c9c237d19d3a98b8bca7ed0095405ec966ed089b8235
## ENVISIoN ## ## Copyright (c) 2021 Gabriel Anderberg, Didrik Axén, Adam Engman, ## Kristoffer Gubberud Maras, Joakim Stenborg ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are met: ## ## 1. Redistributions of source code must retain the above copyright notice, this ## list of conditions and the following disclaimer. ## 2. Redistributions in binary form must reproduce the above copyright notice, ## this list of conditions and the following disclaimer in the documentation ## and/or other materials provided with the distribution. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ## WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ## ############################################################################################## import os,sys import inspect path_to_current_folder = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) sys.path.insert(0, os.path.expanduser(path_to_current_folder+'/..')) import re import numpy as np import itertools import h5py from h5writer import _write_basis, _write_scaling_factor, _write_volume from pathlib import Path #path = '/home/labb/ENVISIoN/ENVISIoN/envisionpy/hdf5parser/ELK' #sys.path.insert(0, os.path.expanduser(path)) #from unitcell_parser import unitcell_parser, find_elements, parse_coordinates line_reg_int = re.compile(r'^( *[+-]?[0-9]+){3} *$') line_reg_float = re.compile(r'( *[+-]?[0-9]*\.[0-9]+(?:[eE][+-]?[0-9]+)? *)+') def check_directory_elf_elk(vasp_path): if Path(vasp_path).joinpath('INFO.OUT').exists() and Path(vasp_path).joinpath('ELF3D.OUT').exists(): return True return False def parse_lattice(ELK_dir): basis = [] with open(os.path.join(ELK_dir,'INFO.OUT'), "r") as f: lines = f.readlines() for i, line in enumerate(lines): if "Lattice vectors :" in line: basis.append([float(n) for n in lines[i+1].split()[:3]]) basis.append([float(n) for n in lines[i+2].split()[:3]]) basis.append([float(n) for n in lines[i+3].split()[:3]]) if "Unit cell volume :" in line: list = line.split() scaling_factor = -float(list[-1]) return scaling_factor ,basis def parse_vol(ELK_file): array = [] datasize = None data_dim = [] counter = 0 for line in ELK_file: match_float = line_reg_float.match(line) if "grid size" in line: data_dim_temp = line.split() for x in range(len(data_dim_temp)): if data_dim_temp[x].isdigit(): data_dim += [int(data_dim_temp[x])] if data_dim: datasize = data_dim[0]*data_dim[1]*data_dim[2] elif data_dim and match_float: for element in line.split(): array.append(float(element)) if len(array) == datasize: return array, data_dim else: data_dim = None return None, None def parse_elf(h5file, ELK_dir): scaling_factor, basis = parse_lattice(ELK_dir) _write_basis(h5file, basis) _write_scaling_factor(h5file, scaling_factor=1) ELK_file = Path(ELK_dir).joinpath('ELF3D.OUT') with open(ELK_file, "r+") as f: for i in itertools.count(): array, data_dim = parse_vol(f) if not _write_volume(h5file, i, array, data_dim, "ELF"): return False if not array: break return True
rartino/ENVISIoN
envisionpy/hdf5parser/ELK/elf_parser_elk.py
Python
bsd-2-clause
4,287
[ "Elk" ]
9cc0ec019770222a0b17f9fd04aa9607ed48e65e9a35172b052794c688a33e35
# Generated from java-escape by ANTLR 4.5 from antlr4 import * # This class defines a complete generic visitor for a parse tree produced by CParser. class CVisitor(ParseTreeVisitor): # Visit a parse tree produced by CParser#FunctionExpression. def visitFunctionExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#DotExpression. def visitDotExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#ParenthesizedExpression. def visitParenthesizedExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#FloatingLiteralExpression. def visitFloatingLiteralExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#PostIncrementExpression. def visitPostIncrementExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#CharacterLiteralExpression. def visitCharacterLiteralExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#ArrowExpression. def visitArrowExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#IndexExpression. def visitIndexExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#SizeOfTypeExpression. def visitSizeOfTypeExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#IdentifierExpression. def visitIdentifierExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#UnaryOperatorExpression. def visitUnaryOperatorExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#IntegerLiteralExpression. def visitIntegerLiteralExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#StringLiteralExpression. def visitStringLiteralExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#PreIncrementExpression. def visitPreIncrementExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#argumentExpressionList. def visitArgumentExpressionList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#castExpression. def visitCastExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#logicalOrExpression. def visitLogicalOrExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#conditionalExpression. def visitConditionalExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#assignmentExpression. def visitAssignmentExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#expression. def visitExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#constantExpression. def visitConstantExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#declaration. def visitDeclaration(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#declarationSpecifier. def visitDeclarationSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#initDeclaratorList. def visitInitDeclaratorList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#initDeclarator. def visitInitDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#storageClassSpecifier. def visitStorageClassSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#typeSpecifier. def visitTypeSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#structOrUnionSpecifier. def visitStructOrUnionSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#structOrUnion. def visitStructOrUnion(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#structDeclaration. def visitStructDeclaration(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#specifierQualifierList. def visitSpecifierQualifierList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#structDeclaratorList. def visitStructDeclaratorList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#structDeclarator. def visitStructDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#enumSpecifier. def visitEnumSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#enumeratorList. def visitEnumeratorList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#enumerator. def visitEnumerator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#typeQualifier. def visitTypeQualifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#functionSpecifier. def visitFunctionSpecifier(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#declarator. def visitDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#directDeclarator. def visitDirectDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#pointer. def visitPointer(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#parameterTypeList. def visitParameterTypeList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#parameterDeclaration. def visitParameterDeclaration(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#typeName. def visitTypeName(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#abstractDeclarator. def visitAbstractDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#directAbstractDeclarator. def visitDirectAbstractDeclarator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#typedefName. def visitTypedefName(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#initializer. def visitInitializer(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#initializerList. def visitInitializerList(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#designation. def visitDesignation(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#designator. def visitDesignator(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#staticAssertDeclaration. def visitStaticAssertDeclaration(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#statement. def visitStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#labeledStatement. def visitLabeledStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#compoundStatement. def visitCompoundStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#blockItem. def visitBlockItem(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#expressionStatement. def visitExpressionStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#IfStatement. def visitIfStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#SwitchStatement. def visitSwitchStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#initExpression. def visitInitExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#iterationExpression. def visitIterationExpression(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#WhileStatement. def visitWhileStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#DoWhileStatement. def visitDoWhileStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#ForStatement. def visitForStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#DeclForStatement. def visitDeclForStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#GotoStatement. def visitGotoStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#ContinueStatement. def visitContinueStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#BreakStatement. def visitBreakStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#ReturnStatement. def visitReturnStatement(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#compilationUnit. def visitCompilationUnit(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#externalDeclaration. def visitExternalDeclaration(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#functionDefinition. def visitFunctionDefinition(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#preprocessorDirective. def visitPreprocessorDirective(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#includeDirective. def visitIncludeDirective(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#defineConstantDirective. def visitDefineConstantDirective(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#defineFunctionArgs. def visitDefineFunctionArgs(self, ctx): return self.visitChildren(ctx) # Visit a parse tree produced by CParser#defineFunctionDirective. def visitDefineFunctionDirective(self, ctx): return self.visitChildren(ctx)
smartanthill/plugin-handler-compiler
smartanthill_phc/antlr_parser/CVisitor.py
Python
gpl-2.0
11,540
[ "VisIt" ]
97746dcc0f6bc8459d4ddf16fb1c980b0985e35afdee753313514d8c53468758
import lb_loader import numpy as np import pandas as pd import simtk.openmm as mm from simtk import unit as u from openmmtools import hmc_integrators, testsystems pd.set_option('display.width', 1000) platform = mm.Platform_getPlatformByName("CUDA") n_steps = 1500 temperature = 300. * u.kelvin collision_rate = 1.0 / u.picoseconds cutoff = 1.0 * u.nanometers hydrogenMass = 1.0 * u.amu testsystem = testsystems.DHFRExplicit(hydrogenMass=hydrogenMass, cutoff=cutoff) system, positions = testsystem.system, testsystem.positions positions = lb_loader.pre_equil(system, positions, temperature) platform_properties = dict(CudaPrecision="mixed") steps_per_hmc = 17 timestep = 1.5 * u.femtoseconds hmc_integrators.guess_force_groups(system, nonbonded=1, fft=1, others=0) factor = 1 groups = [(0, 2), (1, 1)] integrator = hmc_integrators.GHMCRESPA(temperature, steps_per_hmc, timestep, collision_rate, groups) context = mm.Context(system, integrator, platform, platform_properties) context.setPositions(positions) context.setVelocitiesToTemperature(temperature) integrator.step(1) integrator.step(n_steps) integrator.vstep(5) platform_properties = dict(CudaPrecision="single") steps_per_hmc = 17 timestep = 1.5 * u.femtoseconds hmc_integrators.guess_force_groups(system, nonbonded=1, fft=1, others=0) factor = 1 groups = [(0, 2), (1, 1)] integrator = hmc_integrators.GHMCRESPA(temperature, steps_per_hmc, timestep, collision_rate, groups) context = mm.Context(system, integrator, platform, platform_properties) context.setPositions(positions) context.setVelocitiesToTemperature(temperature) integrator.step(1) integrator.step(n_steps) integrator.vstep(5)
kyleabeauchamp/HMCNotes
code/old/test_ghmc_respa_compare_mixed.py
Python
gpl-2.0
1,663
[ "OpenMM" ]
a6240d9aa42b44a7738a481a0a6809db28723ca5e15de32f60dfb455fc62e843
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** ## \package pts.do.eagle.build Build visualization files for completed EAGLE SKIRT-runs. # # This script builds plots, images, movies, or info files from the results of completed EAGLE SKIRT-runs. # The resulting files are placed in the corresponding \c vis directories, replacing any previous versions. # # The script expects exactly two command-line arguments. The first argument specifies what type of files to build. # It should be one of the following strings (it is sufficient to specify an unambiguous portion of the string): # - densities: a plot with histograms of stellar, gas and dust densities in function of the galaxy radius # - greybodyfit: a plot showing a modified blackbody fit to the dust continuum emission and listing the temperature # - infofile: a text info file with statistics on the simulation results # - particles: a 3D plot of the gas particles indicating star forming, cold and hot gas in different colors # - rgbimages: an optical RGB image for each of the frame instruments # - seds: a plot combining the SEDs for all of the instruments # - temperature: a plot with a histogram of dust mass versus dust temperature # - wavemovie: a wavelength movie for the three frame instruments # # The second argument further specifies the operation that should be performed. It should be one of the following: # - the string "update" to perform the build for all completed SKIRT-runs for which the visualization files do not # yet exist. # - the string "rebuild" to perform the build for any and all all completed SKIRT-runs, even if the visualization # files already exist. Previous versions are replaced. # - a comma-seperated list of run-ids and/or run-id ranges (expressed as two run-ids with a dash in between) # for which the build should be performed. Visualization files will be rebuilt even if they already exist. # The script does not verify whether the specified SKIRT-runs have been completed. # # ----------------------------------------------------------------- # Import standard modules import sys import types import os.path # Import the relevant PTS classes and modules from pts.eagle.database import Database from pts.eagle.skirtrun import SkirtRun from pts.eagle.skirtrun import runids_in_range # ----------------------------------------------------------------- # a list of relevant filename endings for each visualization type filenames_for_vistype = { 'densities': ( "density_curves.pdf", ), 'greybodyfit': ( "dust_body_fit.pdf", ), 'infofile': ( "info.txt", ), 'particles': ( "gas_particles.pdf", ), 'rgbimages': ( "xy_total_optical.png", "xz_total_optical.png", "yz_total_optical.png", "xy_total_augmented.png", "xz_total_augmented.png", "yz_total_augmented.png" ), 'seds': ( "sed.pdf", ), 'temperature': ( "dust_temperature.pdf", ), 'wavemovie': ( "wave.mov", ), } # ----------------------------------------------------------------- # returns a list of SkirtRun objects corresponding to all completed or archived skirt-runs, in order of run-id, # optionally omitting any skirt-runs for which all files in the specified sequence exist in the visualization folder def completed_skirtruns(unless_filenames=None): db = Database() runids = sorted([ row['runid'] for row in db.select("runstatus='completed' or runstatus='archived'") ]) runs = [ SkirtRun(runid) for runid in runids ] if unless_filenames!=None: runs = filter(lambda run: not has_visualization_files(run,unless_filenames), runs) db.close() return runs # returns True if all files in the specified sequence exist in the visualization folder of the specified skirt-run def has_visualization_files(skirtrun, filenames): filenames = filenames if isinstance(filenames, (types.TupleType,types.ListType)) else [ filenames ] vispath = skirtrun.vispath() prefix = skirtrun.prefix() for filename in filenames: if not os.path.isfile(os.path.join(vispath, prefix+"_"+filename)): return False return True # move any of the files in the specified sequence from the skirt-run output directory to the visualization directory def move_visualization_files(skirtrun, filenames): for visfile in filter(lambda fn: fn.endswith(filenames), os.listdir(skirtrun.outpath())): os.rename(os.path.join(skirtrun.outpath(), visfile), os.path.join(skirtrun.vispath(), visfile)) # ----------------------------------------------------------------- # get and parse the command-line arguments if len(sys.argv) != 3: raise ValueError("This script expects exactly two command-line arguments") vistype = sys.argv[1].lower() found = False for knowntype in filenames_for_vistype.keys(): if knowntype.startswith(vistype): vistype = knowntype found = True break if not found: raise ValueError("Unknown visualization type: " + vistype) buildrange = sys.argv[2].lower() update = "update".startswith(buildrange) rebuild = "rebuild".startswith(buildrange) runidrange = runids_in_range(buildrange) if not update and not rebuild and not runidrange: raise ValueError("Unknown build range: " + buildrange) # ----------------------------------------------------------------- # get a list of relevant filename endings depending on the visualization type filenames = filenames_for_vistype[vistype] # construct the list of SKIRT-runs to be processed if runidrange: skirtruns = [ SkirtRun(runid) for runid in runidrange ] else: skirtruns = completed_skirtruns(filenames if update else None) # ================================================================= # build density curves if vistype=='densities': from pts.eagle.plotdensitycurves import plotdensitycurves print "Building density curves for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building density curves for SKIRT-run {}...".format(skirtrun.runid()) plotdensitycurves(skirtrun) # ----------------------------------------------------------------- # build grey body fits if vistype=='greybodyfit': from pts.eagle.plotgreybodyfit import plotgreybodyfit print "Building grey body fits for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building grey body fit for SKIRT-run {}...".format(skirtrun.runid()) plotgreybodyfit(skirtrun) # ----------------------------------------------------------------- # build info files if vistype=='infofile': from pts.eagle.makeinfofile import makeinfofile print "Building info files for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building info file for SKIRT-run {}...".format(skirtrun.runid()) makeinfofile(skirtrun) move_visualization_files(skirtrun, filenames) # ----------------------------------------------------------------- # build gas particle plots if vistype=='particles': from pts.eagle.plotgasparticles import plotgasparticles print "Building gas particle plots for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building gas particle plot for SKIRT-run {}...".format(skirtrun.runid()) plotgasparticles(skirtrun) # ----------------------------------------------------------------- # build RGB images if vistype=='rgbimages': from pts.core.plot.rgbimages import makeintegratedrgbimages from pts.core.basics.filter import Filter print "Building RGB images for {} SKIRT-runs".format(len(skirtruns)) filterR = Filter('SDSS.i') filterG = Filter('SDSS.r') filterB = Filter('SDSS.g') filterIR = Filter('Pacs.green') filterUV = Filter('GALEX.FUV') for skirtrun in skirtruns: print "Building RGB images for SKIRT-run {}...".format(skirtrun.runid()) fmin,fmax = makeintegratedrgbimages(skirtrun.simulation(), [ (filterR, 1,0,0), (filterG, 0,1,0), (filterB, 0,0,1) ], postfix="_optical") makeintegratedrgbimages(skirtrun.simulation(), [ (filterR, 1,0,0), (filterG, 0,1,0), (filterB, 0,0,1), (filterIR, 0.02,0,0), (filterUV, 0,0,4) ], postfix="_augmented", fmin=fmin, fmax=fmax) move_visualization_files(skirtrun, filenames) # ----------------------------------------------------------------- # build SED plots for each SKIRT-run if vistype=='seds': from pts.core.plot.seds import plotseds print "Building SED plots for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building SED plot for SKIRT-run {}...".format(skirtrun.runid()) plotseds(skirtrun.simulation()) move_visualization_files(skirtrun, filenames) # ----------------------------------------------------------------- # build temperature histograms if vistype=='temperature': from pts.eagle.plottemperature import plottemperature print "Building temperature histograms for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building temperature histogram for SKIRT-run {}...".format(skirtrun.runid()) plottemperature(skirtrun) # ----------------------------------------------------------------- # build wavelength movies for each SKIRT-run if vistype=='wavemovie': from pts.core.plot.wavemovie import makewavemovie print "Building wavelength movies for {} SKIRT-runs".format(len(skirtruns)) for skirtrun in skirtruns: print "Building wavelength movie for SKIRT-run {}...".format(skirtrun.runid()) makewavemovie(skirtrun.simulation()) move_visualization_files(skirtrun, filenames) print "Done..." # -----------------------------------------------------------------
Stargrazer82301/CAAPR
CAAPR/CAAPR_AstroMagic/PTS/pts/do/eagle/build.py
Python
mit
10,025
[ "Galaxy" ]
378e68f0274516a76c47ebe223e5c8caca2a0d049537c9c7636f9137d01ddd43
"""Runs the main game loop and user interface. """ import os, sys from copy import copy, deepcopy import actions from Character import Character from Character import Character from Weapon import Weapon from Spell import Spell EMPTY_LINE = '{}{:>141}'.format('#', '#\n') BORDER_LINE = "{:#>142}".format("\n") def enemy(side): """Return the side opposite of the given side.""" if side == 'top': return 'bottom' elif side == 'bottom': return 'top' else: raise Exception('Invalid side: %s' % side) def clear(): os.system('cls' if os.name == 'nt' else 'clear') def refresh(board): """Clear the board and redraw it.""" clear() #print board # Border out = "\n" out += BORDER_LINE # Hand, Deck and Mana deckOut = "Deck: %d " % board.decks['top'].size manaOut = "Mana: {%d/%d}" % (board.manaCurrent['top'], board.manaBase['top']) out += "{}{:>137}{}".format('# ', deckOut+manaOut, ' #\n') handOut = str(board.hands['top']) out += "{}{:<137}{}".format('# ', handOut, ' #\n') out += EMPTY_LINE out += EMPTY_LINE # Hero if board.heroes['top'] is None: out += "{}{:^137}{}".format('# ', "None", ' #\n') else: out += "{}{:^137}{}".format('# ', str(board.heroes['top']), ' #\n') out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE # Minions minionOut = [] for m in board.minions['top']: if m is None: minionOut.append("__") else: minionOut.append(' ' + str(m) + ' ') minOut = ['# ',] minOut.extend(minionOut) minOut.extend([' #\n']) out += "{:<4}{:^19}{:^19}{:^19}{:^19}{:^19}{:^19}{:^19}{:>5}".format(*minOut) out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE minionOut = [] for m in board.minions['bottom']: if m is None: minionOut.append("__") else: minionOut.append(' ' + str(m) + ' ') minOut = ['# ',] minOut.extend(minionOut) minOut.extend([' #\n']) out += "{:<4}{:^19}{:^19}{:^19}{:^19}{:^19}{:^19}{:^19}{:>5}".format(*minOut) out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE out += EMPTY_LINE # Hero if board.heroes['bottom'] is None: out += "{}{:^137}{}".format('#', "None", ' #\n') else: out += "{}{:^137}{}".format('# ', str(board.heroes['bottom']), ' #\n') out += EMPTY_LINE out += EMPTY_LINE # Hand, Deck and Mana handOut = str(board.hands['bottom']) out += "{}{:<137}{}".format('# ', handOut, ' #\n') deckOut = "Deck: %d " % board.decks['bottom'].size manaOut = "Mana: {%d/%d}" % (board.manaCurrent['bottom'], board.manaBase['bottom']) out += "{}{:>137}{}".format('# ', deckOut+manaOut, ' #\n') # Border out += BORDER_LINE log = board.get_log() for line in log[-5:]: out += "{:<140}".format(line.strip()) out += "\n" print out def check_if_game_over(board): """End the game if a hero is dead.""" if (board.get_hero(side='top').currentHealth <= 0): print "\n\nBottom player wins. Thank you for playing." sys.exit() elif (board.get_hero(side='bottom').currentHealth <= 0): print "\n\nTop player wins. Thank you for playing." sys.exit() def play_loop(board, ai=None, ai2=None): """The highest level of the loop. Allow player to decide what actions to take, or end the turn.""" while True: refresh(board) check_if_game_over(board) # If enemy turn, let the AI play. if board.get_side() == "top" and ai is not None: board.set_text("AI turn.") ai.play_turn(board) continue if board.get_side() == "bottom" and ai2 is not None: board.set_text("AI_2 turn.") ai2.play_turn(board) continue # Ask for instructions command = None while command not in ['p', 'a', 'h', 'e', 'q']: refresh(board) command = raw_input("{:<140}".format("<p> Play Card <a> Attack w/ Char <h> Hero Power <e> End Turn <q> Quit\n")) # Execute insructions if command == 'q': sys.exit() elif command == 'p': play_card(board) continue elif command == 'a': select_attacker(board) continue elif command == 'h': continue elif command == 'e': end_turn(board) continue def play_card(board): """Spend mana to play a card.""" while True: hand = board.get_hand() # Check if there are any cards to play. playableCardPos = hand.get_playable_card_positions() if not len(playableCardPos): board.set_text("No cards to play.") break # Give options and request instructions play_choices = ['b', 'q'] play_choices.extend([str(x) for x in playableCardPos]) command = None while command not in play_choices: refresh(board) outLine = "Select a card: " for i in playableCardPos: outLine += "<%d> %s " % (i, hand.cards[i-1].name) outLine += " <b> Back <q> Quit\n" command = raw_input("{:<140}".format(outLine)) # Execute instruction if command == 'q': sys.exit() elif command == 'b': break else: pos = int(command) cardToPlay = hand.get_card(pos) board.set_text('Playing %s' % cardToPlay.name) if isinstance(cardToPlay.contents, Character): play_character_from_hand(board, cardToPlay) elif isinstance(cardToPlay.contents, Spell): actions.play_spell_card(board, cardToPlay) elif isinstance(cardToPlay.contents, Weapon): play_weapon_from_hand(board, cardToPlay) else: raise Exception('Invalid card type.') break def play_character_from_hand(board, cardToPlay): while True: """Try to play a minion from the hand. Doing so causes a battlecry.""" # Check if there is room to place the minion. emptyMinionPos = board.get_empty_minion_positions() if not len(emptyMinionPos): board.set_text("Not enough room for more minions.") break # Give the available positions to drop minion and request instructions. play_choices = ['b', 'q'] play_choices.extend([str(x) for x in emptyMinionPos]) command = None while command not in play_choices: refresh(board) outLine = "Choose spot to play minion: " for i in emptyMinionPos: outLine += "<%d> " % i outLine += " <b> Back <q> Quit\n" command = raw_input("{:<140}".format(outLine)) # Execute instructions if command == 'q': sys.exit() elif command == 'b': break else: # Play the minion pos = int(command) actions.play_minion_card(board, cardToPlay, pos) break def play_weapon_from_hand(board, cardToPlay): """Equip a weapon.""" side = board.playerTurn weapon = cardToPlay.contents # Equip Weapon board.set_text("Equipping %s. (Not implemented yet)." % weapon.name) # Remove from hand and reduce players mana. board.hands[side].remove_card(cardToPlay) board.manaCurrent[side] -= weapon.manaCost def select_attacker(board): """Select a minion to use to do some attacking. If valid attacker and defender are choosen, perform the attack.""" while True: # Check if there are any characters that can attack. canAttackPos = board.get_canAttack_char_positions() if not len(canAttackPos): board.set_text("No characters can attack.") break # Give options for attacker and ask for instructions. play_choices = ['b', 'q'] play_choices.extend([str(x) for x in canAttackPos]) command = None while command not in play_choices: refresh(board) outLine = "Select char to attack with: " for i in canAttackPos: outLine += "<%d> %s " % (i, board.get_character(i).name) outLine += " <b> Back [q] Quit\n" command = raw_input("{:<140}".format(outLine)) # Execute instructions if command == 'q': sys.exit() elif command == 'b': break else: pos = int(command) attacker = board.get_character(pos) defender = select_target(board, attacker) if defender is None: break actions.minion_attack(board, attacker, defender) break def select_target(board, attacker): """Currently, a player can only attack an enemy. To change this, check the attackers targeting powers and cross-check that with every characters side attribute.""" while True: # Check if there are any enemies to attack. attackableCharacters = board.get_targetable_characters(attacker) for character in attackableCharacters: print character.name if not len(attackableCharacters): board.set_text("No characters to attack.") return None attackableCharacters.sort(key=lambda char: int(board.get_target_pos(char))) # Give available choices and ask for instructions. play_choices = ['b', 'q'] for char in attackableCharacters: play_choices.append(str(board.get_target_pos(char))) command = None while command not in play_choices: refresh(board) outLine = "Choose enemy to attack: " for char in attackableCharacters: pos = board.get_target_pos(char) outLine += "<%d> %s " % (pos, char.name) outLine += " <b> Back <q> Quit\n" command = raw_input("{:<140}".format(outLine)) # Execute instructions. if command == 'q': sys.exit() elif command == 'b': return None else: pos = int(command) target = board.get_character_by_position(pos) return target def end_turn(board): """End the turn and take necessary actions.""" # Do stuff here, like end of turn effects. # Check if either hero is dead. check_if_game_over(board) begin_turn(board) def begin_turn(board): """Begin the turn and take necessary actions.""" # Increase counter and switch sides. if board.get_side() == 'bottom': board.set_text("Player Turn.") board.increment_turn() board.change_side() # Add mana crystal and reset mana count to full. board.update_mana() # Reset the attacks of characters on this side. board.reset_attacksRemaining() # Draw a card. actions.draw_card(board, board.get_side())
tomhettinger/simplestone
gameboard/loop.py
Python
mit
11,292
[ "CRYSTAL" ]
0ca4343eca48eded8f0d5cd1fe757c20f2b5f1bc8188ee4705a2ce75f0163e4d
"""Unit tests of MQConsumer interface in the DIRAC.Resources.MessageQueue.MQConsumer """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import unittest from DIRAC import S_OK from DIRAC.Resources.MessageQueue.MQConsumer import MQConsumer from DIRAC.Resources.MessageQueue.MQConnectionManager import MQConnectionManager from DIRAC.Resources.MessageQueue.MQConnector import MQConnector class FakeMQConnector(MQConnector): def __init__(self, params={}): super(FakeMQConnector, self).__init__() def disconnect(self): return S_OK("FakeMQConnection disconnecting") def get(self, destination=""): return "FakeMQConnection getting message" def subscribe(self, parameters=None): return S_OK("Subscription successful") def unsubscribe(self, parameters): return S_OK("Unsubscription successful") class TestMQConsumer(unittest.TestCase): def setUp(self): self.maxDiff = None # To show full difference between structures in case of error dest = {} dest.update({"/queue/FakeQueue": ["consumer4", "consumer2"]}) dest4 = {"/queue/test3": ["consumer1", "consumer2", "consumer3", "consumer4"]} conn1 = {"MQConnector": FakeMQConnector(), "destinations": dest} conn2 = {"MQConnector": FakeMQConnector(), "destinations": dest4} storage = {"fake.cern.ch": conn1, "testdir.blabla.ch": conn2} self.myManager = MQConnectionManager(connectionStorage=storage) def tearDown(self): pass class TestMQConsumer_get(TestMQConsumer): def test_failure(self): consumer = MQConsumer(mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId="consumer1") result = consumer.get() self.assertFalse(result["OK"]) self.assertEqual(result["Message"], "No messages ( 1141 : No messages in queue)") def test_sucess(self): consumer = MQConsumer(mqManager=self.myManager, mqURI="bad.cern.ch::Queues::FakeQueue", consumerId="consumer1") result = consumer.get() self.assertFalse(result["OK"]) class TestMQConsumer_close(TestMQConsumer): def test_success(self): consumer = MQConsumer(mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId="consumer4") result = consumer.close() self.assertTrue(result["OK"]) def test_failure(self): consumer = MQConsumer(mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId="consumer4") result = consumer.close() self.assertTrue(result["OK"]) result = consumer.close() self.assertFalse(result["OK"]) self.assertEqual( result["Message"], "MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer4 does not exist!)", ) def test_failure2(self): consumer = MQConsumer(mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId="consumer4") consumer2 = MQConsumer( mqManager=self.myManager, mqURI="fake.cern.ch::Queues::FakeQueue", consumerId="consumer2" ) result = consumer.close() self.assertTrue(result["OK"]) result = consumer.close() self.assertFalse(result["OK"]) self.assertEqual( result["Message"], "MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer4 does not exist!)", ) result = consumer2.close() self.assertTrue(result["OK"]) result = consumer2.close() self.assertFalse(result["OK"]) self.assertEqual( result["Message"], "MQ connection failure ( 1142 : Failed to stop the connection!The messenger consumer2 does not exist!)", ) if __name__ == "__main__": suite = unittest.defaultTestLoader.loadTestsFromTestCase(TestMQConsumer) suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestMQConsumer_get)) suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestMQConsumer_close)) testResult = unittest.TextTestRunner(verbosity=2).run(suite)
ic-hep/DIRAC
src/DIRAC/Resources/MessageQueue/test/Test_MQConsumer.py
Python
gpl-3.0
4,195
[ "DIRAC" ]
0ba199f9219dd116d8710301af0754759ea03c1085aebfb9c82a5378b50aeca5