The change in the altitiude doesnt have anything to do with the codes.
A lean fuel condition may exist if the engine is sucking in too much air and/or the fuel system is not delivering enough fuel. If bad enough, a lean fuel condition may cause lean misfire, a rough idle, hesitation or stumble when accelerating, and/or poor engine performance.
Unmetered air can enter the engine through a vacuum leak, a dirty airflow sensor that is not reading airflow accurately, an EGR valve is not closing and is leaking exhaust into the intake manifold, an EGR valve that is allowing too much flow (because the EGR differential pressure sensor that monitors EGR flow is faulty and is under-reporting EGR flow).
If the problem is not enough fuel, the underling cause may be a weak fuel pump, restricted fuel filter, leaky fuel pressure regulator or dirty fuel injectors.
DIRTY MAF SENSOR
One of the most common causes of Ford P0171 and P0174 lean codes is a dirty mass airflow (MAF) sensor. The MAF sensor is located in the air inlet tube just ahead of the throttle body. The MAF sensor should be protected from outside dust and debris by the air filter, but sometimes the air filter doesn't fit real tight inside the housing and allows unfiltered air into the engine. Dirt can stick to the MAF sensor wire and form a coating that slows the response of the sensor to changes in airflow. The MAF sensor can also be contaminated by fuel vapors that back up through the intake manifold and throttle body when the engine is shut off. The vapors can leave a waxy coating on the sensor wire. This causes the MAF sensor to under report airflow, which in turn misleads the powertrain control module (PCM) so it doesn't add enough fuel to maintain a properly balanced air/fuel ratio. As a result, the engine runs lean and sets a P0171 and/or P0174 code (see Ford TSB 98-23-10 for details).
If the MAF is dirty, the fix is easy enough: just clean or replace the MAF sensor. In many instances, the MAF sensor can be successfully cleaned by spraying the sensor element with electronics cleaner. Do not use any other type of cleaner as this may damage the sensor.
Disconnect the air inlet tube just ahead of the sensor, and then spray the electronics cleaner through the screen at the wire element in the center of the little MAF sensor. Let the cleaner soak in for several minutes, then give it another shot of cleaner. Let it sit another five minutes, then reconnect the air inlet tubing and start the engine.
If the lean codes keep coming back, the MAF sensor may have to be replaced if the engine does not have a vacuum leak or fuel delivery problem.
Another common cause of Ford P0171 and P0174 ean codes is an engine vacuum leak. Ford TSB 04-17-4 details procedures for checking fuel trim and looking for vacuum leaks.
On 3.8L Fords with a split-plenum intake manifold, the port gaskets and isolator bolt assemblies for the upper plenum can deteriorate over time and leak air, often as a result of oil being sucked into the intake manifold through the PCV system. Also the vacuum hose that connects the fuel pressure regulator to the intake manifold can swell and leak vacuum where the hose connects to the manifold. Ford TSB 03-16-1 says the fix involves several steps: remove the upper manifold plenum and replace the original gaskets and bolts with revised ones, replace the front valve cover with a revised valve cover that reduces the amount of oil vapor sucked into the PCV system, inspect and replace the fuel pressure regulator hose, and finally, reflash the PCM so it is less sensitive to lean fuel conditions.