Writing LAS files¶
Any LASFile object can be written to a new LAS file using the
lasio.LASFile.write()
method.
Converting between v1.2 and v2.0¶
Take this sample LAS 2.0 file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ~VERSION INFORMATION VERS. 2.0 : CWLS LOG ASCII STANDARD -VERSION 2.0 WRAP. NO : ONE LINE PER DEPTH STEP ~WELL INFORMATION #MNEM.UNIT DATA DESCRIPTION #----- ----- ---------- ------------------------- STRT .M 1670.0000 :START DEPTH STOP .M 1660.0000 :STOP DEPTH STEP .M -0.1250 :STEP NULL . -999.25 :NULL VALUE COMP . ANY OIL COMPANY INC. :COMPANY WELL . AAAAA_2 :WELL FLD . WILDCAT :FIELD LOC . 12-34-12-34W5M :LOCATION PROV . ALBERTA :PROVINCE SRVC . ANY LOGGING COMPANY INC. :SERVICE COMPANY DATE . 13-DEC-86 :LOG DATE UWI . 100123401234W500 :UNIQUE WELL ID ~CURVE INFORMATION #MNEM.UNIT API CODES CURVE DESCRIPTION #------------------ ------------ ------------------------- DEPT .M : 1 DEPTH DT .US/M 60 520 32 00 : 2 SONIC TRANSIT TIME RHOB .K/M3 45 350 01 00 : 3 BULK DENSITY NPHI .V/V 42 890 00 00 : 4 NEUTRON POROSITY SFLU .OHMM 07 220 04 00 : 5 SHALLOW RESISTIVITY SFLA .OHMM 07 222 01 00 : 6 SHALLOW RESISTIVITY ILM .OHMM 07 120 44 00 : 7 MEDIUM RESISTIVITY ILD .OHMM 07 120 46 00 : 8 DEEP RESISTIVITY ~PARAMETER INFORMATION #MNEM.UNIT VALUE DESCRIPTION #-------------- ---------------- ----------------------------------------------- MUD . GEL CHEM : MUD TYPE BHT .DEGC 35.5000 : BOTTOM HOLE TEMPERATURE BS .MM 200.0000 : BIT SIZE FD .K/M3 1000.0000 : FLUID DENSITY MATR . SAND : NEUTRON MATRIX MDEN . 2710.0000 : LOGGING MATRIX DENSITY RMF .OHMM 0.2160 : MUD FILTRATE RESISTIVITY DFD .K/M3 1525.0000 : DRILL FLUID DENSITY ~OTHER Note: The logging tools became stuck at 625 metres causing the data between 625 metres and 615 metres to be invalid. ~A DEPTH DT RHOB NPHI SFLU SFLA ILM ILD 1670.000 123.450 2550.000 0.450 123.450 123.450 110.200 105.600 1669.875 123.450 2550.000 0.450 123.450 123.450 110.200 105.600 1669.750 123.450 2550.000 0.450 123.450 123.450 110.200 105.600 |
And we can use lasio to convert it to LAS 1.2:
>>> las = lasio.examples.open("2.0/sample_2.0.las")
>>> las.write('example-as-v1.2.las', version=1.2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ~Version --------------------------------------------------- VERS. 1.2 : CWLS LOG ASCII STANDARD - VERSION 1.2 WRAP. NO : ONE LINE PER DEPTH STEP ~Well ------------------------------------------------------ STRT.M 1670.0 : START DEPTH STOP.M 1669.75 : STOP DEPTH STEP.M -0.125 : STEP NULL. -999.25 : NULL VALUE COMP. COMPANY : ANY OIL COMPANY INC. WELL. WELL : AAAAA_2 FLD . FIELD : WILDCAT LOC . LOCATION : 12-34-12-34W5M PROV. PROVINCE : ALBERTA SRVC. SERVICE COMPANY : ANY LOGGING COMPANY INC. DATE. LOG DATE : 13-DEC-86 UWI . UNIQUE WELL ID : 100123401234W500 ~Curves ---------------------------------------------------- DEPT.M : 1 DEPTH DT .US/M 60 520 32 00 : 2 SONIC TRANSIT TIME RHOB.K/M3 45 350 01 00 : 3 BULK DENSITY NPHI.V/V 42 890 00 00 : 4 NEUTRON POROSITY SFLU.OHMM 07 220 04 00 : 5 SHALLOW RESISTIVITY SFLA.OHMM 07 222 01 00 : 6 SHALLOW RESISTIVITY ILM .OHMM 07 120 44 00 : 7 MEDIUM RESISTIVITY ILD .OHMM 07 120 46 00 : 8 DEEP RESISTIVITY ~Params ---------------------------------------------------- MUD . GEL CHEM : MUD TYPE BHT .DEGC 35.5 : BOTTOM HOLE TEMPERATURE BS .MM 200.0 : BIT SIZE FD .K/M3 1000.0 : FLUID DENSITY MATR. SAND : NEUTRON MATRIX MDEN. 2710.0 : LOGGING MATRIX DENSITY RMF .OHMM 0.216 : MUD FILTRATE RESISTIVITY DFD .K/M3 1525.0 : DRILL FLUID DENSITY ~Other ----------------------------------------------------- Note: The logging tools became stuck at 625 metres causing the data between 625 metres and 615 metres to be invalid. ~ASCII ----------------------------------------------------- 1670 123.45 2550 0.45 123.45 123.45 110.2 105.6 1669.9 123.45 2550 0.45 123.45 123.45 110.2 105.6 1669.8 123.45 2550 0.45 123.45 123.45 110.2 105.6 |
Converting between wrapped/unwrapped¶
Here is an example using this file to convert a wrapped data section to unwrapped.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | ~Version Information VERS. 1.20: CWLS log ASCII Standard -VERSION 1.20 WRAP. YES: Multiple lines per depth step ~Well Information #MNEM.UNIT Data Type Information #--------- ------------- ------------------------------ STRT.M 910.000: STOP.M 901.000: STEP.M -0.1250: NULL. -999.2500: Null value COMP. COMPANY: ANY OIL COMPANY INC. WELL. WELL: ANY ET AL XX-XX-XX-XX FLD . FIELD: WILDCAT LOC . LOCATION: XX-XX-XX-XXW3M PROV. PROVINCE: SASKATCHEWAN SRVC. SERVICE COMPANY: ANY LOGGING COMPANY INC. SON . SERVICE ORDER : 142085 DATE. LOG DATE: 13-DEC-86 UWI . UNIQUE WELL ID: ~Curve Information #MNEM.UNIT API CODE Curve Description #--------- ------------- ------------------------------ DEPT.M : Depth DT .US/M : 1 Sonic Travel Time RHOB.K/M : 2 Density-Bulk Density NPHI.V/V : 3 Porosity -Neutron RX0 .OHMM : 4 Resistivity -Rxo RESS.OHMM : 5 Resistivity -Shallow RESM.OHMM : 6 Resistivity -Medium RESD.OHMM : 7 Resistivity -Deep SP .MV : 8 Spon. Potential GR .GAPI : 9 Gamma Ray CALI.MM : 10 Caliper DRHO.K/M3 : 11 Delta-Rho EATT.DBM : 12 EPT Attenuation TPL .NS/M : 13 TP -EPT PEF . : 14 PhotoElectric Factor FFI .V/V : 15 Porosity -NML FFI DCAL.MM : 16 Caliper-Differential RHGF.K/M3 : 17 Density-Formation RHGA.K/M3 : 18 Density-Apparent SPBL.MV : 19 Baselined SP GRC .GAPI : 20 Gamma Ray BHC PHIA.V/V : 21 Porosity -Apparent PHID.V/V : 22 Porosity -Density PHIE.V/V : 23 Porosity -Effective PHIN.V/V : 24 Porosity -Neut BHC PHIC.V/V : 25 Porosity -Total HCC R0 .OHMM : 26 Ro RWA .OHMM : 27 Rfa SW . : 28 Sw -Effective MSI . : 29 Sh Idx -Min BVW . : 30 BVW FGAS. : 31 Flag -Gas Index PIDX. : 32 Prod Idx FBH . : 33 Flag -Bad Hole FHCC. : 34 Flag -HC Correction LSWB. : 35 Flag -Limit SWB ~A Log data section 910.000000 -999.2500 2692.7075 0.3140 19.4086 19.4086 13.1709 12.2681 -1.5010 96.5306 204.7177 30.5822 -999.2500 -999.2500 3.2515 -999.2500 4.7177 3025.0264 3025.0264 -1.5010 93.1378 0.1641 0.0101 0.1641 0.3140 0.1641 11.1397 0.3304 0.9529 0.0000 0.1564 0.0000 11.1397 0.0000 0.0000 0.0000 909.875000 -999.2500 2712.6460 0.2886 23.3987 23.3987 13.6129 12.4744 -1.4720 90.2803 203.1093 18.7566 -999.2500 -999.2500 3.7058 -999.2500 3.1093 3004.6050 3004.6050 -1.4720 86.9078 0.1456 -0.0015 0.1456 0.2886 0.1456 14.1428 0.2646 1.0000 0.0000 0.1456 0.0000 14.1428 0.0000 0.0000 0.0000 909.750000 -999.2500 2692.8137 0.2730 22.5909 22.5909 13.6821 12.6146 -1.4804 89.8492 201.9287 3.1551 -999.2500 -999.2500 4.3124 -999.2500 1.9287 2976.4451 2976.4451 -1.4804 86.3465 0.1435 0.0101 0.1435 0.2730 0.1435 14.5674 0.2598 1.0000 0.0000 0.1435 0.0000 14.5674 0.0000 0.0000 0.0000 909.625000 -999.2500 2644.3650 0.2765 18.4831 18.4831 13.4159 12.6900 -1.5010 93.3999 201.5826 -6.5861 -999.2500 -999.2500 4.3822 -999.2500 1.5826 2955.3528 2955.3528 -1.5010 89.7142 0.1590 0.0384 0.1590 0.2765 0.1590 11.8600 0.3210 0.9667 0.0000 0.1538 0.0000 11.8600 0.0000 0.0000 0.0000 909.500000 -999.2500 2586.2822 0.2996 13.9187 13.9187 12.9195 12.7016 -1.4916 98.1214 201.7126 -4.5574 -999.2500 -999.2500 3.5967 -999.2500 1.7126 2953.5940 2953.5940 -1.4916 94.2670 0.1880 0.0723 0.1880 0.2996 0.1880 8.4863 0.4490 0.8174 0.0000 0.1537 0.0000 8.4863 0.0000 0.0000 0.0000 |
We will change the wrap by adjusting the relevant header section in the LASFile header:
>>> las.version
[HeaderItem(mnemonic="VERS", unit="", value="1.2", descr="CWLS log ASCII Standa"),
HeaderItem(mnemonic="WRAP", unit="", value="YES", descr="Multiple lines per de")]
>>> las.version.WRAP = 'NO'
>>> las.version.WRAP
HeaderItem(mnemonic="WRAP", unit="", value="NO", descr="Multiple lines per dep")
>>> las.write('example-unwrapped.las')
WARNING:lasio.writer:[v1.2] line #58 has 396 chars (>256)
WARNING:lasio.writer:[v1.2] line #59 has 396 chars (>256)
WARNING:lasio.writer:[v1.2] line #60 has 396 chars (>256)
WARNING:lasio.writer:[v1.2] line #61 has 396 chars (>256)
WARNING:lasio.writer:[v1.2] line #62 has 396 chars (>256)
We get warnings because the LAS 1.2 standard doesn’t allow writing lines longer than 256 characters. lasio provides the warning but still produces the long lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ~Version --------------------------------------------------- VERS. 1.2 : CWLS LOG ASCII STANDARD - VERSION 1.2 WRAP. NO : Multiple lines per depth step ~Well ------------------------------------------------------ STRT.M 910.0 : STOP.M 909.5 : STEP.M -0.125 : NULL. -999.25 : Null value COMP. COMPANY : ANY OIL COMPANY INC. WELL. WELL : ANY ET AL XX-XX-XX-XX FLD . FIELD : WILDCAT LOC . LOCATION : XX-XX-XX-XXW3M PROV. PROVINCE : SASKATCHEWAN SRVC. SERVICE COMPANY : ANY LOGGING COMPANY INC. SON . SERVICE ORDER : 142085 DATE. LOG DATE : 13-DEC-86 UWI . UNIQUE WELL ID : ~Curves ---------------------------------------------------- DEPT.M : Depth DT .US/M : 1 Sonic Travel Time RHOB.K/M : 2 Density-Bulk Density NPHI.V/V : 3 Porosity -Neutron RX0 .OHMM : 4 Resistivity -Rxo RESS.OHMM : 5 Resistivity -Shallow RESM.OHMM : 6 Resistivity -Medium RESD.OHMM : 7 Resistivity -Deep SP .MV : 8 Spon. Potential GR .GAPI : 9 Gamma Ray CALI.MM : 10 Caliper DRHO.K/M3 : 11 Delta-Rho EATT.DBM : 12 EPT Attenuation TPL .NS/M : 13 TP -EPT PEF . : 14 PhotoElectric Factor FFI .V/V : 15 Porosity -NML FFI DCAL.MM : 16 Caliper-Differential RHGF.K/M3 : 17 Density-Formation RHGA.K/M3 : 18 Density-Apparent SPBL.MV : 19 Baselined SP GRC .GAPI : 20 Gamma Ray BHC PHIA.V/V : 21 Porosity -Apparent PHID.V/V : 22 Porosity -Density PHIE.V/V : 23 Porosity -Effective PHIN.V/V : 24 Porosity -Neut BHC PHIC.V/V : 25 Porosity -Total HCC R0 .OHMM : 26 Ro RWA .OHMM : 27 Rfa SW . : 28 Sw -Effective MSI . : 29 Sh Idx -Min BVW . : 30 BVW FGAS. : 31 Flag -Gas Index PIDX. : 32 Prod Idx FBH . : 33 Flag -Bad Hole FHCC. : 34 Flag -HC Correction LSWB. : 35 Flag -Limit SWB ~Params ---------------------------------------------------- ~Other ----------------------------------------------------- ~ASCII ----------------------------------------------------- 910 -999.25 2692.7 0.314 19.409 19.409 13.171 12.268 -1.501 96.531 204.72 30.582 -999.25 -999.25 3.2515 -999.25 4.7177 3025 3025 -1.501 93.138 0.1641 0.0101 0.1641 0.314 0.1641 11.14 0.3304 0.9529 0 0.1564 0 11.14 0 0 0 909.88 -999.25 2712.6 0.2886 23.399 23.399 13.613 12.474 -1.472 90.28 203.11 18.757 -999.25 -999.25 3.7058 -999.25 3.1093 3004.6 3004.6 -1.472 86.908 0.1456 -0.0015 0.1456 0.2886 0.1456 14.143 0.2646 1 0 0.1456 0 14.143 0 0 0 909.75 -999.25 2692.8 0.273 22.591 22.591 13.682 12.615 -1.4804 89.849 201.93 3.1551 -999.25 -999.25 4.3124 -999.25 1.9287 2976.4 2976.4 -1.4804 86.347 0.1435 0.0101 0.1435 0.273 0.1435 14.567 0.2598 1 0 0.1435 0 14.567 0 0 0 909.62 -999.25 2644.4 0.2765 18.483 18.483 13.416 12.69 -1.501 93.4 201.58 -6.5861 -999.25 -999.25 4.3822 -999.25 1.5826 2955.4 2955.4 -1.501 89.714 0.159 0.0384 0.159 0.2765 0.159 11.86 0.321 0.9667 0 0.1538 0 11.86 0 0 0 909.5 -999.25 2586.3 0.2996 13.919 13.919 12.919 12.702 -1.4916 98.121 201.71 -4.5574 -999.25 -999.25 3.5967 -999.25 1.7126 2953.6 2953.6 -1.4916 94.267 0.188 0.0723 0.188 0.2996 0.188 8.4863 0.449 0.8174 0 0.1537 0 8.4863 0 0 0 |
If we decide to write the file in LAS 2.0 format, the warnings will go away:
>>> las.write('example-version-2.0.las', version=2.0)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ~Version --------------------------------------------------- VERS. 2.0 : CWLS log ASCII Standard -VERSION 2.0 WRAP. NO : Multiple lines per depth step ~Well ------------------------------------------------------ STRT.M 910.0 : STOP.M 909.5 : STEP.M -0.125 : NULL. -999.25 : Null value COMP. ANY OIL COMPANY INC. : COMPANY WELL. ANY ET AL XX-XX-XX-XX : WELL FLD . WILDCAT : FIELD LOC . XX-XX-XX-XXW3M : LOCATION PROV. SASKATCHEWAN : PROVINCE SRVC. ANY LOGGING COMPANY INC. : SERVICE COMPANY SON . 142085 : SERVICE ORDER DATE. 13-DEC-86 : LOG DATE UWI . : UNIQUE WELL ID ~Curves ---------------------------------------------------- DEPT.M : Depth DT .US/M : 1 Sonic Travel Time RHOB.K/M : 2 Density-Bulk Density NPHI.V/V : 3 Porosity -Neutron RX0 .OHMM : 4 Resistivity -Rxo RESS.OHMM : 5 Resistivity -Shallow RESM.OHMM : 6 Resistivity -Medium RESD.OHMM : 7 Resistivity -Deep SP .MV : 8 Spon. Potential GR .GAPI : 9 Gamma Ray CALI.MM : 10 Caliper DRHO.K/M3 : 11 Delta-Rho EATT.DBM : 12 EPT Attenuation TPL .NS/M : 13 TP -EPT PEF . : 14 PhotoElectric Factor FFI .V/V : 15 Porosity -NML FFI DCAL.MM : 16 Caliper-Differential RHGF.K/M3 : 17 Density-Formation RHGA.K/M3 : 18 Density-Apparent SPBL.MV : 19 Baselined SP GRC .GAPI : 20 Gamma Ray BHC PHIA.V/V : 21 Porosity -Apparent PHID.V/V : 22 Porosity -Density PHIE.V/V : 23 Porosity -Effective PHIN.V/V : 24 Porosity -Neut BHC PHIC.V/V : 25 Porosity -Total HCC R0 .OHMM : 26 Ro RWA .OHMM : 27 Rfa SW . : 28 Sw -Effective MSI . : 29 Sh Idx -Min BVW . : 30 BVW FGAS. : 31 Flag -Gas Index PIDX. : 32 Prod Idx FBH . : 33 Flag -Bad Hole FHCC. : 34 Flag -HC Correction LSWB. : 35 Flag -Limit SWB ~Params ---------------------------------------------------- ~Other ----------------------------------------------------- ~ASCII ----------------------------------------------------- 910 -999.25 2692.7 0.314 19.409 19.409 13.171 12.268 -1.501 96.531 204.72 30.582 -999.25 -999.25 3.2515 -999.25 4.7177 3025 3025 -1.501 93.138 0.1641 0.0101 0.1641 0.314 0.1641 11.14 0.3304 0.9529 0 0.1564 0 11.14 0 0 0 909.88 -999.25 2712.6 0.2886 23.399 23.399 13.613 12.474 -1.472 90.28 203.11 18.757 -999.25 -999.25 3.7058 -999.25 3.1093 3004.6 3004.6 -1.472 86.908 0.1456 -0.0015 0.1456 0.2886 0.1456 14.143 0.2646 1 0 0.1456 0 14.143 0 0 0 909.75 -999.25 2692.8 0.273 22.591 22.591 13.682 12.615 -1.4804 89.849 201.93 3.1551 -999.25 -999.25 4.3124 -999.25 1.9287 2976.4 2976.4 -1.4804 86.347 0.1435 0.0101 0.1435 0.273 0.1435 14.567 0.2598 1 0 0.1435 0 14.567 0 0 0 909.62 -999.25 2644.4 0.2765 18.483 18.483 13.416 12.69 -1.501 93.4 201.58 -6.5861 -999.25 -999.25 4.3822 -999.25 1.5826 2955.4 2955.4 -1.501 89.714 0.159 0.0384 0.159 0.2765 0.159 11.86 0.321 0.9667 0 0.1538 0 11.86 0 0 0 909.5 -999.25 2586.3 0.2996 13.919 13.919 12.919 12.702 -1.4916 98.121 201.71 -4.5574 -999.25 -999.25 3.5967 -999.25 1.7126 2953.6 2953.6 -1.4916 94.267 0.188 0.0723 0.188 0.2996 0.188 8.4863 0.449 0.8174 0 0.1537 0 8.4863 0 0 0 |
Formatting data section columns¶
The keyword parameters that control the column spacing in the data section are, the left-hand spacer, lhs_spacer, and the in-between column spacer, spacer. They are both set to one space by default.
Use the len_numeric_field parameter to configure the padding within the numeric data fields.
The following examples will use lasio/tests/examples/2.0/sample_2.0.las. It’s data section looks like this:
~A DEPTH DT RHOB NPHI SFLU SFLA ILM ILD
1670.000 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
1669.875 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
1669.750 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
Default data section formatting¶
If this file is read in and then written, the data section is formatted like this by default:
import lasio.examples
from lasio.reader import StringIO
las = lasio.examples.open("2.0/sample_2.0.las")
s = StringIO()
las.write(s)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
The default settings are:
len_numeric_field defaults to 10 characters
5 digits to the right of the decimal
1 character for the decimal
4 digits for the number to the left of the decimal
- if there are less than 4 digits, the field is padded with blank spaces
- if there are more than 4 digits, the field is expanded to include all the digits
lhs_spacer defaults to 1 space. So the data is indented by one space.
spacer defaults to 1 space. So data columns will have one space dividing them
- if a number is padded with blanks there will be more spaces seen for that number’s field
Examples: len_numeric_field¶
Turn off data column left-padding, set len_numeric_field to -1¶
This removes the padding of the numeric fields and leaves the lhs_spacer and spacer defaults of one space columns.
remove_padding=-1
las.write(s, len_numeric_field=remove_padding)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Set column width to less than the default: > 0 & < 10¶
Note in this example that only column 4 is 8 characters wide the other columns are 9 or more characters and expand to fit all their characters.
col_width = 8
las.write(s, len_numeric_field=col_width)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Set column width to more than the default: > 10¶
In this example all the columns are padded with space to make them wider. The lhs_spacer, left hand spacer, is still one space wide. The additional space on the left hand side is from the padding of the first data column to the requested col_width of 12 characters.
col_width = 12
las.write(s, len_numeric_field=col_width)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Examples: lhs_spacer¶
Remove the left most space, set lhs_spacer to an empty string¶
The output here removes the default 1 space column from the left hand side. Otherwise, it is the same as the initial default example.
empty_space = ""
las.write(s, lhs_spacer=empty_space)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Increase the left hand space, set lhs_spacer to a string with more spaces¶
In this example, there are 3 columns of space at the left hand side.
three_spaces = " "
las.write(s, lhs_spacer=three_spaces)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Examples: spacer¶
Increase the space between columns, set spacer to as string with more spaces¶
In this example, there are 3 columns of space separating the data columns from each other. In addition some of the columns have more space due to space-padding of their digits to the right of the decimal.
Note that the left hand side only has the 1 space, because it is not in between the columns and is set by the default lhs_spacer setting of one space.
three_spaces = " "
las.write(s, spacer=three_spaces)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.75000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
Use a different character as the spacer character¶
This example demonstrates using a comma as the column separator. This outputs a set of comma separated data values.
comma_spacer = ","
las.write(s, spacer=comma_spacer)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000, 123.45000,2550.00000, 0.45000, 123.45000, 123.45000, 110.20000, 105.60000
1669.87500, 123.45000,2550.00000, 0.45000, 123.45000, 123.45000, 110.20000, 105.60000
1669.75000, 123.45000,2550.00000, 0.45000, 123.45000, 123.45000, 110.20000, 105.60000
Examples: a combined example¶
This example shows that these options can be combined to produce a variety of output formats. Here the data section is output as a tight comma separated data set.
empty_lhs_spacer = ""
comma_spacer = ","
no_padding = -1
las.write(s, lhs_spacer=empty_lhs_spacer, spacer=comma_spacer, len_numeric_field=no_padding)
s.seek(1665)
print(s.read())
~ASCII -----------------------------------------------------
1670.00000,123.45000,2550.00000,0.45000,123.45000,123.45000,110.20000,105.60000
1669.87500,123.45000,2550.00000,0.45000,123.45000,123.45000,110.20000,105.60000
1669.75000,123.45000,2550.00000,0.45000,123.45000,123.45000,110.20000,105.60000